Skip to content

Commit 254c760

Browse files
committed
build: use org.grails.grails-publish for publishing
1 parent b72eb62 commit 254c760

File tree

7 files changed

+62
-129
lines changed

7 files changed

+62
-129
lines changed

.github/workflows/gradle.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ jobs:
5555
- name: "📤 Publish Snapshot to repo.grails.org"
5656
env:
5757
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
58-
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
59-
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
58+
GRADLE_PUBLISH_RELEASE: 'false'
59+
MAVEN_PUBLISH_USERNAME: ${{ secrets.MAVEN_PUBLISH_USERNAME }}
60+
MAVEN_PUBLISH_PASSWORD: ${{ secrets.MAVEN_PUBLISH_PASSWORD }}
61+
MAVEN_PUBLISH_URL: ${{ secrets.MAVEN_PUBLISH_SNAPSHOT_URL }}
6062
run: ./gradlew --no-build-cache publish
6163
trigger-build-gorm-impls:
6264
if: github.event_name == 'push'

.github/workflows/release.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ jobs:
5656
id: publish
5757
env:
5858
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
59+
GRAILS_PUBLISH_RELEASE: 'true'
60+
NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }}
61+
NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }}
62+
NEXUS_PUBLISH_URL: ${{ secrets.NEXUS_PUBLISH_RELEASE_URL }}
63+
NEXUS_PUBLISH_STAGING_PROFILE_ID: ${{ secrets.NEXUS_PUBLISH_STAGING_PROFILE_ID }}
5964
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
6065
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
61-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
62-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
63-
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
6466
run: >
6567
./gradlew --no-build-cache
6668
-Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg
@@ -90,9 +92,11 @@ jobs:
9092
- name: "🚀 Release Sonatype Staging Repository"
9193
env:
9294
GITHUB_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
93-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
94-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
95-
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
95+
GRAILS_PUBLISH_RELEASE: 'true'
96+
NEXUS_PUBLISH_USERNAME: ${{ secrets.NEXUS_PUBLISH_USERNAME }}
97+
NEXUS_PUBLISH_PASSWORD: ${{ secrets.NEXUS_PUBLISH_PASSWORD }}
98+
NEXUS_PUBLISH_URL: ${{ secrets.NEXUS_PUBLISH_RELEASE_URL }}
99+
NEXUS_PUBLISH_STAGING_PROFILE_ID: ${{ secrets.NEXUS_PUBLISH_STAGING_PROFILE_ID }}
96100
run: >
97101
./gradlew
98102
findSonatypeStagingRepository

build.gradle

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
1-
io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository
2-
3-
buildscript {
4-
repositories {
5-
maven { url = 'https://repo.grails.org/grails/core' }
6-
}
7-
dependencies {
8-
classpath 'io.github.gradle-nexus:publish-plugin:2.0.0'
9-
}
10-
}
11-
12-
group = 'org.grails'
13-
version = project.projectVersion
14-
151
ext {
162
isCiBuild = System.getenv('CI')
17-
isSnapshot = projectVersion.endsWith('-SNAPSHOT')
18-
isReleaseVersion = !isSnapshot
193
excludeUnusedTransDeps = findProperty('excludeUnusedTransDeps')
204
}
215

@@ -62,25 +46,7 @@ allprojects {
6246
}
6347
}
6448

65-
if (isReleaseVersion) {
66-
apply plugin: 'io.github.gradle-nexus.publish-plugin'
67-
nexusPublishing {
68-
repositories {
69-
sonatype {
70-
nexusUrl = uri('https://s01.oss.sonatype.org/service/local')
71-
username = System.getenv('SONATYPE_USERNAME') ?: ''
72-
password = System.getenv('SONATYPE_PASSWORD') ?: ''
73-
stagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID') ?: ''
74-
}
75-
}
76-
}
77-
//do not generate extra load on Nexus with new staging repository if signing fails
78-
tasks.withType(InitializeNexusStagingRepository).configureEach {
79-
shouldRunAfter = tasks.withType(Sign)
80-
}
81-
}
82-
8349
tasks.register('clean', Delete) {
8450
group = 'build'
8551
delete layout.buildDirectory
86-
}
52+
}

buildSrc/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
plugins {
2+
id 'groovy-gradle-plugin'
3+
}
4+
5+
def versions = new Properties()
6+
file('../gradle.properties').withInputStream {
7+
versions.load(it)
8+
}
9+
10+
repositories {
11+
mavenLocal()
12+
maven { url = 'https://repo.grails.org/grails/core' }
13+
mavenCentral()
14+
if (System.getenv('GITHUB_MAVEN_PASSWORD')) {
15+
maven {
16+
url = 'https://maven.pkg.github.com/grails/grails-core'
17+
credentials {
18+
username = 'DOES_NOT_MATTER'
19+
password = System.getenv('GITHUB_MAVEN_PASSWORD')
20+
}
21+
}
22+
}
23+
}
24+
25+
dependencies {
26+
implementation platform("org.grails:grails-bom:${versions.getProperty('grailsVersion')}")
27+
implementation 'org.grails:grails-gradle-plugin'
28+
}

