Skip to content

Commit 526ea13

Browse files
Replace use of bintray publishing with publishing to sonatype (#18)
1 parent a3e9b8b commit 526ea13

File tree

4 files changed

+110
-153
lines changed

4 files changed

+110
-153
lines changed

labkey-api-sas/build.gradle

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.labkey.gradle.plugin.extension.TeamCityExtension
55

66
buildscript {
77
repositories {
8-
jcenter()
8+
mavenCentral()
99
maven {
1010
url "${artifactory_contextUrl}/plugins-release"
1111
}
@@ -18,14 +18,6 @@ buildscript {
1818
}
1919
dependencies {
2020
classpath "org.labkey.build:gradlePlugins:${gradlePluginsVersion}"
21-
// N.B. We use the "old-fashioned" way of applying the artifactory plugin because if we use
22-
// the plugins block below and specify a version number, the following error happens if building
23-
// in conjunction with LabKey server (i.e., when including this project in the server's build.gradle
24-
// Error resolving plugin [id: 'com.jfrog.artifactory', version: '4.13.0', apply: false]
25-
// > Plugin request for plugin already on the classpath must not include a version
26-
// We could instead include the plugin without a version number, which would work until
27-
// some change in the latest version of the plugin came along that we aren't compatible with.
28-
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:${artifactoryPluginVersion}"
2921
}
3022
}
3123

@@ -52,9 +44,6 @@ repositories {
5244
}
5345
}
5446

55-
// TODO remove once client-api distribution no longer requires this
56-
buildDir = new File(project.rootProject.buildDir, "/remoteapi/sas")
57-
5847
group 'org.labkey.api'
5948

6049
version '1.0.0-SNAPSHOT'
@@ -71,7 +60,6 @@ configurations {
7160

7261
BuildUtils.addLabKeyDependency(project: project, config: "remoteApi", depProjectPath: BuildUtils.getRemoteApiProjectPath(gradle), depVersion: project.labkeyClientApiVersion)
7362

74-
// TODO change name and destination once client-api no longer requires this
7563
project.task("distribution",
7664
group: GroupNames.DISTRIBUTION,
7765
description: "Create a zip file for the SAS API client distribution containing the SAS macros, java client api jar and its dependencies",
@@ -88,7 +76,8 @@ artifacts {
8876
archives project.tasks.distribution
8977
}
9078

91-
project.afterEvaluate {
79+
if (hasProperty('artifactory_user') && hasProperty('artifactory_password'))
80+
{
9281
project.publishing {
9382
publications {
9483
libs(MavenPublication) {
@@ -109,35 +98,21 @@ project.afterEvaluate {
10998
}
11099
}
111100
}
112-
113-
if (project.hasProperty('doClientApiPublishing'))
114-
{
115-
apply plugin: 'com.jfrog.artifactory'
116-
artifactory {
117-
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
118-
publish {
119-
repository {
120-
repoKey = BuildUtils.getRepositoryKey(project)
121-
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password'))
122-
{
123-
username = artifactory_user
124-
password = artifactory_password
125-
}
126-
maven = true
127-
}
128-
defaults
129-
{
130-
publishPom = true
131-
publishIvy = false
132-
}
101+
repositories {
102+
maven {
103+
url project.version.contains("SNAPSHOT") ? "${artifactory_contextUrl}/libs-snapshot-local" : "${artifactory_contextUrl}/libs-release-local"
104+
credentials {
105+
username = artifactory_user
106+
password = artifactory_password
107+
}
108+
authentication {
109+
basic(BasicAuthentication)
110+
// enable preemptive authentication to get around https://www.jfrog.com/jira/browse/RTFACT-4434
133111
}
134-
}
135-
136-
project.artifactoryPublish {
137-
publications('libs')
138112
}
139113
}
140114
}
115+
141116
project.model {
142117
tasks.publishLibsPublicationToMavenLocal {
143118
enabled = false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

labkey-client-api/build.gradle

Lines changed: 94 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.labkey.gradle.util.PomFileHelper
55

66
buildscript {
77
repositories {
8-
jcenter()
8+
mavenCentral()
99
maven {
1010
url "${artifactory_contextUrl}/plugins-release"
1111
}
@@ -33,11 +33,10 @@ plugins {
3333
id 'java-library'
3434
id 'java'
3535
id 'maven-publish'
36-
id "com.jfrog.bintray" version "${bintrayPluginVersion}" apply false
36+
id 'signing'
3737
}
3838

3939
repositories {
40-
jcenter()
4140
maven {
4241
url "${artifactory_contextUrl}/libs-release"
4342

@@ -55,9 +54,6 @@ repositories {
5554
}
5655
}
5756

58-
// TODO remove this and use default once client-api distribution doesn't need it
59-
buildDir = new File(project.rootProject.buildDir, "/remoteapi/labkey-api-java")
60-
6157
group "org.labkey.api"
6258

6359
version "1.4.0-SNAPSHOT"
@@ -113,13 +109,13 @@ project.task("fatJar",
113109
Jar jar ->
114110
jar.from sourceSets.main.output
115111
jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
116-
jar.from { configurations.default.collect { it.isDirectory() ? it : zipTree(it) }}
112+
jar.from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }}
117113
jar.setArchiveVersion(project.version)
118-
jar.classifier LabKey.FAT_JAR_CLASSIFIER
114+
jar.archiveClassifier.set(LabKey.FAT_JAR_CLASSIFIER)
119115
jar.dependsOn project.tasks.jar
120116
jar.into('lib') {
121117
from tasks.jar
122-
from configurations.default
118+
from configurations.runtimeClasspath
123119
}
124120
}
125121
)
@@ -142,9 +138,8 @@ project.task('javadocJar', description: "Generate jar file of javadoc files", ty
142138

143139
project.task('sourcesJar', description: "Generate jar file of source files", type: Jar) {Jar jar ->
144140
jar.from project.sourceSets.main.allJava
145-
146141
jar.group GroupNames.DISTRIBUTION
147-
jar.classifier LabKey.SOURCES_CLASSIFIER
142+
jar.archiveClassifier.set(LabKey.SOURCES_CLASSIFIER)
148143
}
149144

150145
project.artifacts {
@@ -155,125 +150,112 @@ project.artifacts {
155150

156151
def libDescription = "The client-side library for Java developers is a separate JAR from the LabKey Server code base. It can be used by any Java program, including another Java web application."
157152

158-
project.afterEvaluate {
159-
project.publishing {
160-
publications {
161-
libs(MavenPublication) {
162-
groupId = project.group
163-
from components.java
164-
versionMapping {
165-
usage('java-api') {
166-
fromResolutionOf('runtimeClasspath')
167-
}
168-
usage('java-runtime') {
169-
fromResolutionResult()
170-
}
153+
project.publishing {
154+
publications {
155+
libs(MavenPublication) {
156+
groupId = project.group
157+
from components.java
158+
artifact(sourcesJar) {
159+
classifier = LabKey.SOURCES_CLASSIFIER
160+
}
161+
artifact(javadocJar) {
162+
classifier = LabKey.JAVADOC_CLASSIFIER
163+
}
164+
artifact(fatJar) {
165+
classifier = LabKey.FAT_JAR_CLASSIFIER
166+
}
167+
versionMapping {
168+
usage('java-api') {
169+
fromResolutionOf('runtimeClasspath')
171170
}
172-
pom {
173-
name = "LabKey Server Java Client API"
174-
description = libDescription
175-
url = PomFileHelper.LABKEY_ORG_URL
176-
developers PomFileHelper.getLabKeyTeamDevelopers()
177-
licenses PomFileHelper.getApacheLicense()
178-
organization PomFileHelper.getLabKeyOrganization()
179-
scm {
180-
connection = 'scm:git:https://github.com/LabKey/labkey-api-java'
181-
developerConnection = 'scm:git:https://github.com/LabKey/labkey-api-java'
182-
url = 'scm:git:https://github.com/LabKey/labkey-api-java/labkey-client-api'
183-
}
171+
usage('java-runtime') {
172+
fromResolutionResult()
184173
}
185-
186-
project.tasks.each {
187-
if (it instanceof Jar)
188-
{
189-
artifact it
190-
}
174+
}
175+
pom {
176+
name = "LabKey Server Java Client API"
177+
description = libDescription
178+
url = PomFileHelper.LABKEY_ORG_URL
179+
developers PomFileHelper.getLabKeyTeamDevelopers()
180+
licenses PomFileHelper.getApacheLicense()
181+
organization PomFileHelper.getLabKeyOrganization()
182+
scm {
183+
connection = 'scm:git:https://github.com/LabKey/labkey-api-java'
184+
developerConnection = 'scm:git:https://github.com/LabKey/labkey-api-java'
185+
url = 'scm:git:https://github.com/LabKey/labkey-api-java/labkey-client-api'
191186
}
192187
}
193188
}
194-
195-
if (project.hasProperty('doClientApiPublishing'))
189+
}
190+
repositories {
191+
if (project.hasProperty("sonatype_staging_url") && project.hasProperty("sonatype_username") && project.hasProperty("sonatype_password"))
196192
{
197-
apply plugin: 'com.jfrog.artifactory'
198-
artifactory {
199-
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
200-
publish {
201-
repository {
202-
repoKey = BuildUtils.getRepositoryKey(project)
203-
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password'))
204-
{
205-
username = artifactory_user
206-
password = artifactory_password
207-
}
208-
maven = true
209-
}
210-
defaults
211-
{
212-
publishPom = true
213-
publishIvy = false
214-
}
193+
maven {
194+
url sonatype_staging_url
195+
credentials {
196+
username sonatype_username
197+
password sonatype_password
215198
}
216199
}
200+
}
217201

218-
project.artifactoryPublish {
219-
project.tasks.each {
220-
if (it instanceof Jar)
221-
{
222-
dependsOn it
223-
}
202+
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password'))
203+
{
204+
maven {
205+
url project.version.contains("SNAPSHOT") ? "${artifactory_contextUrl}/libs-snapshot-local" : "${artifactory_contextUrl}/libs-release-local"
206+
credentials {
207+
username = artifactory_user
208+
password = artifactory_password
209+
}
210+
authentication {
211+
basic(BasicAuthentication)
212+
// enable preemptive authentication to get around https://www.jfrog.com/jira/browse/RTFACT-4434
224213
}
225-
publications('libs')
226214
}
227215
}
228-
229216
}
230-
project.model {
231-
tasks.publishLibsPublicationToMavenLocal {
232-
enabled = false
217+
apply plugin: 'com.jfrog.artifactory'
218+
artifactory {
219+
contextUrl = "${artifactory_contextUrl}"
220+
//The base Artifactory URL if not overridden by the publisher/resolver
221+
publish {
222+
repository {
223+
repoKey = BuildUtils.getRepositoryKey(project)
224+
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password'))
225+
{
226+
username = artifactory_user
227+
password = artifactory_password
228+
}
229+
maven = true
230+
}
231+
defaults {
232+
publishPom = true
233+
publishIvy = false
234+
}
233235
}
234236
}
235-
}
236-
237-
// This section is used for publishing the jar files to bintray and then on to maven central.
238-
if (project.hasProperty('bintray_user')
239-
&& project.hasProperty('bintray_api_key')
240-
&& project.hasProperty('gpg_passphrase')
241-
&& project.hasProperty('sonatype_username')
242-
&& project.hasProperty('sonatype_password'))
243-
{
244-
apply plugin: 'com.jfrog.bintray'
245-
bintray {
246-
user = project.bintray_user
247-
key = project.bintray_api_key
248-
publications = ['libs']
249-
publish = true
250-
pkg {
251-
repo = project.version.endsWith('SNAPSHOT') ? 'libs-snapshot' : 'libs-release'
252-
desc = libDescription
253-
websiteUrl = PomFileHelper.LABKEY_ORG_URL
254-
name = project.name
255-
userOrg = 'labkey'
256-
licenses = ['Apache-2.0']
257-
vcsUrl = 'https://github.com/LabKey/labkey-api-java'
258-
version {
259-
name = project.version
260-
desc = "LabKey Java Client API ${project.version}"
261-
released = new Date()
262-
gpg {
263-
sign = true
264-
passphrase = project.gpg_passphrase
265-
}
266237

267-
mavenCentralSync {
268-
sync = true //[Default: true] Determines whether to sync the version to Maven Central.
269-
user = project.sonatype_username //OSS user token: mandatory
270-
password = project.sonatype_password //OSS user password: mandatory
271-
close = '1'
272-
//Optional property. By default the staging repository is closed and artifacts are released to Maven Central.
273-
//You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
274-
}
238+
project.artifactoryPublish {
239+
project.tasks.each {
240+
if (it instanceof Jar)
241+
{
242+
dependsOn it
275243
}
276244
}
245+
publications('libs')
246+
}
247+
}
248+
249+
project.model {
250+
tasks.publishLibsPublicationToMavenLocal {
251+
enabled = false
252+
}
253+
}
254+
255+
if (project.hasProperty("signing.keyId") && project.hasProperty("signing.password") || project.hasProperty("signing.secretKeyRingFile"))
256+
{
257+
signing {
258+
sign publishing.publications.libs
277259
}
278260
}
279261

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)