forked from swiftlang/swift-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
122 lines (103 loc) · 3.19 KB
/
build.gradle.kts
File metadata and controls
122 lines (103 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import utilities.javaLibraryPaths
import utilities.registerJextractTask
plugins {
id("build-logic.java-application-conventions")
id("me.champeau.jmh") version "0.7.2"
}
group = "org.swift.swiftkit"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(25))
}
}
val jextract = registerJextractTask {
// FIXME: disable prebuilts until swift-syntax isn't broken on 6.2 anymore: https://github.com/swiftlang/swift-java/issues/418
val cmdArgs = mutableListOf("build", "--disable-experimental-prebuilts", "--disable-sandbox")
if (project.hasProperty("swiftSdk")) {
// If it was, add the --sdk argument and its value
cmdArgs.add("--swift-sdk")
cmdArgs.add(project.property("swiftSdk").toString())
}
cmdArgs
}
// Add the java-swift generated Java sources
sourceSets {
main {
java {
srcDir(jextract)
}
}
test {
java {
srcDir(jextract)
}
}
this.jmh {
java {
srcDir(jextract)
}
}
}
tasks.build {
dependsOn(jextract)
}
registerCleanSwift()
dependencies {
implementation(projects.swiftKitCore)
testRuntimeOnly(libs.junit.platform.launcher) // TODO: workaround for not finding junit: https://github.com/gradle/gradle/issues/34512
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
}
tasks.named<Test>("test") {
useJUnitPlatform()
testLogging {
events("failed")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
application {
mainClass = "com.example.swift.HelloJava2SwiftJNI"
applicationDefaultJvmArgs = listOf(
"--enable-native-access=ALL-UNNAMED",
// Include the library paths where our dylibs are that we want to load and call
"-Djava.library.path=" + javaLibraryPaths(project.projectDir).joinToString(File.pathSeparator),
// Enable tracing downcalls (to Swift)
"-Djextract.trace.downcalls=true"
)
}
val jmhIncludes = findProperty("jmhIncludes")
jmh {
if (jmhIncludes != null) {
includes = listOf(jmhIncludes.toString())
}
jvmArgsAppend = listOf(
"--enable-native-access=ALL-UNNAMED",
"-Djava.library.path=" + javaLibraryPaths(project.projectDir).joinToString(File.pathSeparator),
// Enable tracing downcalls (to Swift)
"-Djextract.trace.downcalls=false"
)
}
tasks.register("printGradleHome") {
doLast {
println("Gradle Home: ${gradle.gradleHomeDir}")
println("Gradle Version: ${gradle.gradleVersion}")
println("Gradle User Home: ${gradle.gradleUserHomeDir}")
}
}