-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.gradle
117 lines (95 loc) · 3.19 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
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('.')))
sourceCompatibility = '1.8'
targetCompatibility = '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() // DateTimeFormatter.ofPattern("MMMM d yyyy", Locale.ENGLISH).withZone(ZoneOffset.UTC).format(Instant.now())
)
}
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.3"
final String jmhVersion = "1.37"
final String bcVersion = "1.79"
dependencies {
implementation("com.google.code.gson:gson:2.10.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:" + junitVersion)
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:" + junitVersion)
testImplementation("org.bouncycastle:bcprov-jdk14:" + bcVersion)
jmhImplementation("commons-codec:commons-codec:1.17.0")
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
}