gradle/java-config.gradle

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
compileJava.options.release = javaVersion.toInteger()
2-
3-
java {
4-
withSourcesJar()
5-
withJavadocJar()
6-
}
1+
compileJava.options.release = javaVersion.toInteger()

gradle/publish-config.gradle

Lines changed: 17 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,18 @@
1-
apply plugin: 'maven-publish'
2-
apply plugin: 'signing'
3-
4-
ext.set('signing.keyId', System.getenv('SIGNING_KEY'))
5-
ext.set('signing.password', System.getenv('SIGNING_PASSPHRASE'))
6-
ext.set('signing.secretKeyRingFile', project.findProperty('signing.secretKeyRingFile') ?: "${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg")
7-
8-
publishing {
9-
if (isSnapshot) {
10-
repositories {
11-
maven {
12-
credentials {
13-
username = System.getenv('ARTIFACTORY_USERNAME') ?: ''
14-
password = System.getenv('ARTIFACTORY_PASSWORD') ?: ''
15-
}
16-
url = 'https://repo.grails.org/grails/libs-snapshots-local'
17-
}
18-
}
19-
}
20-
21-
publications {
22-
maven(MavenPublication) {
23-
24-
artifactId = project.findProperty('artifactId') ?: project.name
25-
groupId = project.group
26-
version = project.version
27-
28-
from components.java
29-
30-
pom {
31-
name = project.findProperty('pomTitle') ?: 'Grails GORM'
32-
description = project.findProperty('pomDescription') ?: 'GORM - Grails Data Access Framework'
33-
url = 'https://gorm.grails.org/'
34-
35-
licenses {
36-
license {
37-
name = 'The Apache Software License, Version 2.0'
38-
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
39-
distribution = 'repo'
40-
}
41-
}
42-
43-
developers {
44-
for (dev in project.findProperty('pomDevelopers') ?: [[id: 'graemerocher', name: 'Graeme Rocher'], [id: 'jeffscottbrown', name: 'Jeff Brown'], [id: 'burtbeckwith', name: 'Burt Beckwith'], [id: 'jameskleeh', name: 'James Kleeh'], [id: 'puneetbehl', name: 'Puneet Behl'], [id: 'jamesfredley', name: 'James Fredley']]) {
45-
developer {
46-
id = dev.id
47-
name = dev.name
48-
}
49-
}
50-
}
51-
52-
scm {
53-
url = 'scm:[email protected]:grails/grails-data-mapping.git'
54-
connection = 'scm:[email protected]:grails/grails-data-mapping.git'
55-
developerConnection = 'scm:[email protected]:grails/grails-data-mapping.git'
56-
}
57-
}
58-
59-
// dependency management shouldn't be included
60-
pom.withXml {
61-
def pomNode = asNode()
62-
try { pomNode.dependencyManagement.replaceNode({}) } catch (Throwable ignore) {}
63-
}
64-
}
65-
}
1+
import org.grails.gradle.plugin.publishing.GrailsPublishExtension
2+
3+
apply plugin: 'org.grails.grails-publish'
4+
5+
project.extensions.configure(GrailsPublishExtension) {
6+
it.githubSlug = 'grails/grails-data-mapping'
7+
it.license.name = 'Apache-2.0'
8+
it.title = findProperty('pomTitle') ?: 'Grails GORM'
9+
it.desc = findProperty('pomDescription') ?: 'GORM - Grails Data Access Framework'
10+
it.developers = findProperty('pomDevelopers') as Map<String,String> ?: [
11+
'graemerocher': 'Graeme Rocher',
12+
'jeffscottbrown': 'Jeff Brown',
13+
'burtbeckwith': 'Burt Beckwith',
14+
'jameskleeh': 'James Kleeh',
15+
'puneetbehl': 'Puneet Behl',
16+
'jamesfredley': 'James Fredley'
17+
]
6618
}
67-
68-
afterEvaluate {
69-
signing {
70-
required = { isReleaseVersion && gradle.taskGraph.hasTask('publish') }
71-
sign(publishing.publications.maven)
72-
}
73-
}
74-
75-
tasks.withType(Sign).configureEach {
76-
onlyIf { isReleaseVersion }
77-
}

grails-gorm-testing-support/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ group = 'org.grails'
99
ext {
1010
pomTitle = 'Grails Web Testing Support'
1111
pomDescription = 'Support for writing concise expressive tests for Grails Web Artifacts'
12-
pomDevelopers = [
13-
[id: 'jeffscottbrown', name: 'Jeff Brown'],
14-
[id: 'jameskleeh', name: 'James Kleeh']
15-
]
12+
pomDevelopers = ['jeffscottbrown': 'Jeff Brown', 'jameskleeh': 'James Kleeh']
1613
}
1714

1815
dependencies {

0 commit comments

Comments
 (0)