Skip to content

Commit 6402d7e

Browse files
committed
Add workaround for nexus description/group not being defined
1 parent a4a0140 commit 6402d7e

File tree

3 files changed

+105
-59
lines changed

3 files changed

+105
-59
lines changed

grails-gradle/build.gradle

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import java.time.Instant
1919
import java.time.ZoneOffset
2020
import java.time.format.DateTimeFormatter
2121

22-
23-
2422
Properties props = new Properties()
2523
file('../gradle.properties').withInputStream {
2624
props.load(it)
@@ -54,61 +52,7 @@ ext {
5452
configuredTestParallel = findProperty('maxTestParallel') as Integer ?: (isCiBuild ? 3 : Runtime.runtime.availableProcessors() * 3/4 as int ?: 1)
5553
}
5654

57-
if (isReleaseVersion) {
58-
apply plugin: 'io.github.gradle-nexus.publish-plugin'
59-
60-
nexusPublishing {
61-
repositories {
62-
sonatype {
63-
if(System.getenv('NEXUS_PUBLISH_URL')) {
64-
nexusUrl = uri(System.getenv('NEXUS_PUBLISH_URL'))
65-
}
66-
username = System.getenv('NEXUS_PUBLISH_USERNAME')
67-
password = System.getenv('NEXUS_PUBLISH_PASSWORD')
68-
stagingProfileId = System.getenv('NEXUS_PUBLISH_STAGING_PROFILE_ID')
69-
}
70-
}
71-
}
55+
apply {
56+
from layout.projectDirectory.file('gradle/gradle-wrapper-root-config.gradle')
57+
from layout.projectDirectory.file('gradle/publish-root-config.gradle')
7258
}
73-
74-
tasks.register("aggregateChecksums") {
75-
group = "publishing"
76-
description = "Aggregates all SHA-256 checksums from subprojects into a single file."
77-
78-
def outputFileProvider = rootProject.layout.buildDirectory.file("checksums.txt")
79-
outputs.file(outputFileProvider)
80-
81-
outputs.upToDateWhen { false } // not worth caching
82-
83-
doLast {
84-
def outputFile = outputFileProvider.get().asFile
85-
outputFile.withPrintWriter { writer ->
86-
subprojects.each { sub ->
87-
def checksumDir = sub.layout.buildDirectory.dir("checksums").get().asFile
88-
if (checksumDir.exists()) {
89-
checksumDir.listFiles(new FilenameFilter() {
90-
boolean accept(File dir, String name) {
91-
return name.endsWith(".sha256")
92-
}
93-
})?.each { checksumFile ->
94-
def jarName = checksumFile.name - ".sha256"
95-
def checksumLine = checksumFile.text.trim()
96-
def checksum = checksumLine.tokenize()[0]
97-
writer.println("${jarName} ${checksum}")
98-
}
99-
}
100-
}
101-
}
102-
103-
println "Checksum manifest written to ${outputFile}"
104-
}
105-
}
106-
107-
def sdkmanProps = new Properties()
108-
project.rootProject.layout.projectDirectory.file('../.sdkmanrc').asFile.withInputStream {
109-
sdkmanProps.load(it)
110-
}
111-
tasks.withType(Wrapper).configureEach {
112-
gradleVersion = sdkmanProps.gradle
113-
}
114-
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
def sdkmanProps = new Properties()
21+
project.rootProject.layout.projectDirectory.file('../.sdkmanrc').asFile.withInputStream {
22+
sdkmanProps.load(it)
23+
}
24+
tasks.withType(Wrapper).configureEach {
25+
gradleVersion = sdkmanProps.gradle
26+
}
27+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* https://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
// Workaround needed for nexus publishing bug
22+
// version and group must be specified in the root project
23+
// https://github.com/gradle-nexus/publish-plugin/issues/310
24+
version = projectVersion
25+
group = 'this.will.be.overridden'
26+
27+
if (isReleaseVersion) {
28+
apply plugin: 'io.github.gradle-nexus.publish-plugin'
29+
30+
nexusPublishing {
31+
repositories {
32+
sonatype {
33+
if(System.getenv('NEXUS_PUBLISH_URL')) {
34+
nexusUrl = uri(System.getenv('NEXUS_PUBLISH_URL'))
35+
}
36+
username = System.getenv('NEXUS_PUBLISH_USERNAME')
37+
password = System.getenv('NEXUS_PUBLISH_PASSWORD')
38+
stagingProfileId = System.getenv('NEXUS_PUBLISH_STAGING_PROFILE_ID')
39+
}
40+
}
41+
}
42+
}
43+
44+
tasks.register("aggregateChecksums") {
45+
group = "publishing"
46+
description = "Aggregates all SHA-256 checksums from subprojects into a single file."
47+
48+
def outputFileProvider = rootProject.layout.buildDirectory.file("checksums.txt")
49+
outputs.file(outputFileProvider)
50+
51+
outputs.upToDateWhen { false } // not worth caching
52+
53+
doLast {
54+
def outputFile = outputFileProvider.get().asFile
55+
outputFile.withPrintWriter { writer ->
56+
subprojects.each { sub ->
57+
def checksumDir = sub.layout.buildDirectory.dir("checksums").get().asFile
58+
if (checksumDir.exists()) {
59+
checksumDir.listFiles(new FilenameFilter() {
60+
boolean accept(File dir, String name) {
61+
return name.endsWith(".sha256")
62+
}
63+
})?.each { checksumFile ->
64+
def jarName = checksumFile.name - ".sha256"
65+
def checksumLine = checksumFile.text.trim()
66+
def checksum = checksumLine.tokenize()[0]
67+
writer.println("${jarName} ${checksum}")
68+
}
69+
}
70+
}
71+
}
72+
73+
println "Checksum manifest written to ${outputFile}"
74+
}
75+
}

0 commit comments

Comments
 (0)