Skip to content

Commit cfc8426

Browse files
committed
Remove use of deprecated maven plugin
SVN r65040 |2020-02-04 18:59:07 +0000
1 parent 81580ff commit cfc8426

File tree

1 file changed

+40
-62
lines changed

1 file changed

+40
-62
lines changed

java/build.gradle

Lines changed: 40 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
import org.labkey.gradle.plugin.LabKey
22
import org.labkey.gradle.util.BuildUtils
33
import org.labkey.gradle.util.GroupNames
4-
import org.labkey.gradle.task.PomFile
54

65
plugins {
76
id 'java-library'
87
id 'java'
9-
id 'maven' // TODO this has been deprecated
108
id 'maven-publish'
119
}
1210

13-
1411
buildDir = new File(project.rootProject.buildDir, "/remoteapi/java")
1512

1613
def artifactPrefix = 'labkey-client-api'
17-
def description = "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."
18-
def orgUrl = "http://www.labkey.org"
1914

2015
group "org.labkey.api"
2116
//Issue #39336 (comment 4): Updating to use SNAPSHOT until migration to git
@@ -54,6 +49,13 @@ project.tasks.withType(JavaCompile) {
5449
targetCompatibility = project.ext.targetCompatibility
5550
}
5651

52+
// The maven-publish plugin will, by default, publish a metadata file alongside the other
53+
// artifacts. Its extension is .module, which might get confused with our own .module files.
54+
// We could publish these files for everything but .module files, but for now we disable always
55+
// https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html
56+
project.tasks.withType(GenerateModuleMetadata) {
57+
enabled = false
58+
}
5759

5860
project.task("fatJar",
5961
description: "Generate single jar file containing the api and all its dependent classes",
@@ -62,6 +64,7 @@ project.task("fatJar",
6264
{
6365
Jar jar ->
6466
jar.from sourceSets.main.output
67+
jar.duplicatesStrategy = 'exclude'
6568
jar.from { configurations.default.collect { it.isDirectory() ? it : zipTree(it) }}
6669
jar.archiveBaseName.set(artifactPrefix)
6770
jar.setArchiveVersion(project.version)
@@ -105,69 +108,44 @@ project.artifacts {
105108
archives project.tasks.fatJar
106109
}
107110

108-
Properties pomProperties = new Properties()
109-
pomProperties.put('groupId', project.group)
110-
pomProperties.put("ArtifactId", artifactPrefix)
111-
pomProperties.put("Organization", "LabKey")
112-
pomProperties.put("OrganizationURL", orgUrl)
113-
pomProperties.put("Description", description )
114-
pomProperties.put("License", "The Apache Software License, Version 2.0")
115-
pomProperties.put("LicenseURL", "http://www.apache.org/licenses/LICENSE-2.0.txt")
116-
117-
// N.B. This seems redundant with the properties above, but artifactoryPublish needs to have a pom file, and I
118-
// can't figure out how to make it depend on the default pom file task (using tasks.generatePomFileForLibsPublication
119-
// produces an error complaining about not knowing what this task is). Using the pomFileTask as a dependency for
120-
// bintrayUpload does not work because the default generatePomFile... task runs after the pomFileTask and thus
121-
// the pom file we attempt to publish with does not have any of the properties specified above. Since I
122-
// can't figure out how to grab onto this task (don't know what type it is either), I can't disable it or specify
123-
// an ordering. And so we have two, which I really don't like.
124-
def pomConfig = {
125-
organization {
126-
name 'LabKey'
127-
url orgUrl
128-
}
129-
licenses {
130-
license {
131-
name 'The Apache Software License, Version 2.0'
132-
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
133-
distribution 'repo'
134-
}
135-
}
136-
scm {
137-
url 'http://svn.mgt.labkey.host/stedi/trunk'
138-
connection 'http://svn.mgt.labkey.host/stedi/trunk'
139-
developerConnection 'http://svn.mgt.labkey.host/stedi/trunk'
140-
}
141-
developers {
142-
developer {
143-
id 'labkey-team'
144-
name 'The LabKey Development Team'
145-
organization 'LabKey.org'
146-
organizationUrl orgUrl
147-
}
148-
}
149-
}
111+
def description = "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."
112+
def orgUrl = "http://www.labkey.org"
150113

151114
project.afterEvaluate {
152-
Task pomFileTask = project.task("pomFile",
153-
group: GroupNames.PUBLISHING,
154-
description: "create the pom file for this project",
155-
type: PomFile,
156-
{
157-
PomFile pom ->
158-
pom.pomProperties = pomProperties
159-
}
160-
)
161115
project.publishing {
162116
publications {
163117
libs(MavenPublication) {
118+
groupId = project.group
164119
from components.java
165-
pom.withXml {
166-
asNode().appendNode('url', orgUrl)
167-
asNode().appendNode('name', artifactPrefix)
168-
asNode().appendNode('description', description)
169-
asNode().children().last() + pomConfig
120+
artifactId = artifactPrefix
121+
versionMapping {
122+
usage('java-api') {
123+
fromResolutionOf('runtimeClasspath')
124+
}
125+
usage('java-runtime') {
126+
fromResolutionResult()
127+
}
170128
}
129+
pom {
130+
name = "LabKey Server Java Client API"
131+
description = "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."
132+
licenses {
133+
license {
134+
name = 'The Apache License, Version 2.0'
135+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
136+
}
137+
}
138+
organization {
139+
name = "LabKey"
140+
url = orgUrl
141+
}
142+
scm {
143+
connection = 'http://svn.mgt.labkey.host/stedi/trunk'
144+
developerConnection = 'http://svn.mgt.labkey.host/stedi/trunk'
145+
url = 'http://svn.mgt.labkey.host/stedi/trunk'
146+
}
147+
}
148+
171149
project.tasks.each {
172150
if (it instanceof Jar)
173151
{
@@ -187,7 +165,7 @@ project.afterEvaluate {
187165
dependsOn it
188166
}
189167
}
190-
dependsOn pomFileTask
168+
// dependsOn pomFileTask
191169
publications('libs')
192170
}
193171
}

0 commit comments

Comments
 (0)