Skip to content

Commit

Permalink
build - remove grails publish - it does support nested projects
Browse files Browse the repository at this point in the history
  • Loading branch information
jdaugherty committed Nov 4, 2024
1 parent 5f1430c commit 3b1fe22
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 16 deletions.
42 changes: 26 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository

buildscript {
repositories {
mavenCentral()
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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")
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))
}
89 changes: 89 additions & 0 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -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 }
}

0 comments on commit 3b1fe22

Please sign in to comment.