-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
221 lines (184 loc) · 5.64 KB
/
build.gradle
File metadata and controls
221 lines (184 loc) · 5.64 KB
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
import java.time.Year
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id 'idea'
id 'java-library'
id 'com.github.hierynomus.license' version "0.16.1" apply false
id 'biz.aQute.bnd.builder' version '7.1.0' apply false
}
defaultTasks 'clean', 'build'
def projGroup = 'org.tools4j'
def projVersion = file('version.txt').text.trim()
def junitVersion = '5.13.4'
static def getBuildJavaVersion() {
def buildJavaVersion = JavaVersion.current().getMajorVersion()
if (buildJavaVersion.indexOf('.') > 0) {
buildJavaVersion = buildJavaVersion.substring(0, buildJavaVersion.indexOf('.'))
}
if (buildJavaVersion.indexOf('-') > 0) {
buildJavaVersion = buildJavaVersion.substring(0, buildJavaVersion.indexOf('-'))
}
Integer.parseInt(buildJavaVersion)
}
int buildJavaVersion = getBuildJavaVersion()
ext {
//gradle clean build publish -PossrhUsername=mterzer -PossrhPassword=xxx
isReleaseVersion = !projVersion.endsWith('-SNAPSHOT')
releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
println name + " version=" + projVersion + " release=" + isReleaseVersion
if (!project.hasProperty('ossrhUsername')) {
ossrhUsername = ''
}
if (!project.hasProperty('ossrhPassword')) {
ossrhPassword = ''
}
}
def projectPom = {
name = 'time'
packaging = 'pom'
// optionally artifactId can be defined here
description = 'Java library dealing with date and time values without creating objects to be suitable for zero garbage applications'
url = 'https://github.com/tools4j/time'
scm {
connection = 'scm:git:https://github.com/tools4j/time.git'
developerConnection = 'scm:git:https://github.com/tools4j/time.git'
url = 'https://github.com/tools4j/time.git'
}
licenses {
license {
name = 'The MIT License (MIT)'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'terzerm'
name = 'Marco Terzer'
email = 'terzerm@gmail.com'
url = 'https://github.com/terzerm'
}
}
}
jar.enabled = false
allprojects {
repositories {
mavenCentral()
mavenLocal()
}
}
apply plugin: 'java-library'
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'biz.aQute.bnd.builder'
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
}
group = projGroup
version = projVersion
tasks.withType(Sign).configureEach {
onlyIf {
isReleaseVersion && gradle.taskGraph.hasTask(tasks.publish)
}
}
tasks.withType(Jar).configureEach {
enabled = true
includeEmptyDirs = false
}
tasks.withType(JavaCompile).configureEach {
if (JavaVersion.current().isJava9Compatible()) {
options.compilerArgs.addAll(['--add-exports', 'java.base/java.time.zone=ALL-UNNAMED'])
}
options.encoding = 'UTF-8'
options.deprecation = true
}
test {
useJUnitPlatform()
enableAssertions = true
jvmArgs('-Ddisable.thread.safety=true')
jvmArgs('--add-opens', 'java.base/java.time.zone=ALL-UNNAMED')
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
reports.html.required = true
}
license {
header = file("${rootDir}/etc/LICENSE.template")
strictCheck = true
ext.year = Year.now().value
include "**/*.java"
mapping {
java='SLASHSTAR_STYLE'
}
}
compileJava.dependsOn licenseFormat
javadoc {
title = '<h1>time</h1>'
options.bottom = "<i>Copyright © 2020-" + Year.now().getValue() + " tools4j.org (Marco Terzer, Anton Anufriev). All Rights Reserved.</i>"
options.encoding = 'UTF-8'
options.docEncoding = 'UTF-8'
options.charSet = 'UTF-8'
if (JavaVersion.current().isJava10Compatible()) {
options.addBooleanOption 'html5', true
options.links("https://docs.oracle.com/en/java/javase/${buildJavaVersion}/docs/api/") }
}
task testJar(type: Jar, dependsOn: testClasses) {
archiveClassifier.set "test-${base.archivesName}"
from sourceSets.test.output
}
configurations {
tests
}
artifacts {
tests testJar
}
jar {
bundle {
// workaround for https://github.com/bndtools/bnd/issues/6346
properties.put("project.group", provider({project.group}))
bnd """
Automatic-Module-Name: org.tools4j.time
Bundle-Name: org.tools4j.time
Bundle-SymbolicName: org.tools4j.time
Implementation-Title: time
Implementation-Vendor: tools4j.org
Implementation-Version: ${projVersion}
-exportcontents: org.tools4j.time, org.tools4j.time.*
# Suppress headers that reduce reproducibility.
-reproducible: true
-noextraheaders: true
"""
}
}
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications {
timeRegion(MavenPublication) {
from components.java
pom(projectPom)
}
}
repositories {
maven {
url = !isReleaseVersion ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}
signing {
sign publishing.publications.timeRegion
}