From 3b1fe22cf3e0f638e9a74bcd602ab7b21a930db1 Mon Sep 17 00:00:00 2001 From: James Daugherty Date: Mon, 4 Nov 2024 13:32:18 -0500 Subject: [PATCH] build - remove grails publish - it does support nested projects --- build.gradle | 42 +++++++++++-------- gradle/publishing.gradle | 89 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 gradle/publishing.gradle diff --git a/build.gradle b/build.gradle index 4aedae1e..d8442b53 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository + buildscript { repositories { mavenCentral() @@ -25,6 +27,23 @@ def pluginProjects = ['spring-security-rest', 'spring-security-rest-memcached', def profileProjects = ['spring-security-rest-testapp-profile'] def publishedProjects = pluginProjects + profileProjects +if (!version.endsWith('SNAPSHOT')) { + nexusPublishing { + String nexusUser = findProperty('sonatypeUsername') + String nexusPass = findProperty('sonatypePassword') + String nexusStagingProfileId = findProperty('sonatypeStagingProfileId') + String nexusUrl = findProperty('sonatypeNexusUrl') ?: 'https://s01.oss.sonatype.org/service/local/' + repositories { + sonatype { + nexusUrl = uri(nexusUrl) + username = nexusUser + password = nexusPass + stagingProfileId = nexusStagingProfileId + } + } + } +} + version projectVersion subprojects { Project project -> @@ -93,22 +112,13 @@ subprojects { Project project -> } if (project.name in publishedProjects) { - if(project.name in profileProjects) { - apply plugin:"org.grails.internal.grails-profile-publish" - } - else { - apply plugin:"org.grails.internal.grails-plugin-publish" - } - - grailsPublish { - userOrg = 'grails' - githubSlug = 'grails/grails-spring-security-rest' - license = 'Apache-2.0' - title = "Spring Security REST plugin" - desc = "Grails plugin to implement token-based, RESTful authentication using Spring Security" - developers = [alvarosanchez:"Alvaro Sanchez-Mariscal", jameskleeh:"James Kleeh", jdaugherty:"James Daugherty"] - } + apply from: rootProject.file("gradle/publishing.gradle") } } -apply from: rootProject.file("gradle/docs.gradle") \ No newline at end of file +apply from: rootProject.file("gradle/docs.gradle") + +//do not generate extra load on Nexus with new staging repository if signing fails +tasks.withType(InitializeNexusStagingRepository).configureEach { + shouldRunAfter(tasks.withType(Sign)) +} \ No newline at end of file diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle new file mode 100644 index 00000000..9bbf113a --- /dev/null +++ b/gradle/publishing.gradle @@ -0,0 +1,89 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +ext.set('signing.keyId', project.findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY')) +ext.set('signing.password', project.findProperty('signing.password') ?: System.getenv('SIGNING_PASSPHRASE')) + +def pomInfo = { + delegate.name "Spring Security REST plugin" + delegate.description "Grails plugin to implement token-based, RESTful authentication using Spring Security" + delegate.url "https://github.com/grails/grails-spring-security-rest" + + delegate.licenses { + delegate.license { + delegate.name 'Apache-2.0' + delegate.url 'https://www.apache.org/licenses/LICENSE-2.0.txt' + delegate.distribution 'repo' + } + } + + delegate.scm { + delegate.url "scm:git@github.com:grails/grails-spring-security-rest.git" + delegate.connection "scm:git@github.com:grails/grails-spring-security-rest.git" + delegate.developerConnection "scm:git@github.com:grails/grails-spring-security-rest.git" + } + + delegate.developers { + delegate.developer { + delegate.id 'alvarosanchez' + delegate.name 'Alvaro Sanchez-Mariscal' + } + delegate.developer { + delegate.id 'jameskleeh' + delegate.name 'James Kleeh' + } + delegate.developer { + delegate.id 'jdaugherty' + delegate.name "James Daugherty" + } + } +} + +publishing { + publications { + maven(MavenPublication) { + artifactId = project.name + groupId = project.group + version = project.version + + if(!isProfile) { + from components.java + + artifact sourcesJar + artifact javadocJar + } + + pom.withXml { + def pomNode = asNode() + pomNode.children().last() + pomInfo + } + } + } + + if (isSnapshot) { + repositories { + maven { + credentials { + username = project.findProperty('artifactoryPublishUsername') ?: '' + password = project.findProperty('artifactoryPublishPassword') ?: '' + } + url = isProfile ? + uri('https://repo.grails.org/grails/libs-snapshots-local') : + uri('https://repo.grails.org/grails/plugins3-snapshots-local') + + + } + } + } +} + +afterEvaluate { + signing { + required = { isReleaseVersion && gradle.taskGraph.hasTask('publish') } + sign(publishing.publications.maven) + } +} + +tasks.withType(Sign) { + onlyIf { isReleaseVersion } +}