-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
44 lines (35 loc) · 1.38 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
plugins {
id 'com.github.johnrengelman.shadow' version '5.0.0'
id 'java'
}
sourceCompatibility = 1.8
// Set this to your Graal Home Directory
def graalHome = '/opt/graalvm-ee-1.0.0-rc13/Contents/Home/bin'
repositories {
mavenCentral()
}
configurations {
generateConfig
}
dependencies {
compile 'info.picocli:picocli:3.9.5'
compile 'org.fusesource.jansi:jansi:1.17.1' //Prevents native-image build from blowing up
generateConfig 'info.picocli:picocli-codegen:3.9.5'
}
jar {
manifest {
attributes 'Main-Class': 'example.cli.Example'
}
}
shadowJar.dependsOn build
task generateGraalReflectionConfig (dependsOn: 'classes', type: JavaExec) {
main = 'picocli.codegen.aot.graalvm.ReflectionConfigGenerator'
classpath = configurations.generateConfig + sourceSets.main.runtimeClasspath
def outputFile = new File(project.buildDir, 'cli-reflect.json')
//args = ["--output=$outputFile", 'com.your.package.YourCommand1', 'com.your.package.YourCommand2']
args = ["--output=$outputFile", 'example.cli.Example']
}
assemble.dependsOn generateGraalReflectionConfig
task nativeImage (type: Exec, dependsOn: shadowJar) {
commandLine "$graalHome/native-image", "-H:ReflectionConfigurationFiles=$buildDir/cli-reflect.json", "-H:+ReportUnsupportedElementsAtRuntime", "--no-server", "-jar", "$buildDir/libs/picocli-graalvm-example-$version-all.jar"
}