@@ -16,6 +16,7 @@ import org.swift.swiftkit.gradle.BuildUtils
1616
1717plugins {
1818 id(" build-logic.java-application-conventions" )
19+ id " me.champeau.jmh" version " 0.7.2"
1920}
2021
2122group = " org.swift.swiftkit"
@@ -31,43 +32,38 @@ java {
3132 }
3233}
3334
34- sourceSets {
35- generated {
36- java. srcDir " ${ buildDir} /generated/src/java/"
37- }
3835
39- // Make the 'main' and 'test' source sets depend on the generated sources
40- main {
41- compileClasspath + = sourceSets. generated. output
42- runtimeClasspath + = sourceSets. generated. output
43- }
44- test {
45- compileClasspath + = sourceSets. main. output
46- runtimeClasspath + = sourceSets. main. output
36+ def jextract = tasks. register(" jextract" , Exec ) {
37+ description = " Extracts Java accessor sources using jextract"
38+
39+ outputs. dir(layout. buildDirectory. dir(" generated/sources/jextract/main" ))
40+ inputs. dir(" $rootDir /Sources/ExampleSwiftLibrary" ) // monitored library
41+
42+ // any changes in the source generator sources also mean the resulting output might change
43+ inputs. dir(" $rootDir /Sources/JExtractSwift" )
44+ inputs. dir(" $rootDir /Sources/JExtractSwiftTool" )
4745
48- compileClasspath + = sourceSets. generated. output
49- runtimeClasspath + = sourceSets. generated. output
46+ workingDir = rootDir
47+ commandLine " make"
48+ args " jextract-generate"
49+ }
50+
51+ sourceSets {
52+ main {
53+ java {
54+ srcDir(jextract)
55+ }
5056 }
5157}
5258
5359dependencies {
5460 implementation(project(' :SwiftKit' ))
55- generatedImplementation(project(' :SwiftKit' ))
5661
5762 testImplementation(platform(" org.junit:junit-bom:5.10.0" ))
5863 testImplementation(" org.junit.jupiter:junit-jupiter" )
5964}
6065
61- configurations {
62- generatedImplementation. extendsFrom(mainImplementation)
63- generatedRuntimeOnly. extendsFrom(mainRuntimeOnly)
64- }
65-
66- tasks. named(" compileJava" ). configure {
67- dependsOn(" jextract" )
68- }
69-
70- tasks. test {
66+ tasks. named(' test' , Test ) {
7167 useJUnitPlatform()
7268}
7369
@@ -84,27 +80,15 @@ application {
8480 " --enable-native-access=ALL-UNNAMED" ,
8581
8682 // Include the library paths where our dylibs are that we want to load and call
87- " -Djava.library.path=" + BuildUtils . javaLibraryPaths(). join(" :" ),
83+ " -Djava.library.path=" + BuildUtils . javaLibraryPaths(rootDir ). join(" :" ),
8884
8985 // Enable tracing downcalls (to Swift)
9086 " -Djextract.trace.downcalls=true"
9187 ]
9288}
9389
94- task jextract (type : Exec ) {
95- description = " Extracts Java accessor sources using jextract"
96- outputs. dir(layout. buildDirectory. dir(" generated" ))
97- inputs. dir(" $rootDir /Sources/ExampleSwiftLibrary" ) // monitored library
98-
99- // any changes in the source generator sources also mean the resulting output might change
100- inputs. dir(" $rootDir /Sources/JExtractSwift" )
101- inputs. dir(" $rootDir /Sources/JExtractSwiftTool" )
102-
103- workingDir = rootDir
104- commandLine " make"
105- args " jextract-generate"
106- }
107-
108- tasks. named(" compileGeneratedJava" ). configure {
109- dependsOn jextract
110- }
90+ jmh {
91+ jvmArgsAppend = [
92+ " -Djava.library.path=" + BuildUtils . javaLibraryPaths(rootDir). join(" :" ),
93+ ]
94+ }
0 commit comments