-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
225 lines (186 loc) · 5.74 KB
/
build.gradle
File metadata and controls
225 lines (186 loc) · 5.74 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
222
223
224
225
import java.time.Year
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id 'idea'
id 'java-library'
id 'io.freefair.javadoc-links' version '6.5.1' apply false
id 'biz.aQute.bnd.builder' version '6.3.1' apply false
id 'com.github.hierynomus.license' version "0.16.1" apply false
}
defaultTasks 'clean', 'build'
def projGroup = 'org.tools4j'
def projVersion = file('version.txt').text.trim()
def junitVersion = '5.9.2'
def mockitoVersion = '4.11.0' //5.x requires Java 11
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 = 'shortstring'
packaging = 'pom'
// optionally artifactId can be defined here
description = 'Tiny library to convert short enough strings to integers and back'
url = 'https://github.com/tools4j/shortstring'
scm {
connection = 'scm:git:https://github.com/tools4j/shortstring.git'
developerConnection = 'scm:git:https://github.com/tools4j/shortstring.git'
url = 'https://github.com/tools4j/shortstring.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'
}
developer {
id = 'anton-anufriev'
name = 'Antun Anufriev'
email = 'anufriev@gmail.com'
url = 'https://github.com/anton-anufriev'
}
}
}
jar.enabled = false
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'
apply plugin: 'io.freefair.javadoc-links'
dependencies {
testImplementation "org.mockito:mockito-junit-jupiter:${mockitoVersion}"
testImplementation "org.mockito:mockito-inline:${mockitoVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
}
group = projGroup
version = projVersion
tasks.withType(Sign) {
onlyIf {
isReleaseVersion && gradle.taskGraph.hasTask(tasks.publish)
}
}
tasks.withType(Jar) {
enabled = true
includeEmptyDirs = false
}
tasks.withType(JavaCompile) {
if (JavaVersion.current().isJava9Compatible()) {
options.compilerArgs.addAll(['--add-exports', 'java.base/java.lang.reflect=ALL-UNNAMED'])
options.compilerArgs.addAll(['--add-exports', 'java.base/java.net=ALL-UNNAMED'])
options.compilerArgs.addAll(['--add-exports', 'java.base/sun.nio.ch=ALL-UNNAMED'])
options.compilerArgs.addAll(['--add-exports', 'java.base/jdk.internal.ref=ALL-UNNAMED'])
options.compilerArgs.addAll(['--add-exports', 'jdk.unsupported/sun.misc=ALL-UNNAMED'])
}
options.encoding = 'UTF-8'
options.deprecation = true
}
tasks.withType(Test) {
enableAssertions = true
useJUnitPlatform {
excludeTags 'perf'
}
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
reports.html.required = false // Disable individual test reports
}
license {
header rootProject.file('etc/LICENSE.template')
strictCheck true
include "**/*.java"
ext.year = Year.now().value
mapping {
java='SLASHSTAR_STYLE'
}
}
compileJava.dependsOn licenseFormat
javadoc {
title = '<h1>Short-string codecs library</h1>'
options.bottom = "<i>Copyright © 2023 tools4j.org (Marco Terzer). All Rights Reserved.</i>"
options.encoding = 'UTF-8'
options.docEncoding = 'UTF-8'
options.charSet = 'UTF-8'
if (JavaVersion.current().isJava10Compatible()) {
options.addBooleanOption 'html5', true
}
}
task testJar(type: Jar, dependsOn: testClasses) {
archiveClassifier.set "test-${project.archivesBaseName}"
from sourceSets.test.output
}
configurations {
tests
}
artifacts {
tests testJar
}
jar {
bnd """
Automatic-Module-Name: org.tools4j.shortstring
Bundle-Name: org.tools4j.shortstring
Bundle-SymbolicName: org.tools4j.shortstring
Implementation-Title: Shortstring
Implementation-Vendor: tools4j.org
Implementation-Version: ${projVersion}
-exportcontents: org.tools4j.shortstring
# Suppress headers that reduce reproducibility.
-reproducible: true
-noextraheaders: true
"""
}
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications {
shortstring(MavenPublication) {
from components.java
pom(projectPom)
}
}
repositories {
maven {
url = !isReleaseVersion ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}
signing {
sign publishing.publications.shortstring
}
tasks.register('testReport', TestReport) {
destinationDirectory = file("${buildDir}/reports/allTests")
// Include the results from the `test` task in all sub-projects
testResults.setFrom(subprojects*.test)
}