jdaugherty commented on code in PR #14836:
URL: https://github.com/apache/grails-core/pull/14836#discussion_r2174090541
##########
grails-forge/gradle/publish-config.gradle:
##########
@@ -29,4 +31,84 @@ extensions.configure(GrailsPublishExtension) {
it.developers = findProperty('pomDevelopers') as Map<String, String> ?:
[puneetbehl: 'Peter Behl']
it.pomCustomization = findProperty('pomCustomization') as Closure
it.publishTestSources = findProperty('pomPublishTestSources') ?: false
+}
+
+apply plugin: 'org.gradle.crypto.checksum'
+
+afterEvaluate {
+ if (project.plugins.hasPlugin('signing')) {
+ if(System.getenv('TEST_BUILD_REPRODUCIBLE')) {
+ project.logger.lifecycle("Signing is disabled for this build to
test build reproducibility.")
+ project.tasks.withType(Sign).configureEach {
+ it.enabled = false
+ }
+ }
+ }
+ if (project.plugins.hasPlugin("maven-publish")) {
+ def checksumTask = tasks.register("publishedChecksums", Checksum)
+ checksumTask.configure { Checksum check ->
+ check.checksumAlgorithm = Checksum.Algorithm.SHA512
+
check.outputDirectory.set(project.layout.buildDirectory.dir("checksums"))
+ check.dependsOn(tasks.withType(Jar))
+ }
+
+ def artifactsDir = project.layout.buildDirectory.dir("artifacts")
+ def artifactsTask = tasks.register("savePublishedArtifacts") {
+ it.outputs.dir(artifactsDir)
+ it.dependsOn(tasks.withType(Jar))
+ }
+
+ gradle.taskGraph.whenReady {
+ List filesToChecksum = []
+ publishing.publications.withType(MavenPublication).all {
MavenPublication publication ->
+ publication.artifacts.each { MavenArtifact artifact ->
+ if(artifact.file.name == 'grails-plugin.xml' ||
artifact.file.name == 'profile.yml') {
+ return
+ }
+ filesToChecksum << artifact.file
+ }
+ }
+
+ checksumTask.configure { Checksum check ->
+ check.inputFiles.setFrom(filesToChecksum.unique())
+ check.finalizedBy(artifactsTask)
+
+ }
+
+ artifactsTask.configure {
+ doLast {
+ Map<String, String> artifacts = [:]
+
project.publishing.publications.withType(MavenPublication).all {
MavenPublication publication ->
+ publication.artifacts.each { MavenArtifact artifact ->
+ if(!artifact.file.exists() || artifact.file.name
== 'grails-plugin.xml' || artifact.file.name == 'profile.yml') {
+ return
+ }
+
+ if(artifact.classifier) {
+ artifacts[artifact.file.name] =
"${publication.groupId}:${publication.artifactId}:${publication.version}:${artifact.classifier}"
as String
+ }
+ else {
+ artifacts[artifact.file.name] =
"${publication.groupId}:${publication.artifactId}:${publication.version}" as
String
+ }
+ }
+ }
Review Comment:
I tried several iterations of this initially and couldn't get it to work.
When I updated this code, it fails:
Execution failed for task ':grails-forge-cli:savePublishedArtifacts'.
> Extension of type 'PublishingExtension' does not exist. Currently
registered extension types: [ExtraPropertiesExtension]
Also, doLast { } is part of the execution phase, so I can't fetch these
using configureEach. I need to find the publications that are actually
registered. Any suggestions?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]