-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.gradle.kts
203 lines (172 loc) · 7.22 KB
/
build.gradle.kts
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
import com.jfrog.bintray.gradle.BintrayExtension.PackageConfig
import org.jfrog.gradle.plugin.artifactory.dsl.DoubleDelegateWrapper
import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask
// === PLUGINS =====================================================================================
plugins {
java
idea
signing
`maven-publish`
id("com.jfrog.bintray") version "1.8.5"
id("com.jfrog.artifactory") version "4.21.0"
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
// Using the lastest 5.3, I run into: https://issuetracker.google.com/issues/166468915
id("io.freefair.javadoc-links") version "5.1.1"
}
// === MAIN BUILD DETAILS ==========================================================================
group = "com.norswap"
version = "1.2.0"
description = "A parser combinator library"
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8
val website = "https://github.com/norswap/${project.name}"
val vcs = "https://github.com/norswap/${project.name}.git"
val generatedTestDir = "build/generated/sources/annotationProcessor/java/test"
sourceSets.main.get().java.srcDirs("src")
sourceSets.test.get().java.srcDirs("test", "examples", generatedTestDir)
java {
withSourcesJar()
withJavadocJar()
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.test.get().useTestNG()
tasks.javadoc.get().options {
// https://github.com/gradle/gradle/issues/7038
this as StandardJavadocDocletOptions
addStringOption("Xdoclint:none", "-quiet")
if (JavaVersion.current().isJava9Compatible)
addBooleanOption("html5", true) // nice future proofing
// Normally we would use `links = listOf(...)` here, but it doesn't work with javadoc.io.
// Instead, we use the io.freefair.javadoc-links plugin.
}
// === IDE =========================================================================================
idea.module {
// Download javadoc & sources for dependencies.
isDownloadJavadoc = true
isDownloadSources = true
}
// === PUBLISHING ==================================================================================
// Publication definition
publishing.publications.create<MavenPublication>(project.name) {
from(components["java"])
pom.withXml {
val root = asNode()
root.appendNode("name", project.name)
root.appendNode("description", project.description)
root.appendNode("url", website)
root.appendNode("scm").apply {
appendNode("url", website)
val connection = "scm:git:[email protected]:norswap/${project.name}.git"
appendNode("connection", connection)
appendNode("developerConnection", connection)
}
root.appendNode("licenses").appendNode("license").apply {
appendNode("name", "The BSD 3-Clause License")
appendNode("url", "$website/blob/master/LICENSE")
}
root.appendNode("developers").appendNode("developer").apply {
appendNode("id", "norswap")
appendNode("name", "Nicolas Laurent")
}
}
}
signing {
// Create a 'gradle.properties' file at the root of the project, containing the next two lines,
// replacing the values as needed:
// signing.gnupg.keyName=<KEY_ID>
// signing.gnupg.passphrase=<PASSWORD_WITHOUT_QUOTES>
// You'll need to have GnuPG installed, and it should be aliased to "gpg2"
// (homebrew on mac links it to only "gpg" by default).
// You are forced to use the agent, because otherwise Gradle wants a private keyring, which
// gnupg doesn't create by default since version 2.x.y. An alternative is to export the
// private keys to a keyring file.
useGpgCmd()
sign(publishing.publications[project.name])
}
// Use `gradle bintrayUpload` target to deploy to Bintray.
bintray {
user = System.getenv("BINTRAY_USER")
key = System.getenv("BINTRAY_KEY")
publish = true
override = true // enables overriding versions
pkg(closureOf<PackageConfig> {
repo = "maven"
name = project.name
vcsUrl = vcs
desc = project.description
// https://youtrack.jetbrains.com/issue/KT-33879
setLicenses("BSD 3-Clause")
setPublications(project.name)
})
}
// Use `gradle artifactoryPublish` target to deploy to Artifactory.
artifactory {
setContextUrl("https://norswap.jfrog.io/artifactory")
publish(closureOf<PublisherConfig> {
setContextUrl("https://norswap.jfrog.io/artifactory")
repository(closureOf<DoubleDelegateWrapper> {
invokeMethod("setRepoKey", project.name)
invokeMethod("setUsername", System.getenv("JFROG_USER"))
invokeMethod("setPassword", System.getenv("JFROG_KEY"))
})
defaultsClosure = closureOf<ArtifactoryTask> {
publications(project.name)
}
})
}
// DO NOT USE - Use the nexus plugin instead (see below).
// But this enables using `gradle publishAutumnPublicationToMavenCentralRepository` to deploy to
// Maven Central. However, further steps are required on https://oss.sonatype.org/ to actually
// publish the repository.
publishing.repositories.maven { // publishing to maven central
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
authentication {
// Create a 'gradle.properties' file at the root of the project, containing the next two
// lines, replacing the values as needed:
// mavenCentralUsername=<USERNAME>
// mavenCentralPassword=<PASSWORD>
name = "mavenCentral"
credentials(PasswordCredentials::class)
}
}
// Use `gradle publishToSonatype closeAndReleaseSonatypeStagingDirectory` to deploy to Maven Central.
nexusPublishing {
repositories {
sonatype {
// Create a 'gradle.properties' file at the root of the project, containing the next two
// lines, replacing the values as needed:
// mavenCentralUsername=<USERNAME>
// mavenCentralPassword=<PASSWORD>
username.set(property("mavenCentralUsername") as String)
password.set(property("mavenCentralPassword") as String)
}
}
}
// Deploy to all locations.
tasks.register("deploy") {
dependsOn("bintrayUpload")
dependsOn("artifactoryPublish")
// NOTE: must be changed if we only want to publish a single publications.
val publishToSonatype = tasks["publishToSonatype"]
val closeAndReleaseSonatype = tasks["closeAndReleaseSonatypeStagingRepository"]
dependsOn(publishToSonatype)
dependsOn(closeAndReleaseSonatype)
closeAndReleaseSonatype.mustRunAfter(publishToSonatype)
}
// === DEPENDENCIES ================================================================================
repositories {
mavenCentral()
maven {
url = uri("https://norswap.jfrog.io/artifactory/maven")
}
}
dependencies {
implementation("com.norswap:utils:2.1.8")
testImplementation("org.testng:testng:6.14.3")
testCompileOnly("com.google.auto.value:auto-value-annotations:1.6.2")
testAnnotationProcessor("com.google.auto.value:auto-value:1.6.2")
}
// =================================================================================================