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.
This commit is contained in:
48
build.gradle
48
build.gradle
@@ -99,30 +99,6 @@ allprojects {
|
||||
|
||||
}
|
||||
|
||||
subprojects { subproject ->
|
||||
|
||||
apply from: "${rootProject.projectDir}/publish-maven.gradle"
|
||||
|
||||
sourceCompatibility=1.8
|
||||
targetCompatibility=1.8
|
||||
|
||||
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:none"]
|
||||
|
||||
sourceSets.test.resources.srcDirs = ["src/main/java", "src/test/resources", "src/test/java"]
|
||||
|
||||
jar {
|
||||
manifest.attributes["Implementation-Title"] = subproject.name
|
||||
manifest.attributes["Implementation-Version"] = subproject.version
|
||||
|
||||
from("${rootProject.projectDir}/src/dist") {
|
||||
include "license.txt"
|
||||
include "notice.txt"
|
||||
into "META-INF"
|
||||
expand(copyright: new Date().format("yyyy"), version: project.version)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configure(javaProjects) { javaProject ->
|
||||
|
||||
test {
|
||||
@@ -154,6 +130,30 @@ configure(javaProjects) { javaProject ->
|
||||
}
|
||||
}
|
||||
|
||||
subprojects { subproject ->
|
||||
|
||||
apply from: "${rootProject.projectDir}/publish-maven.gradle"
|
||||
|
||||
sourceCompatibility=1.8
|
||||
targetCompatibility=1.8
|
||||
|
||||
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:none"]
|
||||
|
||||
sourceSets.test.resources.srcDirs = ["src/main/java", "src/test/resources", "src/test/java"]
|
||||
|
||||
jar {
|
||||
manifest.attributes["Implementation-Title"] = subproject.name
|
||||
manifest.attributes["Implementation-Version"] = subproject.version
|
||||
|
||||
from("${rootProject.projectDir}/src/dist") {
|
||||
include "license.txt"
|
||||
include "notice.txt"
|
||||
into "META-INF"
|
||||
expand(copyright: new Date().format("yyyy"), version: project.version)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configure(rootProject) {
|
||||
description = "Spring Web Flow"
|
||||
|
||||
|
||||
@@ -1,55 +1,61 @@
|
||||
apply plugin: "maven"
|
||||
apply plugin: "maven-publish"
|
||||
|
||||
install {
|
||||
repositories.mavenInstaller {
|
||||
customizePom(pom, project)
|
||||
}
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
if (project.name != 'spring-js-resources') {
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
}
|
||||
versionMapping {
|
||||
usage('java-api') {
|
||||
fromResolutionOf('runtimeClasspath')
|
||||
}
|
||||
usage('java-runtime') {
|
||||
fromResolutionResult()
|
||||
}
|
||||
}
|
||||
pom {
|
||||
afterEvaluate {
|
||||
description = project.description
|
||||
name = project.description
|
||||
}
|
||||
url = "https://github.com/spring-projects/spring-webflow"
|
||||
organization {
|
||||
name = "Spring IO"
|
||||
url = "https://spring.io/projects/spring-webflow"
|
||||
}
|
||||
licenses {
|
||||
license {
|
||||
name = "The Apache Software License, Version 2.0"
|
||||
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
|
||||
distribution = "repo"
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url = "https://github.com/spring-projects/spring-webflow"
|
||||
connection = "scm:git:git://github.com/spring-projects/spring-webflow"
|
||||
developerConnection = "scm:git:git://github.com/spring-projects/spring-webflow"
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = "rstoyanchev"
|
||||
name = "Rossen Stoyanchev"
|
||||
email = "rstoyanchev@pivotal.io"
|
||||
}
|
||||
}
|
||||
issueManagement {
|
||||
system = "Jira"
|
||||
url = "https://jira.spring.io/browse/SWF"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def customizePom(pom, gradleProject) {
|
||||
pom.whenConfigured { generatedPom ->
|
||||
// eliminate test-scoped dependencies (no need in maven central poms)
|
||||
generatedPom.dependencies.removeAll { dep ->
|
||||
dep.scope == "test"
|
||||
}
|
||||
|
||||
// sort to make pom dependencies order consistent to ease comparison of older poms
|
||||
generatedPom.dependencies = generatedPom.dependencies.sort { dep ->
|
||||
"$dep.scope:$dep.groupId:$dep.artifactId"
|
||||
}
|
||||
|
||||
// add all items necessary for maven central publication
|
||||
generatedPom.project {
|
||||
name = gradleProject.description
|
||||
description = gradleProject.description
|
||||
url = "https://github.com/spring-projects/spring-webflow"
|
||||
organization {
|
||||
name = "Spring IO"
|
||||
url = "https://spring.io/projects/spring-webflow"
|
||||
}
|
||||
licenses {
|
||||
license {
|
||||
name "The Apache Software License, Version 2.0"
|
||||
url "https://www.apache.org/licenses/LICENSE-2.0.txt"
|
||||
distribution "repo"
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url = "https://github.com/spring-projects/spring-webflow"
|
||||
connection = "scm:git:git://github.com/spring-projects/spring-webflow"
|
||||
developerConnection = "scm:git:git://github.com/spring-projects/spring-webflow"
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = "rstoyanchev"
|
||||
name = "Rossen Stoyanchev"
|
||||
email = "rstoyanchev@pivotal.io"
|
||||
}
|
||||
}
|
||||
issueManagement {
|
||||
system = "Jira"
|
||||
url = "https://jira.spring.io/browse/SWF"
|
||||
}
|
||||
}
|
||||
}
|
||||
// Disable generation of Gradle Module Metadata for compatibility
|
||||
// with older versions of Spring Web Flow.
|
||||
tasks.withType(GenerateModuleMetadata) {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user