-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle
272 lines (240 loc) · 8.86 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
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'net.sourceforge.fmpp:fmpp:0.9.14'
}
}
plugins {
id "me.champeau.gradle.jmh" version "0.5.3"
id "com.github.hierynomus.license" version"0.15.0"
id 'io.codearte.nexus-staging' version '0.21.1'
id 'io.freefair.javadoc-links' version '4.1.6'
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'me.champeau.gradle.jmh'
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'io.freefair.javadoc-links'
sourceCompatibility = 1.8
group = "org.decimal4j"
version = '1.0.7-SNAPSHOT'
archivesBaseName = "decimal4j"
def versionJunit = '4.13.2'
def versionJunitParams = '1.1.1'
def versionJmh = '1.11.2'
def generatedSources = 'build/generated-src'
def generatedResources = 'build/generated-res'
sourceSets.main.java {
srcDirs += generatedSources
}
sourceSets.main.resources {
srcDirs += generatedResources
}
jar {
manifest.attributes(
'Implementation-Title': 'decimal4j',
'Implementation-Version': "${version}",
'Implementation-Vendor': 'tools4j.org',
'Automatic-Module-Name': 'org.decimal4j',
'Bundle-Name': 'org.decimal4j',
'Bundle-SymbolicName': 'org.decimal4j'
)
}
repositories {
mavenCentral()
}
dependencies {
// //NOTE: only needed for IDEs like eclipse to compile the jmh benchmarks
// // gradle is happy with jmh dependencies added by the jmh plugin
// compile "org.openjdk.jmh:jmh-core:${versionJmh}"
testImplementation 'junit:junit:' + versionJunit
testImplementation 'pl.pragmatists:JUnitParams:' + versionJunitParams
}
test {
//supported system properties for test sets:
//
//-DtestVariant=TINY,SMALL,STANDARD,ALL
//-DtestCases=TINY,SMALL,STANDARD,ALL
//-DtestScales=TINY,SMALL,STANDARD,ALL
systemProperties = System.getProperties()
testLogging {
exceptionFormat = 'full'
}
}
jacocoTestReport {
reports {
xml.enabled = true
}
}
uploadArchives {
repositories {
flatDir {
dirs 'build/repositories'
}
}
}
task generateSources {
mustRunAfter init
doLast {
println "Generating sources...."
ant.taskdef(name: 'fmpp', classname:'fmpp.tools.AntTask', classpath: buildscript.configurations.classpath.asPath)
ant.fmpp(
configuration: "src/main/resources/codegen/config.fmpp",
sourceRoot: "src/main/resources/codegen/templates",
outputRoot: generatedSources
)
new File(generatedSources).eachFileRecurse {
println it
}
println "Generating sources complete."
}
}
task copyLicense(type: Copy) {
from('.')
into(generatedResources +'/LICENSE.txt')
include('LICENSE.md')
rename('LICENSE.md', 'LICENSE.txt')
}
task copyLicenseToSrc(type: Copy) {
from(generatedResources)
into(generatedSources + '/LICENSE.txt')
include('LICENSE.txt')
}
license {
header rootProject.file('src/main/resources/LICENSE.template')
strictCheck true
include "**/*.java"
ext.year = Year.now().value
mapping {
java='SLASHSTAR_STYLE'
}
}
task licenseFormatGen(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {
source = generatedSources
outputs.upToDateWhen { false }
}
copyLicense.dependsOn 'processResources'
copyLicenseToSrc.dependsOn 'copyLicense','generateSources'
licenseFormatGen.dependsOn 'generateSources'
compileJava.dependsOn 'generateSources','licenseFormatMain','licenseFormatGen','licenseFormatJmh','licenseFormatTest','copyLicense','copyLicenseToSrc'
compileTestJava.dependsOn 'licenseFormatTest'
javadoc {
options.showFromPackage()
options.linkSource()
options.windowTitle = "decimal4j API ${version}"
options.overview = "src/main/java/overview.html";
}
java {
withSourcesJar()
withJavadocJar()
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
jmh {
jmhVersion = versionJmh
include = '.*Benchmark.*' // include pattern (regular expression) for benchmarks to be executed
// include = '.*AddBenchmark.*' // include pattern (regular expression) for benchmarks to be executed
// exclude = '.*CheckedBenchmark.*,.*PowBenchmark.*' // exclude pattern (regular expression) for benchmarks to be executed
// exclude = '.*PowBenchmark.*' // exclude pattern (regular expression) for benchmarks to be executed
benchmarkMode = ['thrpt'] // Benchmark mode. Available modes are: [Throughput/thrpt, AverageTime/avgt, SampleTime/sample, SingleShotTime/ss, All/all]
iterations = 3 // Number of measurement iterations to do.
timeOnIteration = '1000ms' // Time to spend at each measurement iteration.
batchSize = 1 // Batch size: number of benchmark method calls per operation. (some benchmark modes can ignore this setting)
fork = 1 // How many times to forks a single benchmark. Use 0 to disable forking altogether
failOnError = false // Should JMH fail immediately if any benchmark had experienced the unrecoverable error?
forceGC = true // Should JMH force GC between iterations?
// jvm = 'myjvm' // Custom JVM to use when forking.
// jvmArgs = 'Custom JVM args to use when forking.'
// jvmArgsAppend = 'Custom JVM args to use when forking (append these)'
// jvmArgsPrepend = 'Custom JVM args to use when forking (prepend these)'
humanOutputFile = project.file("${project.buildDir}/reports/jmh/human.txt") // human-readable output file
resultsFile = project.file("${project.buildDir}/reports/jmh/results.csv") // results file
// operationsPerInvocation = 10 // Operations per invocation.
// benchmarkParameters = [:] // Benchmark parameters.
// profilers = [] // Use profilers to collect additional data.
resultFormat = 'CSV' // Result format type (one of CSV, JSON, NONE, SCSV, TEXT)
// synchronizeIterations = true // Synchronize iterations?
// threads = 1 // Number of worker threads to run with.
// threadGroups = [2,3,4] //Override thread group distribution for asymmetric benchmarks.
timeUnit = 'us' // Output time unit. Available time units are: [m, s, ms, us, ns].
verbosity = 'NORMAL' // Verbosity mode. Available modes are: [SILENT, NORMAL, EXTRA]
warmup = '1000ms' // Time to spend at each warmup iteration.
// warmupBatchSize = 10 // Warmup batch size: number of benchmark method calls per operation.
// warmupForks = 0 // How many warmup forks to make for a single benchmark. 0 to disable warmup forks.
warmupIterations = 3 // Number of warmup iterations to do.
// warmupMode = 'INDI' // Warmup mode for warming up selected benchmarks. Warmup modes are: [INDI, BULK, BULK_INDI].
// warmupBenchmarks = ['.*Warmup'] // Warmup benchmarks to include in the run in addition to already selected. JMH will not measure these benchmarks, but only use them for the warmup.
// zip64 = true // Use ZIP64 format for bigger archives
}
//snapshot first, then release:
//gradle clean uploadArchives -Pupload -DossrhUsername=xxx -DossrhPassword=xxx
if (project.hasProperty('upload')) {
allprojects {
apply plugin: 'signing'
apply plugin: 'maven'
apply plugin: 'io.codearte.nexus-staging'
// Signature of artifacts
signing {
sign configurations.archives
}
// OSSRH publication
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'decimal4j'
packaging 'jar'
// optionally artifactId can be defined here
description 'Java library for fast fixed-point arithmetic based on longs with support for up to 18 decimal places.'
url 'http://decimal4j.org'
scm {
connection 'scm:git:git@github.com:tools4j/decimal4j.git'
developerConnection 'scm:git:git@github.com:tools4j/decimal4j.git'
url 'git@github.com:tools4j/decimal4j.git'
}
licenses {
license {
name 'MIT License'
url 'http://opensource.org/licenses/MIT'
}
}
developers {
developer {
id 'terzerm'
name 'Marco Terzer'
}
developer {
id 'majerv'
name 'Viktor Majer'
}
}
}
// remove jmh scope dependencies showing as compile time dependency
pom.whenConfigured { pom ->
pom.dependencies = pom.dependencies.findAll { dep -> dep.groupId != 'org.openjdk.jmh' }
}
}
}
}
nexusStaging {
username = ossrhUsername
password = ossrhPassword
}
}
}