Skip to content

Commit ef2d35b

Browse files
committed
Add maven central uploading; upgrade deps
1 parent 39e4cb9 commit ef2d35b

File tree

3 files changed

+138
-78
lines changed

3 files changed

+138
-78
lines changed

build.gradle

Lines changed: 132 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,22 @@ buildscript {
2424
dependencies {
2525
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2626
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
27+
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_version"
28+
classpath "net.researchgate:gradle-release:$gradle_release_version"
2729
}
2830
}
2931

3032
plugins {
31-
id "com.jfrog.bintray" version "1.8.0"
32-
id 'net.researchgate.release' version "2.6.0"
33-
id 'org.jmailen.kotlinter' version '1.7.0'
33+
id 'org.jmailen.kotlinter' version '1.9.0'
3434
}
3535

36+
apply plugin: 'net.researchgate.release'
3637
apply plugin: 'maven'
3738
apply plugin: 'kotlin'
3839
apply plugin: 'java'
3940
apply plugin: 'org.jetbrains.dokka'
41+
apply plugin: 'signing'
42+
apply plugin: 'com.jfrog.bintray'
4043
apply plugin: 'maven-publish'
4144
apply plugin: 'jacoco'
4245

@@ -45,14 +48,16 @@ description = 'Concise, easy, powerful and robust command line argument parsing
4548

4649
group 'com.xenomachina'
4750
project.ext {
48-
githubRepo = "xenomachina/$name"
51+
githubUser = "xenomachina"
52+
vcsDev = "https://github.com/$githubUser"
53+
githubRepo = "$githubUser/$name"
4954
vcsUrl = "https://github.com/$githubRepo"
5055
}
5156

5257
sourceCompatibility = 1.6
5358

5459
repositories {
55-
jcenter()
60+
mavenCentral()
5661
}
5762

5863
dependencies {
@@ -105,91 +110,144 @@ task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
105110
from javadoc.destinationDir
106111
}
107112

