File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -78,8 +78,14 @@ def swiftProductsWithJExtractPlugin() {
7878 }
7979}
8080
81+ def swiftCheckValid = tasks. register(" swift-check-valid" , Exec ) {
82+ commandLine " swift"
83+ args(" -version" )
84+ }
85+
8186def jextract = tasks. register(" jextract" , Exec ) {
8287 description = " Generate Java wrappers for swift target"
88+ dependsOn swiftCheckValid
8389 // dependsOn compileSwiftJExtractPlugin
8490
8591 // only because we depend on "live developing" the plugin while using this project to test it
@@ -90,7 +96,8 @@ def jextract = tasks.register("jextract", Exec) {
9096 inputs. file(new File (projectDir, " Package.swift" ))
9197
9298 // monitor all targets/products which depend on the JExtract plugin
93- swiftProductsWithJExtractPlugin(). each {
99+ // swiftProductsWithJExtractPlugin().each {
100+ [" MySwiftLibrary" ]. each {
94101 logger. info(" [swift-java:jextract (Gradle)] Swift input target: ${ it} " )
95102 inputs. dir(new File (layout. projectDirectory. asFile, " Sources/${ it} " . toString()))
96103 }
Original file line number Diff line number Diff line change 88# check if we can compile a plain Example file that uses the generated Java bindings that should be in the generated jar
99javac -cp bin/default/build/libs/* jar Example.java
1010
11- # Can we run the example?
12- # - find libswiftCore.dylib
13- SWIFT_DYLIB_PATHS=$( find " $( swiftly use --print-location) " | grep dylib$ | grep libswiftCore | grep macos | xargs dirname)
14- # - find our library dylib
15- SWIFT_DYLIB_PATHS=" ${SWIFT_DYLIB_PATHS} :$( find . | grep libMySwiftLibrary.dylib$ | sort | head -n1 | xargs dirname) "
16- java -Djava.library.path=" ${SWIFT_DYLIB_PATHS} " -cp " .:bin/default/build/libs/*jar:../../SwiftKit/build/libs/*jar" Example
11+ if [[ " $( uname -s) " -eq ' Linux' ]]
12+ then
13+ # Can we run the example?
14+ # - find libswiftCore.dylib
15+ SWIFT_DYLIB_PATHS=$( find " $( swiftly use --print-location) " | grep dylib$ | grep libswiftCore | grep macos | xargs dirname)
16+ # - find our library dylib
17+ SWIFT_DYLIB_PATHS=" ${SWIFT_DYLIB_PATHS} :$( find . | grep libMySwiftLibrary.dylib$ | sort | head -n1 | xargs dirname) "
18+ java -Djava.library.path=" ${SWIFT_DYLIB_PATHS} " -cp " .:bin/default/build/libs/*jar:../../SwiftKit/build/libs/*jar" Example
19+ elif [[ " $( uname -s) " -eq ' Darwin' ]]
20+ fi
Original file line number Diff line number Diff line change @@ -30,13 +30,19 @@ repositories {
3030
3131java {
3232 toolchain {
33- languageVersion. set(JavaLanguageVersion . of(22 ))
33+ languageVersion. set(JavaLanguageVersion . of(23 ))
3434 }
3535}
3636
37+ def swiftCheckValid = tasks. register(" swift-check-valid" , Exec ) {
38+ commandLine " swift"
39+ args(" -version" )
40+ }
41+
3742def jextract = tasks. register(" jextract" , Exec ) {
3843 description = " Builds swift sources, including swift-java source generation"
39- dependsOn compileSwiftJExtractPlugin
44+ dependsOn swiftCheckValid
45+ // dependsOn compileSwiftJExtractPlugin
4046
4147 // only because we depend on "live developing" the plugin while using this project to test it
4248 inputs. file(new File (rootDir, " Package.swift" ))
You can’t perform that action at this time.
0 commit comments