forked from vavr-io/vavr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
208 lines (184 loc) · 5.99 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
/*
* Some Gradle tasks we use:
*
* - Build: `./gradlew check`
* -> test reports: ./build/reports/tests/test/index.html
* -> coverage reports: ./build/reports/jacoco/test/html/index.html
* -> javadoc: `./build/docs/javadoc`
*
* - Release: `./gradlew release --info`
*
* - Release:
* -> checking the generated artifacts: `./gradlew publishAllPublicationsToTestRepo` then look into `build/repo`
* -> Releasing: `./gradlew release --info`
*
* In order to perform a release you need to:
* - Add the following properties to ~/.gradle/gradle.properties
* ossrhUsername=<username>
* ossrhPassword=<password>
* - or pass the credentials as command line parameters
* ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -DossrhUsername=<my-username> -DossrhPassword=<my-password>
*
* And for signing the artifacts:
* - Get public key ID `gpg --list-keys --keyid-format SHORT`
* - Export key `gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg`
* - Add the following properties to ~/.gradle/gradle.properties
* signing.keyId=0ABCDEF
* signing.password=password
* signing.secretKeyRingFile=/absolute/path/to/.gnupg/secring.gpg
*/
plugins {
// library
id 'java-library'
id 'jacoco'
// publishing
id 'maven-publish'
id 'signing'
id 'net.researchgate.release' version '2.8.1'
id 'io.github.gradle-nexus.publish-plugin' version '1.0.0'
}
ext.ammoniteScalaVersion = '2.13'
ext.ammoniteVersion = '2.3.8'
ext.assertjVersion = '3.19.0'
ext.junitVersion = '4.13.2'
// JAVA_VERSION used for CI build matrix, may be provided as env variable
def javaVersion = Integer.parseInt(System.getenv('JAVA_VERSION') ?: '8')
repositories {
mavenCentral()
}
// -- --
// -- JAVA BUILD & CODE GEN --
// -- --
dependencies {
testImplementation "junit:junit:$junitVersion"
testImplementation "org.assertj:assertj-core:$assertjVersion"
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
withSourcesJar()
withJavadocJar()
}
sourceSets.main.java.srcDirs += ['src-gen/main/java']
sourceSets.test.java.srcDirs += ['src-gen/test/java']
task generateSources() {
doLast {
delete 'src-gen'
def ammoniteDir = file("generator/bin")
if (!ammoniteDir.exists()) {
ammoniteDir.mkdirs()
}
def ammoniteJar = new File(ammoniteDir, "amm-${ammoniteScalaVersion}-${ammoniteVersion}.jar")
if (!ammoniteJar.exists()) {
def ammoniteReleaseUrl = "https://github.com/lihaoyi/Ammonite/releases/download/${ammoniteVersion}/${ammoniteScalaVersion}-${ammoniteVersion}"
ant.get(src: ammoniteReleaseUrl, dest: ammoniteJar)
}
javaexec {
classpath = project.files(ammoniteJar)
args = ["generator/Generator.sc"]
}
}
}
compileJava.dependsOn 'generateSources'
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs = [ '-Werror', '-Xlint:all', '-Xlint:-deprecation' ]
}
tasks.named('jacocoTestReport') {
reports {
xml.required = true
}
}
tasks.named('check') {
dependsOn jacocoTestReport
dependsOn javadoc
}
tasks.named('jar') {
from('.') {
include 'LICENSE'
}
manifest {
attributes('Automatic-Module-Name': 'io.vavr')
}
}
tasks.register('testSourcesJar', Jar) {
from sourceSets.test.allSource
archiveClassifier = 'test-sources'
}
// -- --
// -- PUBLISHING & RELEASING --
// -- --
// What we want to publish
publishing {
repositories {
maven {
// A test repository which can be used to
// verify what is going to be uploaded by
// running ./gradlew publishAllPublicationsToTestRepo
name = "testRepo"
url = "${buildDir}/repo"
}
}
publications {
maven(MavenPublication) {
from components.java
// vavr also publishes a test sources jar
artifact tasks.named('testSourcesJar')
pom {
name = project.name
description = "Vavr is an object-functional library for Java 8+"
url = 'https://www.vavr.io'
inceptionYear = '2014'
licenses {
license {
name = 'The MIT License (MIT)'
url = 'https://mit-license.org'
}
}
developers {
developer {
name = 'Daniel Dietrich'
email = '[email protected]'
organization = 'Vavr'
organizationUrl = 'https://github.com/vavr-io'
}
}
scm {
connection = 'scm:git:https://github.com/vavr-io/vavr.git'
developerConnection = 'scm:git:https://github.com/vavr-io/vavr.git'
url = 'https://github.com/vavr-io/vavr/tree/master'
}
}
}
}
}
// Signing configuration mandatory for Maven Central
signing {
required { !version.endsWith("-SNAPSHOT") }
publishing.publications.configureEach {
sign(it)
}
}
// Configure the publishing repositories for Maven Central
nexusPublishing {
repositories {
sonatype {
username.set(providers.systemProperty("ossrhUsername").orElse("").forUseAtConfigurationTime())
password.set(providers.systemProperty("ossrhPassword").orElse("").forUseAtConfigurationTime())
}
}
}
// Configure the "release" plugin
tasks.named('afterReleaseBuild') {
dependsOn "publishToSonatype", "closeAndReleaseSonatypeStagingRepository"
}
release {
buildTasks = ['build']
tagTemplate = '$name-$version'
git {
requireBranch = ''
pushToRemote = 'origin'
pushToCurrentBranch = true
}
}