Skip to content

Commit d8cdb67

Browse files
danieljarabekmcimadamore
authored andcommittedMay 5, 2022
gradle buildscript improvements
Reviewed-by: mcimadamore
1 parent 6510048 commit d8cdb67

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed
 

‎build.gradle

+27-8
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ def clang_version = clang_versions[0]
2727
def jextract_app_dir = "$buildDir/jextract"
2828
def clang_include_dir = "${llvm_home}/lib/clang/${clang_version}/include"
2929
checkPath(clang_include_dir)
30-
def quote_jlink_opts = Os.isFamily(Os.FAMILY_WINDOWS)?
31-
"\\\"--enable-native-access=org.openjdk.jextract\\\"" :
32-
'"--enable-native-access=org.openjdk.jextract"';
3330
def os_lib_dir = Os.isFamily(Os.FAMILY_WINDOWS)? "bin" : "lib"
3431
def os_script_extension = Os.isFamily(Os.FAMILY_WINDOWS)? ".bat" : ""
3532
def libclang_dir = "${llvm_home}/${os_lib_dir}"
@@ -40,7 +37,7 @@ repositories {
4037
}
4138

4239
compileJava {
43-
options.compilerArgs.addAll(['--release', '18'])
40+
options.release = 18
4441
options.compilerArgs << "--add-modules=jdk.incubator.foreign"
4542
options.compilerArgs << "-Xlint:all"
4643
options.fork = true
@@ -55,7 +52,17 @@ jar {
5552
task createJextractImage(type: Exec) {
5653
dependsOn jar
5754

58-
onlyIf { !new File("${jextract_app_dir}").exists() }
55+
// if these inputs or outputs change, gradle will rerun the task
56+
inputs.file(jar.archiveFile.get())
57+
outputs.dir(jextract_app_dir)
58+
59+
def quote_jlink_opts = Os.isFamily(Os.FAMILY_WINDOWS)?
60+
'\\"--enable-native-access=org.openjdk.jextract\\"' :
61+
'"--enable-native-access=org.openjdk.jextract"'
62+
63+
doFirst {
64+
delete(jextract_app_dir)
65+
}
5966

6067
executable = "${jdk18_home}/bin/jlink"
6168
args = [
@@ -90,6 +97,9 @@ task jextractapp() {
9097
dependsOn copyLibClang
9198
}
9299

100+
// build the jextract image when the build or assemble task is run
101+
assemble.dependsOn(jextractapp)
102+
93103
// very simple integration test for generated jextract
94104
task verify(type: Exec) {
95105
dependsOn jextractapp
@@ -102,12 +112,21 @@ task verify(type: Exec) {
102112
task createRuntimeImageForTest(type: Exec) {
103113
dependsOn verify
104114

105-
onlyIf { !new File("$buildDir/jextract-jdk-test-image").exists() }
115+
def out_dir = "$buildDir/jextract-jdk-test-image"
116+
117+
// if these inputs or outputs change, gradle will rerun the task
118+
inputs.file(jar.archiveFile.get())
119+
outputs.dir(out_dir)
120+
121+
doFirst {
122+
delete(out_dir)
123+
}
124+
106125
executable = "${jdk18_home}/bin/jlink"
107126
args = [
108127
"--module-path=$buildDir/libs" + File.pathSeparator + "$jdk18_home/jmods",
109128
"--add-modules=ALL-MODULE-PATH",
110-
"--output=$buildDir/jextract-jdk-test-image",
129+
"--output=$out_dir",
111130
]
112131
}
113132

@@ -150,7 +169,7 @@ task cmakeBuild(type: Exec) {
150169
]
151170
}
152171

153-
// run jtreg tests. Note: needs jtreg_cmd variable set to point to the jtreg
172+
// run jtreg tests. Note: needs jtreg_home variable set to point to the jtreg
154173
task jtreg(type: JavaExec) {
155174
dependsOn prepareTestJDK,cmakeBuild
156175

0 commit comments

Comments
 (0)
Please sign in to comment.