@@ -27,9 +27,6 @@ def clang_version = clang_versions[0]
27
27
def jextract_app_dir = " $buildDir /jextract"
28
28
def clang_include_dir = " ${ llvm_home} /lib/clang/${ clang_version} /include"
29
29
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"' ;
33
30
def os_lib_dir = Os . isFamily(Os . FAMILY_WINDOWS )? " bin" : " lib"
34
31
def os_script_extension = Os . isFamily(Os . FAMILY_WINDOWS )? " .bat" : " "
35
32
def libclang_dir = " ${ llvm_home} /${ os_lib_dir} "
@@ -40,7 +37,7 @@ repositories {
40
37
}
41
38
42
39
compileJava {
43
- options. compilerArgs . addAll([ ' -- release' , ' 18 ' ])
40
+ options. release = 18
44
41
options. compilerArgs << " --add-modules=jdk.incubator.foreign"
45
42
options. compilerArgs << " -Xlint:all"
46
43
options. fork = true
55
52
task createJextractImage (type : Exec ) {
56
53
dependsOn jar
57
54
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
+ }
59
66
60
67
executable = " ${ jdk18_home} /bin/jlink"
61
68
args = [
@@ -90,6 +97,9 @@ task jextractapp() {
90
97
dependsOn copyLibClang
91
98
}
92
99
100
+ // build the jextract image when the build or assemble task is run
101
+ assemble. dependsOn(jextractapp)
102
+
93
103
// very simple integration test for generated jextract
94
104
task verify (type : Exec ) {
95
105
dependsOn jextractapp
@@ -102,12 +112,21 @@ task verify(type: Exec) {
102
112
task createRuntimeImageForTest (type : Exec ) {
103
113
dependsOn verify
104
114
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
+
106
125
executable = " ${ jdk18_home} /bin/jlink"
107
126
args = [
108
127
" --module-path=$buildDir /libs" + File . pathSeparator + " $jdk18_home /jmods" ,
109
128
" --add-modules=ALL-MODULE-PATH" ,
110
- " --output=$b uildDir /jextract-jdk-test-image " ,
129
+ " --output=$o ut_dir " ,
111
130
]
112
131
}
113
132
@@ -150,7 +169,7 @@ task cmakeBuild(type: Exec) {
150
169
]
151
170
}
152
171
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
154
173
task jtreg (type : JavaExec ) {
155
174
dependsOn prepareTestJDK,cmakeBuild
156
175
0 commit comments