-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.gradle
127 lines (105 loc) · 3.47 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
import java.text.SimpleDateFormat
plugins {
id("java-library")
id("maven-publish")
}
group = "com.esaulpaugh"
version = "12.3.4-SNAPSHOT"
final String versionStr = getProject().getGradle().getGradleVersion()
final int gradleMajorVersion = Integer.parseUnsignedInt(versionStr.substring(0, versionStr.indexOf((int)".".charAt(0))))
if (gradleMajorVersion >= 5) {
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
} else {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileJava {
if (JavaVersion.current() >= JavaVersion.VERSION_1_10) {
options.compilerArgs.addAll(["--release", "8"])
}
}
tasks.withType(JavaCompile) {
options.encoding = "US-ASCII"
}
test {
useJUnitPlatform()
maxParallelForks = Runtime.runtime.availableProcessors()
}
task javadocJar(type: Jar, dependsOn: javadoc) {
if (gradleMajorVersion >= 6) getArchiveClassifier().set("javadoc")
else classifier = "javadoc"
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
if (gradleMajorVersion >= 6) getArchiveClassifier().set("sources")
else classifier = "sources"
from sourceSets.main.allSource
}
static String todayUTC() {
SimpleDateFormat sdf = new SimpleDateFormat("MMMMM d yyyy")
sdf.setTimeZone(TimeZone.getTimeZone("UTC"))
return sdf.format(new Date())
}
jar {
manifest {
attributes(
"Implementation-Title": project.name,
"Implementation-Version": project.version,
"Automatic-Module-Name": "com.esaulpaugh.headlong",
"Created-By": "Gradle",
"Build-Date": todayUTC()
)
}
finalizedBy(sourcesJar)
}
artifacts {
archives javadocJar, sourcesJar
}
publishing {
publications {
headlong(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
}
}
sourceSets {
jmh {
java.srcDirs = ["src/jmh/java"]
compileClasspath += sourceSets.main.runtimeClasspath
}
}
repositories {
mavenCentral()
}
final String junitVersion = "5.11.4"
final String jmhVersion = "1.37"
final String bcVersion = "1.80"
dependencies {
implementation("com.google.code.gson:gson:[2.1, 2.12.0]") {
exclude(group: "com.google.errorprone", module: "error_prone_annotations")
}
testImplementation("org.junit.jupiter:junit-jupiter-api:" + junitVersion)
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:" + junitVersion)
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.11.4")
testImplementation("org.bouncycastle:bcprov-jdk14:" + bcVersion)
jmhImplementation("commons-codec:commons-codec:1.17.2")
jmhImplementation("org.openjdk.jmh:jmh-core:" + jmhVersion)
jmhAnnotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:" + jmhVersion)
jmhImplementation("org.bouncycastle:bcprov-jdk14:" + bcVersion)
}
task jmh(type: JavaExec, dependsOn: jmhClasses) { // run benchmarks with `gradle jmh`
if (gradleMajorVersion >= 7) getMainClass().set("org.openjdk.jmh.Main")
else main = "org.openjdk.jmh.Main"
classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath
}
classes.finalizedBy(jmhClasses)
// tasks.withType(AbstractArchiveTask).configureEach {
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}