Skip to content

Commit

Permalink
chore(release): update build configurations (#547)
Browse files Browse the repository at this point in the history
Fixes Signing and Publishing of the artifacts.
  • Loading branch information
puneetbehl authored Mar 14, 2024
1 parent 8b01700 commit 9137f43
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 101 deletions.
56 changes: 29 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,39 @@ version = projectVersion
ext.set('grailsVersion', libs.versions.grails.asProvider().get())
ext.set('isSnapshot', version.endsWith('-SNAPSHOT'))
ext.set('isReleaseVersion', !isSnapshot)
ext.set('signing.keyId', findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY'))
ext.set('signing.password', findProperty('signing.password') ?: System.getenv('SIGNING_PASSPHRASE'))
ext.set('signing.secretKeyRingFile', findProperty('signing.secretKeyRingFile') ?: "${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg")
ext.set('pomInfo', {
delegate.url 'https://views.grails.org/latest/'
delegate.licenses {
delegate.license {
delegate.name 'The Apache Software License, Version 2.0'
delegate.url 'https://www.apache.org/licenses/LICENSE-2.0.txt'

allprojects {

ext.set('signing.keyId', findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY'))
ext.set('signing.password', findProperty('signing.password') ?: System.getenv('SIGNING_PASSPHRASE'))
ext.set('signing.secretKeyRingFile', findProperty('signing.secretKeyRingFile') ?: "${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg")
ext.set('pomInfo', {
delegate.url 'https://views.grails.org/latest/'
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.scm {
delegate.url 'https://github.com/grails/grails-views/'
delegate.connection 'scm:git:git://github.com/grails/grails-views'
delegate.developerConnection 'scm:git:ssh://github.com:grails/grails-views'
}
delegate.developers {
delegate.developer {
delegate.id 'graemerocher'
delegate.name 'Graeme Rocher'
delegate.email '[email protected]'
delegate.scm {
delegate.url 'https://github.com/grails/grails-views/'
delegate.connection 'scm:git:git://github.com/grails/grails-views'
delegate.developerConnection 'scm:git:ssh://github.com:grails/grails-views'
}
delegate.developer {
delegate.id 'puneetbehl'
delegate.name 'Puneet Behl'
delegate.email '[email protected]'
delegate.developers {
delegate.developer {
delegate.id 'graemerocher'
delegate.name 'Graeme Rocher'
delegate.email '[email protected]'
}
delegate.developer {
delegate.id 'puneetbehl'
delegate.name 'Puneet Behl'
delegate.email '[email protected]'
}
}
}
})
})

allprojects {
version = rootProject.version
repositories {
mavenLocal() // Used by Groovy Joint workflow github action after building Groovy
Expand Down
90 changes: 37 additions & 53 deletions gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,71 +1,55 @@
plugins {
id 'java-gradle-plugin'
id 'groovy'
id 'maven-publish'
id 'signing'
id 'java-gradle-plugin'
id 'groovy'
id 'maven-publish'
id 'signing'
}

group = 'org.grails.plugins'
ext.set('projectDesc', 'Grails Views Gradle Plugin')

dependencies {
implementation libs.grails.bootstrap
implementation libs.grails.gradle.plugin
implementation libs.groovy.core
implementation libs.spring.boot.gradle.plugin
implementation libs.grails.bootstrap
implementation libs.grails.gradle.plugin
implementation libs.groovy.core
implementation libs.spring.boot.gradle.plugin

// This is a workaround for grails-bootstrap exposing a
// different version of groovy-xml than the one used by Gradle.
// This causes issues with the Groovy compiler.
compileOnly "org.codehaus.groovy:groovy-xml:$GroovySystem.version"
// This is a workaround for grails-bootstrap exposing a
// different version of groovy-xml than the one used by Gradle.
// This causes issues with the Groovy compiler.
compileOnly "org.codehaus.groovy:groovy-xml:$GroovySystem.version"
}

gradlePlugin {
plugins {
create('viewsJson') {
id = 'org.grails.plugins.views-json'
implementationClass = 'grails.views.gradle.json.GrailsJsonViewsPlugin'
displayName = 'Grails Json Views Gradle Plugin'
description = 'The Gradle plugin for Json Views'
}
create('viewsMarkup') {
id = 'org.grails.plugins.views-markup'
implementationClass = 'grails.views.gradle.markup.GrailsMarkupViewsPlugin'
displayName = 'Grails Markup Views Gradle Plugin'
description = 'The Gradle plugin for Markup Views'
}
}
plugins {
create('viewsJson') {
id = 'org.grails.plugins.views-json'
implementationClass = 'grails.views.gradle.json.GrailsJsonViewsPlugin'
displayName = 'Grails Json Views Gradle Plugin'
description = 'The Gradle plugin for Json Views'
}
create('viewsMarkup') {
id = 'org.grails.plugins.views-markup'
implementationClass = 'grails.views.gradle.markup.GrailsMarkupViewsPlugin'
displayName = 'Grails Markup Views Gradle Plugin'
description = 'The Gradle plugin for Markup Views'
}
}
}

// Signing and publishing for this project is handled
// Publishing for this project is handled
// separately as it is using the java-gradle-plugin
afterEvaluate {
def publications = extensions.findByType(PublishingExtension).publications
signing {
required = { isReleaseVersion && gradle.taskGraph.hasTask('publish') }
sign(publications.withType(MavenPublication))
}
// Modify the 'pluginMaven' publication that is already
// set up by the java-gradle-plugin for the java components
publications.named('pluginMaven', MavenPublication) {
artifactId = project.name
versionMapping {
usage('java-api') { fromResolutionOf('runtimeClasspath') }
usage('java-runtime') { fromResolutionResult() }
}
pom {
name = 'Grails Views'
description = 'Provides additional view technologies to the Grails framework, including JSON and Markup views.'
}
}
// Add our pom info to all publications
// (e.g. also to the plugin marker poms)
publications.withType(MavenPublication).each {
it.pom.withXml {
asNode().children().last() + pomInfo
}
}
publishing.publications.each { MavenPublication publication ->
if (publication.name != "pluginMaven") {
publication.pom.withXml {
def xml = asNode()
xml.children().last() + pomInfo
}
}
}
}

apply from: rootProject.layout.projectDirectory.file('gradle/java-config.gradle')
apply from: rootProject.layout.projectDirectory.file('gradle/api-docs-config.gradle')
apply from: rootProject.layout.projectDirectory.file('gradle/api-docs-config.gradle')
apply from: rootProject.layout.projectDirectory.file('gradle/publishing.gradle')
62 changes: 41 additions & 21 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
def javaComponent = components.named('java')
project.extensions.configure(PublishingExtension) { PublishingExtension pe ->
pe.publications.register('maven', MavenPublication) {
artifactId = project.name
from javaComponent.get()
versionMapping {
usage('java-api') { fromResolutionOf('runtimeClasspath') }
usage('java-runtime') { fromResolutionResult() }
}
pom {
name = 'Grails Views'
description = 'Provides additional view technologies to the Grails framework, including JSON and Markup views.'
}
pom.withXml {
def pomNode = asNode()
pomNode.children().last() + pomInfo
// dependency management shouldn't be included
try { pomNode.dependencyManagement.replaceNode({}) } catch (Throwable ignore) {}

publishing {
publications {
pluginMaven(MavenPublication) {
artifactId = project.name
artifactId = "grails-${project.name}"
if (project.name != 'views-gradle') {
from javaComponent.get()
}
versionMapping {
usage('java-api') { fromResolutionOf('runtimeClasspath') }
usage('java-runtime') { fromResolutionResult() }
}
if (ext.has('isGrailsPlugin')) {
artifact source: "${project.sourceSets.main.groovy.classesDirectory.getAsFile().get()}/META-INF/grails-plugin.xml",
classifier: "plugin",
extension: 'xml'
}
pom {
name = 'Grails Views'
description = 'Provides additional view technologies to the Grails framework, including JSON and Markup views.'
}
pom.withXml {
def pomNode = asNode()
pomNode.children().last() + pomInfo
// dependency management shouldn't be included
try {
pomNode.dependencyManagement.replaceNode({})
} catch (Throwable ignore) {
}
}
}
}

Expand All @@ -35,12 +49,18 @@ project.extensions.configure(PublishingExtension) { PublishingExtension pe ->
}

afterEvaluate {
def publications = extensions.findByType(PublishingExtension).publications
extensions.configure(SigningExtension) { SigningExtension se ->
se.required = { isReleaseVersion && gradle.taskGraph.hasTask('publish') }
se.sign(publications.named('maven').get())
signing {
required = { isReleaseVersion && gradle.taskGraph.hasTask("publish") }
Publication[] publications = new Publication[project.publishing.publications.size()]
project.publishing.publications.findAll().toArray(publications)
sign(publications)
}

tasks.withType(Sign) {
onlyIf { isReleaseVersion }
}
}

tasks.register('install') {
dependsOn 'publishToMavenLocal'
}
1 change: 1 addition & 0 deletions json/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {

group = 'org.grails.plugins'
ext.set('projectDesc', 'Grails JSON Views')
ext.set('isGrailsPlugin', true)

dependencies {

Expand Down
1 change: 1 addition & 0 deletions markup/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
}

ext.set('projectDesc', 'Grails Markup Views')
ext.set('isGrailsPlugin', true)

dependencies {

Expand Down

0 comments on commit 9137f43

Please sign in to comment.