Skip to content

Commit 64fbd09

Browse files
committed
Bumped JScriptBox to the publish-and-sync-on-push build.gradle.
1 parent 7aff4be commit 64fbd09

File tree

1 file changed

+50
-16
lines changed

1 file changed

+50
-16
lines changed

build.gradle

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
plugins {
22
// code formatting
33
id "com.diffplug.gradle.spotless" version "1.2.0"
4+
// bintray upload
5+
id "com.jfrog.bintray" version "1.3.1"
46
}
57

68
repositories {
79
mavenCentral()
810
// SNAPSHOT versions are free to rely on other SNAPSHOT libraries
911
if (project.version.endsWith('-SNAPSHOT')) {
10-
maven {
11-
url 'https://oss.sonatype.org/content/repositories/snapshots/'
12-
}
13-
configurations.all {
14-
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
15-
}
12+
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
13+
configurations.all { resolutionStrategy.cacheChangingModulesFor 0, 'seconds' }
1614
}
1715
}
1816

@@ -121,6 +119,21 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
121119
from javadoc.destinationDir
122120
}
123121

122+
////////////////
123+
// PUBLISHING //
124+
////////////////
125+
def isSnapshot = project.version.endsWith('-SNAPSHOT')
126+
// pulls the credentials from either the environment variable or gradle.properties
127+
def cred = {
128+
if (System.env[it] != null) {
129+
return System.env[it]
130+
} else if (project[it] != null) {
131+
return project[it]
132+
} else {
133+
return 'unknown_' + it
134+
}
135+
}
136+
124137
publishing {
125138
publications {
126139
mavenJava(MavenPublication) {
@@ -159,20 +172,41 @@ publishing {
159172
}
160173
}
161174
}
162-
repositories {
163-
maven {
164-
def isSnapshot = project.version.endsWith('-SNAPSHOT')
165-
if (isSnapshot) {
166-
url = 'https://oss.sonatype.org/content/repositories/snapshots'
167-
} else {
168-
url = "https://api.bintray.com/maven/diffplug/opensource/${project.name}"
169-
}
175+
if (isSnapshot) {
176+
// upload snapshots to oss.sonatype.org
177+
repositories { maven {
178+
url = 'https://oss.sonatype.org/content/repositories/snapshots'
170179
credentials {
171-
username = System.env[isSnapshot ? 'nexus_user' : 'bintray_user']
172-
password = System.env[isSnapshot ? 'nexus_pass' : 'bintray_pass']
180+
username = cred('nexus_user')
181+
password = cred('nexus_pass')
182+
}
183+
} }
184+
}
185+
}
186+
187+
if (!isSnapshot) {
188+
// upload releases to bintray and then mavenCentral
189+
bintray {
190+
user = cred('bintray_user')
191+
key = cred('bintray_pass')
192+
publications = ['mavenJava']
193+
publish = true
194+
pkg {
195+
repo = 'opensource'
196+
name = project.name
197+
userOrg = project.org
198+
version {
199+
name = project.version
200+
mavenCentralSync {
201+
user = cred('nexus_user')
202+
password = cred('nexus_pass')
203+
}
173204
}
174205
}
175206
}
207+
208+
publish.dependsOn(bintrayUpload)
209+
bintrayUpload.dependsOn(['generatePomFileForMavenJavaPublication', jar, sourcesJar, javadocJar])
176210
}
177211

178212
// helps external scripts detect version

0 commit comments

Comments
 (0)