@@ -5,7 +5,7 @@ import org.labkey.gradle.util.PomFileHelper
55
66buildscript {
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
3939repositories {
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-
6157group " org.labkey.api"
6258
6359version " 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
143139project. 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
150145project. artifacts {
@@ -155,125 +150,112 @@ project.artifacts {
155150
156151def 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
0 commit comments