-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
build.gradle.kts
213 lines (187 loc) · 7.09 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
/*
* 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.
*/
object Config {
const val GROUP_ID = "com.caoccao.javet"
const val NAME = "Javet"
const val VERSION = Versions.JAVET
const val URL = "https://github.com/caoccao/Javet"
object Pom {
const val ARTIFACT_ID = "javet"
const val DESCRIPTION =
"Javet is Java + V8 (JAVa + V + EighT). It is an awesome way of embedding Node.js and V8 in Java."
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/Javet/blob/main/LICENSE"
}
object Scm {
const val CONNECTION = "scm:git:git://github.com/Javet.git"
const val DEVELOPER_CONNECTION = "scm:git:ssh://github.com/Javet.git"
}
}
object Projects {
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
const val JACKSON_DATABIND = "com.fasterxml.jackson.core:jackson-databind:${Versions.JACKSON_DATABIND}"
// 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.eclipse.jetty.websocket/javax-websocket-server-impl
const val JETTY_JAVAX_WEBSOCKET_SERVER_IMPL =
"org.eclipse.jetty.websocket:javax-websocket-server-impl:${Versions.JETTY_WEBSOCKET}"
// https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-server
const val JETTY_WEBSOCKET_SERVER = "org.eclipse.jetty.websocket:websocket-server:${Versions.JETTY_WEBSOCKET}"
// 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/org.junit.jupiter/junit-jupiter-params
const val JUNIT_JUPITER_PARAMS = "org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}"
}
object Versions {
const val JACKSON_DATABIND = "2.16.0"
const val JAVA_VERSION = "1.8"
const val JAVET = "4.0.0"
const val JAVET_BUDDY = "0.2.0"
const val JETTY_WEBSOCKET = "9.4.53.v20231009"
const val JUNIT = "5.10.1"
}
}
val buildDir = layout.buildDirectory.get().toString()
plugins {
java
`java-library`
`maven-publish`
}
group = Config.GROUP_ID
version = Config.VERSION
repositories {
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
dependencies {
testImplementation(Config.Projects.JACKSON_DATABIND)
testImplementation(Config.Projects.JAVET_BUDDY)
testImplementation(Config.Projects.JETTY_JAVAX_WEBSOCKET_SERVER_IMPL)
testImplementation(Config.Projects.JETTY_WEBSOCKET_SERVER)
testImplementation(Config.Projects.JUNIT_JUPITER_API)
testImplementation(Config.Projects.JUNIT_JUPITER_PARAMS)
// testImplementation(files("../JavetBuddy/build/libs/javet-buddy-${Config.Versions.JAVET_BUDDY}.jar"))
testRuntimeOnly(Config.Projects.JUNIT_JUPITER_ENGINE)
}
afterEvaluate {
tasks.withType(JavaCompile::class) {
options.compilerArgs.add("-Xlint:unchecked")
options.compilerArgs.add("-Xlint:deprecation")
}
}
task<Exec>("buildJNIHeaders") {
mkdir("$buildDir/generated/tmp/jni")
project.exec {
workingDir("$projectDir")
commandLine(
"javac",
"-h",
"cpp/jni",
"-d",
"$buildDir/generated/tmp/jni",
"src/main/java/com/caoccao/javet/interop/INodeNative.java",
"src/main/java/com/caoccao/javet/interop/IV8Native.java",
"src/main/java/com/caoccao/javet/interop/NodeNative.java",
"src/main/java/com/caoccao/javet/interop/V8Native.java"
)
}
}
tasks.jar {
manifest {
attributes["Automatic-Module-Name"] = Config.GROUP_ID
}
}
tasks.test {
useJUnitPlatform {
excludeTags("performance")
}
}
tasks.register<Test>("performanceTest") {
useJUnitPlatform {
includeTags("performance")
}
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
}
withType<Javadoc> {
options.encoding = "UTF-8"
}
withType<Test> {
systemProperty("file.encoding", "UTF-8")
}
withType<GenerateMavenPom> {
destination = file("$buildDir/libs/${Config.Pom.ARTIFACT_ID}-${Config.VERSION}.pom")
}
}
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.JAVET)
url.set(Config.URL)
}
properties.set(
mapOf(
"maven.compiler.source" to Config.Versions.JAVA_VERSION,
"maven.compiler.target" to Config.Versions.JAVA_VERSION,
)
)
}
}
}
}