Update maven publishing plugin

This commit is contained in:
Scott Frederick
2021-10-04 17:59:56 -05:00
parent d1b0d051d0
commit 702d2a6d97
2 changed files with 60 additions and 50 deletions

View File

@@ -87,8 +87,6 @@ allprojects {
]
}
apply from: "${rootProject.projectDir}/publish-maven.gradle"
if (project.hasProperty('platformVersion')) {
apply plugin: 'spring-io'
@@ -109,6 +107,13 @@ allprojects {
}
}
configure(allprojects - [project(':spring-credhub-docs'),
project(':spring-credhub-integration-tests'),
project(':spring-credhub-reactive-integration-tests')]) {
apply plugin: 'java-library'
apply from: "${rootProject.projectDir}/publish-maven.gradle"
}
subprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8

View File

@@ -14,60 +14,65 @@
* limitations under the License.
*/
apply plugin: 'maven'
apply plugin: 'maven-publish'
install {
repositories.mavenInstaller {
customizePom(pom, project)
publishing {
repositories {
maven {
url = project.properties.getOrDefault('publicationRepository', "${System.getenv('HOME')}/.m2/repository")
}
}
}
def customizePom(pom, gradleProject) {
pom.whenConfigured { generatedPom ->
// eliminate test-scoped dependencies (no need in maven central poms)
generatedPom.dependencies.removeAll { dep ->
dep.scope == 'test'
}
// Ensure consistent ordering of dependencies to ease comparison with 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://spring.io/projects/spring-credhub'
organization {
name = 'Spring IO'
url = 'https://spring.io'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
publications {
mavenJava(MavenPublication) {
// suppressAllPomMetadataWarnings()
from components.java
pom {
afterEvaluate {
name = project.description
description = project.description
}
url = "https://spring.io/projects/spring-credhub"
organization {
name = "Pivotal Software, Inc."
url = "https://spring.io"
}
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-credhub"
connection = "scm:git:git://github.com/spring-projects/spring-credhub"
developerConnection = "scm:git:git://github.com/spring-projects/spring-credhub"
}
issueManagement {
system = "GitHub"
url = "https://github.com/spring-projects/spring-credhub/issues"
}
developers {
developer {
id = "sfrederick"
name = "Scott Frederick"
email = "sfrederick@pivotal.io"
}
}
}
scm {
url = 'https://github.com/spring-projects/spring-credhub'
connection = 'scm:git:https://github.com/spring-projects/spring-credhub.git'
developerConnection = 'scm:git:https://github.com/spring-projects/spring-credhub.git'
}
issueManagement {
system = 'GitHub'
url = 'https://github.com/spring-projects/spring-credhub/issues'
}
developers {
developer {
id = 'sfrederick'
name = 'Scott Frederick'
email = 'sfrederick@pivotal.io'
// Published pom will use fully-qualified dependency versions and no BOMs
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom.withXml {
def dependencyManagementNode = asNode().get("dependencyManagement")
asNode().remove(dependencyManagementNode)
}
}
}