-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
67 lines (49 loc) · 1.57 KB
/
build.gradle
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
apply plugin: "java"
version '1.0'
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
repositories{
mavenCentral()
maven{ url 'https://jitpack.io' }
}
ext{
mainClassName = "namegen.NameGen"
appName = "NameGen"
sdkRoot = System.getenv("ANDROID_HOME")
sdkVersion = "30"
doExec = { cmd ->
def proc = cmd.execute(null, new File("$buildDir/libs"))
proc.waitForProcessOutput(System.out, System.err)
}
}
task jarAndroid(type: Jar){
dependsOn "jar"
doLast{
def files = (configurations.compileClasspath.asList() + configurations.runtimeClasspath.asList() + [new File("$sdkRoot/platforms/android-$sdkVersion/android.jar")])
def dependencies = files.collect{ "--classpath $it.path" }.join(" ")
doExec("d8 $dependencies --min-api 14 --output ${appName}Android.jar ${appName}Desktop.jar")
}
manifest{
attributes("Main-Class": mainClassName)
}
}
jar{
archiveFileName = "${appName}Desktop.jar"
from {configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }}
manifest{
attributes("Main-Class": mainClassName)
}
}
task deploy(type: Jar){
dependsOn jarAndroid
dependsOn jar
archiveFileName = "${appName}.jar"
from{ [zipTree("$buildDir/libs/${appName}Desktop.jar"), zipTree("$buildDir/libs/${appName}Android.jar")] }
doLast{
delete{ delete "$buildDir/libs/${appName}Desktop.jar" }
delete{ delete "$buildDir/libs/${appName}Android.jar" }
}
manifest{
attributes("Main-Class": mainClassName)
}
}