Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
262 lines (232 sloc) 8.85 KB
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'net.sourceforge.fmpp:fmpp:0.9.14'
}
}
plugins {
id "me.champeau.gradle.jmh" version "0.2.0"
id "com.github.hierynomus.license-base" 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-base'
apply plugin: 'io.freefair.javadoc-links'
sourceCompatibility = 1.7
group = "org.decimal4j"
version = '1.0.7-SNAPSHOT'
archivesBaseName = "decimal4j"
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
exclude '**/*.template'
exclude '**/codegen/**'
}
jar {
manifest.attributes(
'Implementation-Title': 'decimal4j',
'Implementation-Version': "${project.version}",
'Implementation-Vendor': 'tools4j',
'Automatic-Module-Name': '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:4.11'
testImplementation 'pl.pragmatists:JUnitParams:1.0.4'
}
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'
}
}
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 = Calendar.getInstance().get(Calendar.YEAR)
}
task licenseFormatGen(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {
source = generatedSources
outputs.upToDateWhen { false }
}
licenseFormatGen.dependsOn 'generateSources'
licenseFormatMain.dependsOn 'generateSources','licenseFormatGen','licenseFormatJmh','licenseFormatTest'
copyLicense.dependsOn 'processResources'
copyLicenseToSrc.dependsOn 'copyLicense','generateSources'
//compileJava.dependsOn 'generateSources','licenseFormat','licenseFormatGen','copyLicense','copyLicenseToSrc'
compileJava.dependsOn 'generateSources','licenseFormatMain','licenseFormatGen','copyLicense','copyLicenseToSrc'
compileTestJava.dependsOn 'licenseFormatTest'
javadoc {
options.showFromPackage()
options.linkSource()
options.windowTitle = "decimal4j API ${project.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
}
}
}
You can’t perform that action at this time.