Skip to content

Commit

Permalink
Publish artefacts to Sonatype OSSRH (#32)
Browse files Browse the repository at this point in the history
* Clean up root build.gradle

* Publish to Sonatype OSSRH

Use Gradle maven-publish, signing, and nexus-staging plugin to publish the plugin artifacts to Sonatype OSSRH
  • Loading branch information
puneetbehl authored Mar 11, 2022
1 parent 49a2bef commit c4acac8
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 45 deletions.
32 changes: 29 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
project('spring-security-cas') {
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
}
}

version = project.projectVersion

ext.isSnapshot = project.projectVersion.endsWith('-SNAPSHOT')
ext.isReleaseVersion = !isSnapshot

if (isReleaseVersion) {
apply plugin: 'maven-publish'
apply plugin: "io.github.gradle-nexus.publish-plugin"

nexusPublishing {
repositories {
sonatype {
def ossUser = System.getenv("SONATYPE_USERNAME") ?: project.hasProperty("sonatypeOssUsername") ? project.sonatypeOssUsername : ''
def ossPass = System.getenv("SONATYPE_PASSWORD") ?: project.hasProperty("sonatypeOssPassword") ? project.sonatypeOssPassword : ''
def ossStagingProfileId = System.getenv("SONATYPE_STAGING_PROFILE_ID") ?: project.hasProperty("sonatypeOssStagingProfileId") ? project.sonatypeOssStagingProfileId : ''
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
username = ossUser
password = ossPass
stagingProfileId = ossStagingProfileId
}
}
}
}
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
grailsVersion=5.1.1
projectVersion=5.0.0-SNAPSHOT
projectVersion=4.0.0-TEST
threeZeroXProjectVersion=3.0.1
casClientCoreVersion=3.4.1
springSecurityCoreVersion=5.0.0-SNAPSHOT
springSecurityVersion=5.6.1
javaxServletApiVersion=4.0.1
assetPipelineVersion=3.4.3
projectDesc=The CAS plugin adds CAS single sign-on support to a Grails application that uses Spring Security.
projectUrl=https://github.com/grails-plugins/grails-spring-security-cas
githubSlug=grails-plugins/grails-spring-security-cas
projectUrl=https://github.com/grails/grails-spring-security-cas
githubSlug=grails/grails-spring-security-cas
githubBranch=master
developers=Burt Beckwith
vcsUrl=https://github.com/grails-plugins/grails-spring-security-cas
websiteUrl=https://github.com/grails-plugins/grails-spring-security-cas
issueTrackerUrl=https://github.com/grails-plugins/grails-spring-security-cas/issues
vcsUrl=https://github.com/grails/grails-spring-security-cas
websiteUrl=https://github.com/grails/grails-spring-security-cas
issueTrackerUrl=https://github.com/grails/grails-spring-security-cas/issues
13 changes: 0 additions & 13 deletions gradle/artifactoryPublish.gradle

This file was deleted.

108 changes: 85 additions & 23 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,57 @@
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url 'https://repo.grails.org/grails/core' }
mavenCentral()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
}
}

version = projectVersion
group = 'org.grails.plugins'

apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "org.grails.grails-plugin"
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'org.grails.grails-plugin'

ext."signing.keyId" = project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : System.getenv('SIGNING_KEY')
ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : "${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg"
ext."signing.password" = project.hasProperty("signing.password") ? project.getProperty('signing.password') : System.getenv('SIGNING_PASSPHRASE')
ext.pomInfo = {
delegate.name "Grails Spring Security CAS Plugin"
delegate.description project.projectDesc
delegate.url project.hasProperty('vcsUrl') ? project.vcsUrl : "https://github.com/grails/$project.name"

delegate.licenses {
delegate.license {
delegate.name 'The Apache Software License, Version 2.0'
delegate.url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
delegate.distribution 'repo'
}
}

delegate.scm {
delegate.url "scm:git@github.com:${githubSlug}.git"
delegate.connection "scm:git@github.com:${githubSlug}.git"
delegate.developerConnection "scm:git@github.com:${githubSlug}.git"
}

if (developers) {
delegate.developers {
for (dev in developers.split(',')) {
delegate.developer {
delegate.id dev.toLowerCase().replace(' ', '')
delegate.name dev
}
}
}
}
}

repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}

Expand All @@ -33,26 +61,60 @@ dependencies {
compileOnly "org.grails:grails-web-boot"

profile "org.grails.profiles:web-plugin"
compile "org.grails.plugins:spring-security-core:$springSecurityCoreVersion"
api "org.grails.plugins:spring-security-core:$springSecurityCoreVersion"

compile "org.jasig.cas.client:cas-client-core:$casClientCoreVersion", {
api "org.jasig.cas.client:cas-client-core:$casClientCoreVersion", {
exclude module: 'slf4j-api'
}
compile "org.springframework.security:spring-security-cas:$springSecurityVersion", {
api "org.springframework.security:spring-security-cas:$springSecurityVersion", {
['spring-beans', 'spring-context', 'spring-core', 'spring-security-core',
'spring-security-web', 'spring-web'].each { exclude module: it }
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
}
if (isSnapshot) {
repositories {
maven {
credentials {
def u = System.getenv("ARTIFACTORY_USERNAME") ?: project.hasProperty("artifactoryPublishUsername") ? project.artifactoryPublishUsername : ''
def p = System.getenv("ARTIFACTORY_PASSWORD") ?: project.hasProperty("artifactoryPublishPassword") ? project.artifactoryPublishPassword : ''
username = u
password = p
}
url "https://repo.grails.org/grails/plugins3-snapshots-local"
}
}
}

publications {
maven(MavenPublication) {
artifactId project.name
from components.java

artifact sourcesJar
artifact javadocJar
artifact source: "${buildDir}/classes/groovy/main/META-INF/grails-plugin.xml",
classifier: "plugin",
extension: 'xml'
pom.withXml {
def xml = asNode()

xml.children().last() + pomInfo
// dependency management shouldn't be included
def n = xml.get("dependencyManagement")
if (n)
xml.remove(n)
}

}
}
}

signing {
sign publishing.publications.maven
}

// apply from: "${rootProject.projectDir}/gradle/artifactoryPublish.gradle"
tasks.withType(Sign) {
onlyIf { isReleaseVersion }
}

0 comments on commit c4acac8

Please sign in to comment.