1414
1515import org.swift.swiftkit.gradle.BuildUtils
1616
17+ import java.nio.file.Files
18+
1719plugins {
1820 id(" build-logic.java-application-conventions" )
1921// id("me.champeau.jmh") version "0.7.2"
@@ -33,18 +35,28 @@ java {
3335}
3436
3537
36- def jextract = tasks. register(" swift- build" , Exec ) {
38+ def buildSwift = tasks. register(" build-swift " , Exec ) {
3739 description = " Builds swift sources, including swift-java source generation"
3840
39- // monitor project Swift sources:
41+ // monitor root project Swift sources:
4042 inputs. dir(layout. projectDirectory. dir(" Sources/" ))
43+ println (" INPUT = ${ layout.projectDirectory.dir("Sources/")} " )
4144
4245 // monitor root java-swift sources (including source generator libs which may be changing):
4346 inputs. dir(" $rootDir /Sources" )
47+ println (" INPUT = ${ "$rootDir/Sources"} " )
4448
4549 // the swift-java produced Java sources are located here:
4650 outputs. dir(layout. buildDirectory. dir(" ../.build/plugins/outputs/jextractpluginsampleapp/JExtractPluginSampleLib/destination/JExtractSwiftPlugin/src/generated/java" ))
4751
52+ Files . walk(layout. buildDirectory. dir(" ../.build/plugins/outputs/" ). get(). asFile. toPath()). each {
53+ println (" PATH === ${ it} " )
54+ if (it. endsWith(" JExtractSwiftPlugin/src/generated/java" )) {
55+ outputs. dir(it)
56+ println (" MAKE IT AN OUTPUT" )
57+ }
58+ }
59+
4860 workingDir = rootDir
4961 commandLine " swift"
5062 args " build"
@@ -54,7 +66,7 @@ def jextract = tasks.register("swift-build", Exec) {
5466sourceSets {
5567 main {
5668 java {
57- srcDir(jextract )
69+ srcDir(buildSwift )
5870 }
5971 }
6072}
@@ -71,7 +83,7 @@ tasks.named('test', Test) {
7183}
7284
7385application {
74- mainClass = " com.example.swift.HelloJava2Swift "
86+ mainClass = " com.example.swift.JExtractPluginSampleMain "
7587
7688 // In order to silence:
7789 // WARNING: A restricted method in java.lang.foreign.SymbolLookup has been called
@@ -83,7 +95,9 @@ application {
8395 " --enable-native-access=ALL-UNNAMED" ,
8496
8597 // Include the library paths where our dylibs are that we want to load and call
86- " -Djava.library.path=" + BuildUtils . javaLibraryPaths(rootDir). join(" :" ),
98+ " -Djava.library.path=" +
99+ (BuildUtils . javaLibraryPaths(rootDir) +
100+ BuildUtils . javaLibraryPaths(layout. projectDirectory. asFile)). join(" :" ),
87101
88102 // Enable tracing downcalls (to Swift)
89103 " -Djextract.trace.downcalls=true"
0 commit comments