forked from wasmerio/wasmer-java
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
137 lines (112 loc) · 3.36 KB
/
build.gradle
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
plugins {
id "java"
// As Wasmer is a package, we need tools to build the JARs and so
id "java-library"
}
allprojects {
group "org.wasmer"
version "1.1.0"
}
// This is needed for the Java plugin to make sure
// the generated class files are compatible with
// old versions of Java.
sourceCompatibility = 21
targetCompatibility = 21
sourceSets {
main {
java {
srcDirs = ["src/java"]
}
resources {
srcDirs = ["$buildDir/toArtifact"]
}
}
test {
java {
srcDirs = ["test/org"]
}
resources {
srcDirs = ["test/resources"]
}
}
}
javadoc {
options.links "https://docs.oracle.com/javase/8/docs/api/"
// TODO: change when https://github.com/gradle/gradle/issues/2354 is fixed
options.addStringOption "Xdoclint:all", "-Xdoclint:-missing"
}
repositories {
jcenter()
google()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.2")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.4.2")
testImplementation("org.junit.platform:junit-platform-commons:1.6.0")
testImplementation("org.junit.platform:junit-platform-engine:1.6.0")
testImplementation("com.github.luben:zstd-jni:1.5.2-5")
}
test {
useJUnitPlatform()
}
jar {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": project.version)
}
}
task generateJniHeaders(type: JavaCompile) {
description "Generate the JNI header files (in `include/`)."
classpath = sourceSets.main.compileClasspath
destinationDir file("include")
source = sourceSets.main.java
options.compilerArgs += [
"-h", file("include"),
]
options.verbose = true
}
task buildRust(type: Exec) {
dependsOn generateJniHeaders
description "Build the Rust project."
commandLine "make", "build-rust"
}
task copyAllArtifacts(type: Copy) {
dependsOn buildRust
description "Copy artifacts to the `build/` directory. If a non-empty directory exists at the value of " +
"'EXT_ARTIFACTS_DIR' env variable it copies its contents, otherwise it copies from the artifacts folder."
def extArtifactsDir = System.getenv('EXT_ARTIFACTS_DIR')
def sourceDir = extArtifactsDir != null && !extArtifactsDir.isBlank()
? extArtifactsDir
: 'artifacts'
from(sourceDir)
include '**/*'
into "$buildDir/toArtifact/org/wasmer/native/"
}
tasks.withType(Test) {
// We add the path, so the Java Tests can find the
// shared object file
systemProperty "java.library.path", "target/current/"
testLogging {
outputs.upToDateWhen { false }
// Don"t capture the standard output.
showStandardStreams = true
}
}
jar.doLast() {
// Display specific “action outputs” for Github Actions.
def jar_name = project.archivesBaseName + "-" + project.version + ".jar"
println(jar_name)
println("::set-output name=path::./build/libs/" + jar_name)
println("::set-output name=name::" + jar_name)
}
jar.outputs.upToDateWhen { false }
// We build the integration before running any test
compileTestJava.dependsOn buildRust
processResources.dependsOn copyAllArtifacts
// Local Variables:
// mode: java
// End:
// vim: set ft=java :