Skip to content

Commit

Permalink
build: Fix publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
matrei committed Sep 17, 2024
1 parent 5ce49f2 commit 0beb778
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
ext.setProperty('signing.keyId', project.findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY'))
ext.setProperty('signing.password', project.findProperty('signing.password') ?: System.getenv('SIGNING_PASSPHRASE'))
ext.set('signing.keyId', project.findProperty('signing.keyId') ?: System.getenv('SIGNING_KEY'))
ext.set('signing.password', project.findProperty('signing.password') ?: System.getenv('SIGNING_PASSPHRASE'))

def isGrailsPlugin = project.group == 'org.grails.plugins'
def isCoreModule = project.name.endsWith('-core')

def pomInfo = {
delegate.name project.title
delegate.description project.projectDesc
Expand Down Expand Up @@ -36,26 +35,25 @@ def pomInfo = {
}

def javaComponent = components.named('java')
project.extensions.configure(PublishingExtension) { PublishingExtension pe ->

pe.publications.register('maven', MavenPublication) {

if (isGrailsPlugin) artifactId = project.name - 'grails-plugin-'
if (isCoreModule) artifactId = project.name - '-core'

from javaComponent.get()
publishing {
publications {
maven(MavenPublication) {
if (isGrailsPlugin) artifactId = project.name - 'grails-plugin-'
if (isCoreModule) artifactId = project.name - '-core'
from javaComponent.get()

versionMapping {
usage('java-api') { fromResolutionOf('runtimeClasspath') }
usage('java-runtime') { fromResolutionResult() }
}
versionMapping {
usage('java-api') { fromResolutionOf('runtimeClasspath') }
usage('java-runtime') { fromResolutionResult() }
}

pom.withXml {
def pomNode = asNode()
pomNode.children().last() + pomInfo
pom.withXml {
def pomNode = asNode()
pomNode.children().last() + pomInfo

// dependency management shouldn't be included
try { pomNode.dependencyManagement.replaceNode({}) } catch (Throwable ignore) {}
// dependency management shouldn't be included
try { pomNode.dependencyManagement.replaceNode({}) } catch (Throwable ignore) {}
}
}
}

Expand All @@ -67,21 +65,21 @@ project.extensions.configure(PublishingExtension) { PublishingExtension pe ->
password = project.findProperty('artifactoryPublishPassword') ?: ''
}
url = isGrailsPlugin ?
uri('https://repo.grails.org/grails/plugins3-snapshots-local') :
uri('https://repo.grails.org/grails/libs-snapshots-local')
uri('https://repo.grails.org/grails/plugins3-snapshots-local') :
uri('https://repo.grails.org/grails/libs-snapshots-local')

}
}
}
}

afterEvaluate {
def mavenPublication = project.extensions.findByType(PublishingExtension).publications.named('maven')
project.extensions.configure(SigningExtension) { SigningExtension se ->
se.required = { isReleaseVersion }
se.sign mavenPublication.get()
signing {
required = { isReleaseVersion && gradle.taskGraph.hasTask('publish') }
sign(publishing.publications.maven)
}
}

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

0 comments on commit 0beb778

Please sign in to comment.