forked from vavr-io/vavr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
192 lines (168 loc) · 5.31 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
/*
* 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`
*/
plugins {
id "net.researchgate.release" version "2.8.1"
}
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'maven'
apply plugin: 'signing'
ext.ammoniteScalaVersion = '2.13' // Currently, generator/Generator.sc does not build with Scala 2.13
ext.ammoniteVersion = '2.0.4'
ext.assertjVersion = '3.15.0'
ext.junitVersion = '4.13'
repositories {
mavenLocal()
mavenCentral()
}
sourceSets {
main {
java {
srcDirs = ['src/main/java', 'src-gen/main/java']
}
}
test {
java {
srcDirs = ['src/test/java', '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 {
main = "-jar"
args = [ammoniteJar, "generator/Generator.sc"]
}
}
}
compileJava.dependsOn 'generateSources'
tasks.withType(JavaCompile) {
sourceCompatibility = 8
targetCompatibility = 8
options.encoding = 'UTF-8'
options.compilerArgs = [ '-Werror', '-Xlint:all', '-Xlint:-deprecation' ]
}
dependencies {
testImplementation "junit:junit:$junitVersion"
testImplementation "org.assertj:assertj-core:$assertjVersion"
}
jacocoTestReport {
reports {
xml.enabled = true
}
}
check {
dependsOn jacocoTestReport
dependsOn javadoc
}
jar {
manifest {
attributes('Automatic-Module-Name': 'io.vavr')
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveClassifier = 'sources'
}
task testSourcesJar(type: Jar) {
from sourceSets.test.allSource
archiveClassifier = 'test-sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
artifacts {
archives javadocJar, sourcesJar, testSourcesJar
}
// Requirements:
//
// - 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
//
signing {
required { !version.endsWith("-SNAPSHOT") }
sign configurations.archives
}
// Requirements:
//
// - Add the following properties to ~/.gradle/gradle.properties
// ossrhUsername=<username>
// ossrhPassword=<password>
// - Or pass the credentials as command line parameters
// ./gradlew uploadArchives -PossrhUsername=<my-username> -PossrhPassword=<my-password>
//
uploadArchives {
repositories {
mavenDeployer {
def sonatypeUser = findProperty("ossrhUsername")
def sonatypePass = findProperty("ossrhPassword")
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUser, password: sonatypePass)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: sonatypeUser, password: sonatypePass)
}
// Generate Sonatype conform .pom for Bintray Maven-sync, see https://central.sonatype.org/pages/requirements.html
pom.project {
name = project.name
description = "Vavr is an object-functional library for Java 8+"
url = 'https://www.vavr.io'
inceptionYear '2014'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
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'
}
}
}
}
}
release {
buildTasks = ['build']
tagTemplate = '$name-$version'
git {
requireBranch = ''
pushToRemote = 'origin'
pushToCurrentBranch = true
}
}
afterReleaseBuild.dependsOn uploadArchives