-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
111 lines (89 loc) · 3.01 KB
/
build.gradle.kts
File metadata and controls
111 lines (89 loc) · 3.01 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
//===----------------------------------------------------------------------===//
//
// 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 kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import org.swift.swiftkit.gradle.BuildUtils
import java.io.ByteArrayOutputStream
import java.io.File
import java.nio.file.*
import kotlin.concurrent.thread
plugins {
id("build-logic.java-application-conventions")
id("me.champeau.jmh") version "0.7.2"
id("swiftpm-import-plugin")
}
group = "org.swift.swiftkit"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(25))
}
}
// Add the java-swift generated Java sources
val cleanSwift = tasks.register("cleanSwift", Exec::class.java) {
workingDir = layout.projectDirectory.asFile
commandLine = listOf("swift")
args("package", "clean")
}
tasks.clean {
dependsOn("cleanSwift")
}
dependencies {
implementation(project(":SwiftKitCore"))
implementation(project(":SwiftKitFFM"))
testRuntimeOnly("org.junit.platform:junit-platform-launcher") // TODO: workaround for not finding junit: https://github.com/gradle/gradle/issues/34512 // TODO: workaround for not finding junit: https://github.com/gradle/gradle/issues/34512
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks.named("test", Test::class.java) {
useJUnitPlatform()
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
}
application {
mainClass = "com.example.swift.HelloJava2Swift"
}
val jmhIncludes = findProperty("jmhIncludes") as? String
jmh {
if (jmhIncludes != null) {
includes.set(setOf(jmhIncludes))
}
jvmArgsAppend = listOf(
"--enable-native-access=ALL-UNNAMED",
"-Djava.library.path=" +
((BuildUtils.javaLibraryPaths(rootDir) as Iterable<String>) +
(BuildUtils.javaLibraryPaths(project.projectDir) as Iterable<String>)).joinToString(":"),
// Enable tracing downcalls (to Swift)
"-Djextract.trace.downcalls=false"
)
}
swiftPMDependencies {
`package`(
url = url("https://github.com/abdulowork/SwiftPMImport.git"),
version = exact("1.0.12"),
products = listOf(product("SwiftPMImport", importedModules = setOf("SwiftTarget", "TargetWithAlgorithms"))),
)
localPackage(
path = projectDir,
products = listOf("MySwiftLibrary")
)
swiftJavaRepository.set(rootDir)
}