-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle.kts
235 lines (208 loc) · 8.38 KB
/
build.gradle.kts
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
* Copyright (c) 2021-2024. caoccao.com Sam Cao
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.gradle.internal.os.OperatingSystem
object Config {
const val GROUP_ID = "com.caoccao.javet"
const val NAME = "Javenode"
const val VERSION = Versions.JAVENODE
const val URL = "https://github.com/caoccao/Javenode"
object Pom {
const val ARTIFACT_ID = "javenode"
const val DESCRIPTION =
"Javenode is Java + V8 + Node.js. It is a Node.js simulator with Java in V8."
object Developer {
const val ID = "caoccao"
const val EMAIL = "[email protected]"
const val NAME = "Sam Cao"
const val ORGANIZATION = "caoccao.com"
const val ORGANIZATION_URL = "https://www.caoccao.com"
}
object License {
const val NAME = "APACHE LICENSE, VERSION 2.0"
const val URL = "https://github.com/caoccao/Javenode/blob/main/LICENSE"
}
object Scm {
const val CONNECTION = "scm:git:git://github.com/Javenode.git"
const val DEVELOPER_CONNECTION = "scm:git:ssh://github.com/Javenode.git"
}
}
object Projects {
const val JAVET = "com.caoccao.javet:javet-core:${Versions.JAVET}"
const val JAVET_NODE_LINUX_ARM64 = "com.caoccao.javet:javet-node-linux-arm64:${Versions.JAVET}"
const val JAVET_NODE_LINUX_X86_64 = "com.caoccao.javet:javet-node-linux-x86_64:${Versions.JAVET}"
const val JAVET_NODE_MACOS_ARM64 = "com.caoccao.javet:javet-node-macos-arm64:${Versions.JAVET}"
const val JAVET_NODE_MACOS_X86_64 = "com.caoccao.javet:javet-node-macos-x86_64:${Versions.JAVET}"
const val JAVET_NODE_WINDOWS_X86_64 = "com.caoccao.javet:javet-node-windows-x86_64:${Versions.JAVET}"
const val JAVET_V8_LINUX_ARM64 = "com.caoccao.javet:javet-v8-linux-arm64:${Versions.JAVET}"
const val JAVET_V8_LINUX_X86_64 = "com.caoccao.javet:javet-v8-linux-x86_64:${Versions.JAVET}"
const val JAVET_V8_MACOS_ARM64 = "com.caoccao.javet:javet-v8-macos-arm64:${Versions.JAVET}"
const val JAVET_V8_MACOS_X86_64 = "com.caoccao.javet:javet-v8-macos-x86_64:${Versions.JAVET}"
const val JAVET_V8_WINDOWS_X86_64 = "com.caoccao.javet:javet-v8-windows-x86_64:${Versions.JAVET}"
// https://mvnrepository.com/artifact/com.caoccao.javet.buddy/javet-buddy
const val JAVET_BUDDY = "com.caoccao.javet.buddy:javet-buddy:${Versions.JAVET_BUDDY}"
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
const val JUNIT_JUPITER_API = "org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}"
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine
const val JUNIT_JUPITER_ENGINE = "org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}"
// https://mvnrepository.com/artifact/io.vertx/vertx-core
const val VERTX = "io.vertx:vertx-core:${Versions.VERTX}"
}
object Versions {
const val BYTE_BUDDY = "1.14.10"
const val JAVA_VERSION = "1.8"
const val JAVET = "4.0.0"
const val JAVET_BUDDY = "0.2.0"
const val JAVENODE = "0.9.0"
const val JUNIT = "5.10.1"
const val VERTX = "4.4.6"
}
}
val buildDir = layout.buildDirectory.get().toString()
plugins {
java
`java-library`
`maven-publish`
}
repositories {
mavenCentral()
}
group = Config.GROUP_ID
version = Config.VERSION
repositories {
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
dependencies {
val os = OperatingSystem.current()
val cpuArch = System.getProperty("os.arch")
val isArm64 = cpuArch == "aarch64" || cpuArch == "arm64";
compileOnly(Config.Projects.JAVET)
testImplementation(Config.Projects.JAVET)
if (os.isLinux) {
if (isArm64) {
compileOnly(Config.Projects.JAVET_NODE_LINUX_ARM64)
testImplementation(Config.Projects.JAVET_NODE_LINUX_ARM64)
compileOnly(Config.Projects.JAVET_V8_LINUX_ARM64)
testImplementation(Config.Projects.JAVET_V8_LINUX_ARM64)
} else {
compileOnly(Config.Projects.JAVET_NODE_LINUX_X86_64)
testImplementation(Config.Projects.JAVET_NODE_LINUX_X86_64)
compileOnly(Config.Projects.JAVET_V8_LINUX_X86_64)
testImplementation(Config.Projects.JAVET_V8_LINUX_X86_64)
}
} else if (os.isMacOsX) {
if (isArm64) {
compileOnly(Config.Projects.JAVET_NODE_MACOS_ARM64)
testImplementation(Config.Projects.JAVET_NODE_MACOS_ARM64)
compileOnly(Config.Projects.JAVET_V8_MACOS_ARM64)
testImplementation(Config.Projects.JAVET_V8_MACOS_ARM64)
} else {
compileOnly(Config.Projects.JAVET_NODE_MACOS_X86_64)
testImplementation(Config.Projects.JAVET_NODE_MACOS_X86_64)
compileOnly(Config.Projects.JAVET_V8_MACOS_X86_64)
testImplementation(Config.Projects.JAVET_V8_MACOS_X86_64)
}
} else if (os.isWindows && !isArm64) {
compileOnly(Config.Projects.JAVET_NODE_WINDOWS_X86_64)
testImplementation(Config.Projects.JAVET_NODE_WINDOWS_X86_64)
compileOnly(Config.Projects.JAVET_V8_WINDOWS_X86_64)
testImplementation(Config.Projects.JAVET_V8_WINDOWS_X86_64)
}
implementation(Config.Projects.JAVET_BUDDY)
implementation(Config.Projects.VERTX)
testImplementation(Config.Projects.JUNIT_JUPITER_API)
testRuntimeOnly(Config.Projects.JUNIT_JUPITER_ENGINE)
}
afterEvaluate {
tasks.withType(JavaCompile::class) {
options.compilerArgs.add("-Xlint:unchecked")
options.compilerArgs.add("-Xlint:deprecation")
}
}
tasks.test {
useJUnitPlatform {
excludeTags("performance")
}
}
tasks.register<Test>("performanceTest") {
useJUnitPlatform {
includeTags("performance")
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.withType<Test> {
systemProperty("file.encoding", "UTF-8")
}
tasks.withType<Javadoc> {
options.encoding = "UTF-8"
}
publishing {
publications {
create<MavenPublication>("generatePom") {
from(components["java"])
pom {
artifactId = Config.Pom.ARTIFACT_ID
description.set(Config.Pom.DESCRIPTION)
groupId = Config.GROUP_ID
name.set(Config.NAME)
url.set(Config.URL)
version = Config.VERSION
licenses {
license {
name.set(Config.Pom.License.NAME)
url.set(Config.Pom.License.URL)
}
}
developers {
developer {
id.set(Config.Pom.Developer.ID)
email.set(Config.Pom.Developer.EMAIL)
name.set(Config.Pom.Developer.NAME)
organization.set(Config.Pom.Developer.ORGANIZATION)
organizationUrl.set(Config.Pom.Developer.ORGANIZATION_URL)
}
}
scm {
connection.set(Config.Pom.Scm.CONNECTION)
developerConnection.set(Config.Pom.Scm.DEVELOPER_CONNECTION)
tag.set(Config.Versions.JAVENODE)
url.set(Config.URL)
}
properties.set(
mapOf(
"maven.compiler.source" to Config.Versions.JAVA_VERSION,
"maven.compiler.target" to Config.Versions.JAVA_VERSION,
)
)
}
}
}
}
tasks {
withType(Test::class.java) {
useJUnitPlatform()
}
withType<GenerateMavenPom> {
destination = file("$buildDir/libs/${Config.Pom.ARTIFACT_ID}-${Config.VERSION}.pom")
}
}