-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopyAll.py
32 lines (26 loc) · 1.36 KB
/
copyAll.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/python3
import os
import shutil
# This script copies all jars in build/libs from every gradle
# subproject to the current directory's build/libs directory.
# Get the current directory
currentDir = os.getcwd()
# Get the libs directory
libsDir = currentDir + "/build/libs"
# Get the list of subprojects
# A subproject is a directory in the current directory that contains a build.gradle file
subprojects = os.listdir(currentDir)
subprojects = [sub for sub in subprojects if os.path.isdir(sub)]
subprojects = [sub for sub in subprojects if os.path.isfile(sub + "/build.gradle")]
# Get the list of build/libs directories
subprojectsBuildLibs: list[str] = list(map(lambda sub: sub + "/build/libs", subprojects))
subprojectsBuildLibs = list(filter(lambda sub: os.path.isdir(sub), subprojectsBuildLibs))
# Get the list of jars in build/libs
subprojectsBuildLibsJars: list[tuple[list[str] | list[bytes], str]] = \
list(map(lambda sub: (os.listdir(sub), sub), subprojectsBuildLibs))
subprojectsBuildLibsJars = list(filter(lambda sub: len(sub[0]) > 0, subprojectsBuildLibsJars))
# Copy the jars to the libs directory
for subprojectBuildLibsJars, subprojectBuildLibs in subprojectsBuildLibsJars:
for jar in subprojectBuildLibsJars:
print("Copying " + jar + " from " + subprojectBuildLibs + " to " + libsDir)
shutil.copy(subprojectBuildLibs + "/" + jar, libsDir)