108-
//////////////////////////////////////////////////////////////////////////////
109-
// bintrayUpload config
110-
//////////////////////////////////////////////////////////////////////////////
111-
112-
// Based on https://github.com/bintray/gradle-bintray-plugin
113-
bintray {
114-
user = System.getenv('BINTRAY_USER')
115-
key = System.getenv('BINTRAY_KEY')
116-
117-
pkg {
118-
repo = 'maven'
119-
name = project.name
120-
desc = project.description
121-
122-
licenses = ['LGPL-2.1']
123-
vcsUrl = "$project.ext.vcsUrl"
124-
websiteUrl = "$project.ext.vcsUrl"
125-
issueTrackerUrl = "$project.ext.vcsUrl/issues"
126-
githubRepo = project.ext.githubRepo
127-
githubReleaseNotesFile = 'CHANGELOG.md'
128-
129-
version {
130-
name = project.version
131-
desc = "$project.name version $project.version"
132-
released = new Date()
133-
vcsTag = "$project.version"
134-
}
135-
}
113+
task sourcesJar(type: Jar, dependsOn: classes) {
114+
classifier = 'sources'
115+
from sourceSets.main.allSource
116+
}
136117

137-
publications = ['MyPublication']
118+
artifacts {
119+
archives javadocJar, sourcesJar
138120
}
139121

140-
// Create the pom configuration:
141-
def pomConfig = {
142-
licenses {
143-
license {
144-
name "GNU Lesser General Public License, Version 2.1"
145-
url "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt"
146-
distribution "repo"
122+
if (System.env.CI != "true") {
123+
// Some of the stuff in here can break continuous integration, and none of
124+
// it is necessary in CI.
125+
126+
//////////////////////////////////////////////////////////////////////////////
127+
// POM config
128+
//////////////////////////////////////////////////////////////////////////////
129+
130+
def pomConfig = {
131+
packaging 'jar'
132+
133+
name project.name
134+
description project.description
135+
url project.ext.vcsUrl
136+
137+
scm {
138+
connection "scm:git:$project.ext.vcsUrl"
139+
developerConnection "scm:git:$project.ext.vcsDev"
140+
url "$project.ext.vcsUrl"
141+
}
142+
143+
licenses {
144+
license {
145+
name "GNU Lesser General Public License, Version 2.1"
146+
url "https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt"
147+
distribution "repo"
148+
}
149+
}
150+
151+
developers {
152+
developer {
153+
id "xenomachina"
154+
name "Laurence Gonsalves"
155+
156+
// State-of-the art anti-scraper encryption. ;-)
157+
email "moc.anihcamonex@ecnerual".reverse()
158+
}
147159
}
148160
}
149-
developers {
150-
developer {
151-
id "xenomachina"
152-
name "Laurence Gonsalves"
153161

154-
// State-of-the art anti-scraper encryption. ;-)
155-
email "moc.anihcamonex@ecnerual".reverse()
162+
//////////////////////////////////////////////////////////////////////////////
163+
// Maven Central upload
164+
//////////////////////////////////////////////////////////////////////////////
165+
166+
signing {
167+
useGpgCmd()
168+
sign configurations.archives
169+
}
170+
171+
def ossrhUsernameOrEmpty = hasProperty('ossrhUsername') ? ossrhUsername : ''
172+
def ossrhPasswordOrEmpty = hasProperty('ossrhPassword') ? ossrhPassword : ''
173+
174+
uploadArchives {
175+
repositories {
176+
mavenDeployer {
177+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
178+
179+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
180+
authentication(userName: ossrhUsernameOrEmpty, password: ossrhPasswordOrEmpty)
181+
}
182+
183+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
184+
authentication(userName: ossrhUsernameOrEmpty, password: ossrhPasswordOrEmpty)
185+
}
186+
187+
pom.project pomConfig
188+
}
156189
}
157190
}
158-
}
159191

160-
task sourcesJar(type: Jar, dependsOn: classes) {
161-
classifier = 'sources'
162-
from sourceSets.main.allSource
163-
}
192+
//////////////////////////////////////////////////////////////////////////////
193+
// bintray upload
194+
//////////////////////////////////////////////////////////////////////////////
195+
196+
// Based on https://github.com/bintray/gradle-bintray-plugin
197+
bintray {
198+
user = System.getenv('BINTRAY_USER')
199+
key = System.getenv('BINTRAY_KEY')
200+
201+
pkg {
202+
repo = 'maven'
203+
name = project.name
204+
desc = project.description
205+
206+
licenses = ['LGPL-2.1']
207+
vcsUrl = "$project.ext.vcsUrl"
208+
websiteUrl = "$project.ext.vcsUrl"
209+
issueTrackerUrl = "$project.ext.vcsUrl/issues"
210+
githubRepo = project.ext.githubRepo
211+
githubReleaseNotesFile = 'CHANGELOG.md'
212+
213+
version {
214+
name = project.version
215+
desc = "$project.name version $project.version"
216+
released = new Date()
217+
vcsTag = "$project.version"
218+
}
219+
}
220+
221+
publications = ['MyPublication']
222+
}
164223

165-
// Create the publication with the pom configuration:
166-
publishing {
167-
publications {
168-
MyPublication(MavenPublication) {
169-
from components.java
170-
artifact sourcesJar
171-
artifact javadocJar
172-
// We use default groupId, artifactId, and version
173-
174-
pom.withXml {
175-
def root = asNode()
176-
root.appendNode('description', project.description)
177-
root.appendNode('name', project.name)
178-
root.appendNode('url', project.ext.vcsUrl)
179-
root.children().last() + pomConfig
224+
// Create the publication with the pom configuration:
225+
publishing {
226+
publications {
227+
MyPublication(MavenPublication) {
228+
from components.java
229+
artifact sourcesJar
230+
artifact javadocJar
231+
232+
pom.withXml {
233+
def root = asNode()
234+
root.children().last() + pomConfig
235+
}
180236
}
181237
}
182238
}
183-
}
184239

185-
//////////////////////////////////////////////////////////////////////////////
186-
// gradle-release plugin config
187-
//////////////////////////////////////////////////////////////////////////////
240+
///////////////////////////////////////////////////////////////////////////
241+
// gradle-release plugin config
242+
///////////////////////////////////////////////////////////////////////////
188243

189-
// Based on https://github.com/researchgate/gradle-release
244+
// Based on https://github.com/researchgate/gradle-release
190245

191-
// This causes './gradlew release' to also upload release package to bintray.
192-
afterReleaseBuild.dependsOn bintrayUpload
246+
// This causes './gradlew release' to also upload release packages to maven
247+
// central and bintray
248+
afterReleaseBuild.dependsOn bintrayUpload
249+
bintrayUpload.dependsOn uploadArchives
250+
}
193251

194252
//////////////////////////////////////////////////////////////////////////////
195253
// jacoco (codecov.io) plugin config

gradle.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
version=2.0.5-SNAPSHOT
22

33
# Dependency versions
4-
dokka_version = 0.9.15
4+
dokka_version = 0.9.16
5+
gradle_bintray_version = 1.8.0
6+
gradle_release_version = 2.6.0
57
kotlintest_version = 2.0.7
6-
kotlin_version = 1.2.20
8+
kotlin_version = 1.2.30
79
xenocom_version = 0.0.6
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-bin.zip
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
4-
zipStorePath=wrapper/dists
53
zipStoreBase=GRADLE_USER_HOME
4+
zipStorePath=wrapper/dists
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip

0 commit comments

Comments
 (0)