Skip to content

Commit 2e3750d

Browse files
iayrstoyanchev
authored andcommitted
Adopt new Gradle maven-publish plugin
The maven plugin was removed in Gradle 7, so we need to replace it with maven-publish. This uses a similar DSL, but operates in a slightly different way. The simplest way of handling the differences is to reorder its application within build.gradle so that appropriate properties will have been applied by the time publish-maven.gradle is invoked.
1 parent 014c3d4 commit 2e3750d

File tree

2 files changed

+81
-75
lines changed

2 files changed

+81
-75
lines changed

build.gradle

+24-24
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,6 @@ allprojects {
9999

100100
}
101101

102-
subprojects { subproject ->
103-
104-
apply from: "${rootProject.projectDir}/publish-maven.gradle"
105-
106-
sourceCompatibility=1.8
107-
targetCompatibility=1.8
108-
109-
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:none"]
110-
111-
sourceSets.test.resources.srcDirs = ["src/main/java", "src/test/resources", "src/test/java"]
112-
113-
jar {
114-
manifest.attributes["Implementation-Title"] = subproject.name
115-
manifest.attributes["Implementation-Version"] = subproject.version
116-
117-
from("${rootProject.projectDir}/src/dist") {
118-
include "license.txt"
119-
include "notice.txt"
120-
into "META-INF"
121-
expand(copyright: new Date().format("yyyy"), version: project.version)
122-
}
123-
}
124-
}
125-
126102
configure(javaProjects) { javaProject ->
127103

128104
test {
@@ -154,6 +130,30 @@ configure(javaProjects) { javaProject ->
154130
}
155131
}
156132

133+
subprojects { subproject ->
134+
135+
apply from: "${rootProject.projectDir}/publish-maven.gradle"
136+
137+
sourceCompatibility=1.8
138+
targetCompatibility=1.8
139+
140+
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:none"]
141+
142+
sourceSets.test.resources.srcDirs = ["src/main/java", "src/test/resources", "src/test/java"]
143+
144+
jar {
145+
manifest.attributes["Implementation-Title"] = subproject.name
146+
manifest.attributes["Implementation-Version"] = subproject.version
147+
148+
from("${rootProject.projectDir}/src/dist") {
149+
include "license.txt"
150+
include "notice.txt"
151+
into "META-INF"
152+
expand(copyright: new Date().format("yyyy"), version: project.version)
153+
}
154+
}
155+
}
156+
157157
configure(rootProject) {
158158
description = "Spring Web Flow"
159159

publish-maven.gradle

+57-51
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,61 @@
1-
apply plugin: "maven"
1+
apply plugin: "maven-publish"
22

3-
install {
4-
repositories.mavenInstaller {
5-
customizePom(pom, project)
6-
}
3+
publishing {
4+
publications {
5+
mavenJava(MavenPublication) {
6+
from components.java
7+
if (project.name != 'spring-js-resources') {
8+
artifact sourcesJar
9+
artifact javadocJar
10+
}
11+
versionMapping {
12+
usage('java-api') {
13+
fromResolutionOf('runtimeClasspath')
14+
}
15+
usage('java-runtime') {
16+
fromResolutionResult()
17+
}
18+
}
19+
pom {
20+
afterEvaluate {
21+
description = project.description
22+
name = project.description
23+
}
24+
url = "https://github.com/spring-projects/spring-webflow"
25+
organization {
26+
name = "Spring IO"
27+
url = "https://spring.io/projects/spring-webflow"
28+
}
29+
licenses {
30+
license {
31+
name = "The Apache Software License, Version 2.0"
32+
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
33+
distribution = "repo"
34+
}
35+
}
36+
scm {
37+
url = "https://github.com/spring-projects/spring-webflow"
38+
connection = "scm:git:git://github.com/spring-projects/spring-webflow"
39+
developerConnection = "scm:git:git://github.com/spring-projects/spring-webflow"
40+
}
41+
developers {
42+
developer {
43+
id = "rstoyanchev"
44+
name = "Rossen Stoyanchev"
45+
46+
}
47+
}
48+
issueManagement {
49+
system = "Jira"
50+
url = "https://jira.spring.io/browse/SWF"
51+
}
52+
}
53+
}
54+
}
755
}
856

9-
def customizePom(pom, gradleProject) {
10-
pom.whenConfigured { generatedPom ->
11-
// eliminate test-scoped dependencies (no need in maven central poms)
12-
generatedPom.dependencies.removeAll { dep ->
13-
dep.scope == "test"
14-
}
15-
16-
// sort to make pom dependencies order consistent to ease comparison of older poms
17-
generatedPom.dependencies = generatedPom.dependencies.sort { dep ->
18-
"$dep.scope:$dep.groupId:$dep.artifactId"
19-
}
20-
21-
// add all items necessary for maven central publication
22-
generatedPom.project {
23-
name = gradleProject.description
24-
description = gradleProject.description
25-
url = "https://github.com/spring-projects/spring-webflow"
26-
organization {
27-
name = "Spring IO"
28-
url = "https://spring.io/projects/spring-webflow"
29-
}
30-
licenses {
31-
license {
32-
name "The Apache Software License, Version 2.0"
33-
url "https://www.apache.org/licenses/LICENSE-2.0.txt"
34-
distribution "repo"
35-
}
36-
}
37-
scm {
38-
url = "https://github.com/spring-projects/spring-webflow"
39-
connection = "scm:git:git://github.com/spring-projects/spring-webflow"
40-
developerConnection = "scm:git:git://github.com/spring-projects/spring-webflow"
41-
}
42-
developers {
43-
developer {
44-
id = "rstoyanchev"
45-
name = "Rossen Stoyanchev"
46-
47-
}
48-
}
49-
issueManagement {
50-
system = "Jira"
51-
url = "https://jira.spring.io/browse/SWF"
52-
}
53-
}
54-
}
57+
// Disable generation of Gradle Module Metadata for compatibility
58+
// with older versions of Spring Web Flow.
59+
tasks.withType(GenerateModuleMetadata) {
60+
enabled = false
5561
}

0 commit comments

Comments
 (0)