14
14
15
15
import org.swift.swiftkit.gradle.BuildUtils
16
16
17
+ import java.nio.file.Files
18
+
17
19
plugins {
18
20
id(" build-logic.java-application-conventions" )
19
21
// id("me.champeau.jmh") version "0.7.2"
@@ -33,18 +35,28 @@ java {
33
35
}
34
36
35
37
36
- def jextract = tasks. register(" swift- build" , Exec ) {
38
+ def buildSwift = tasks. register(" build-swift " , Exec ) {
37
39
description = " Builds swift sources, including swift-java source generation"
38
40
39
- // monitor project Swift sources:
41
+ // monitor root project Swift sources:
40
42
inputs. dir(layout. projectDirectory. dir(" Sources/" ))
43
+ println (" INPUT = ${ layout.projectDirectory.dir("Sources/")} " )
41
44
42
45
// monitor root java-swift sources (including source generator libs which may be changing):
43
46
inputs. dir(" $rootDir /Sources" )
47
+ println (" INPUT = ${ "$rootDir/Sources"} " )
44
48
45
49
// the swift-java produced Java sources are located here:
46
50
outputs. dir(layout. buildDirectory. dir(" ../.build/plugins/outputs/jextractpluginsampleapp/JExtractPluginSampleLib/destination/JExtractSwiftPlugin/src/generated/java" ))
47
51
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
+
48
60
workingDir = rootDir
49
61
commandLine " swift"
50
62
args " build"
@@ -54,7 +66,7 @@ def jextract = tasks.register("swift-build", Exec) {
54
66
sourceSets {
55
67
main {
56
68
java {
57
- srcDir(jextract )
69
+ srcDir(buildSwift )
58
70
}
59
71
}
60
72
}
@@ -71,7 +83,7 @@ tasks.named('test', Test) {
71
83
}
72
84
73
85
application {
74
- mainClass = " com.example.swift.HelloJava2Swift "
86
+ mainClass = " com.example.swift.JExtractPluginSampleMain "
75
87
76
88
// In order to silence:
77
89
// WARNING: A restricted method in java.lang.foreign.SymbolLookup has been called
@@ -83,7 +95,9 @@ application {
83
95
" --enable-native-access=ALL-UNNAMED" ,
84
96
85
97
// 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(" :" ),
87
101
88
102
// Enable tracing downcalls (to Swift)
89
103
" -Djextract.trace.downcalls=true"
0 commit comments