jdaugherty commented on code in PR #5:
URL:
https://github.com/apache/incubator-grails-gradle-publish/pull/5#discussion_r2266936008
##########
plugin/src/main/groovy/org/apache/grails/gradle/publish/GrailsPublishGradlePlugin.groovy:
##########
@@ -250,192 +271,158 @@ Note: if project properties are used, the properties
must be defined prior to ap
validateProjectPublishable(project as Project)
- project.publishing {
+ project.extensions.configure(PublishingExtension) {
PublishingExtension pe ->
final GrailsPublishExtension gpe =
extensionContainer.findByType(GrailsPublishExtension)
final def mavenPublishUrl =
project.findProperty('mavenPublishUrl') ?: System.getenv('MAVEN_PUBLISH_URL')
if (useMavenPublish) {
System.setProperty('org.gradle.internal.publish.checksums.insecure', true as
String)
- repositories {
- maven {
+ pe.repositories { RepositoryHandler repoHandler ->
+ repoHandler.maven { MavenArtifactRepository repo ->
final String mavenPublishUsername =
project.findProperty('mavenPublishUsername') ?:
System.getenv('MAVEN_PUBLISH_USERNAME')
final String mavenPublishPassword =
project.findProperty('mavenPublishPassword') ?:
System.getenv('MAVEN_PUBLISH_PASSWORD')
if (mavenPublishUsername && mavenPublishPassword) {
- credentials {
- username = mavenPublishUsername
- password = mavenPublishPassword
+ repo.credentials { PasswordCredentials
credentials ->
+ credentials.username = mavenPublishUsername
+ credentials.password = mavenPublishPassword
}
}
- url = mavenPublishUrl
+ repo.url = mavenPublishUrl
+ repo.name = 'maven'
}
def testRepoPath = gpe.testRepositoryPath.getOrNull()
if (testRepoPath) {
- maven {
- name = 'TestCaseMavenRepo'
- url = testRepoPath
+ repoHandler.maven { MavenArtifactRepository repo ->
+ repo.name = 'TestCaseMavenRepo'
+ repo.url = testRepoPath
}
}
}
} else {
// This is a local publish. Add the test case repository
if it's defined on the extension.
def testRepoPath = gpe.testRepositoryPath.getOrNull()
if (testRepoPath) {
- repositories {
- maven {
- name = 'TestCaseMavenRepo'
- url = testRepoPath
+ pe.repositories { RepositoryHandler repoHandler ->
+ repoHandler.maven { MavenArtifactRepository repo ->
+ repo.name = 'TestCaseMavenRepo'
+ repo.url = testRepoPath
}
}
}
}
- publications {
- it.create(gpe.publicationName.get(), MavenPublication) {
- delegate.artifactId = gpe.artifactId.get()
- delegate.groupId = gpe.groupId.get()
+ pe.publications { PublicationContainer publications ->
+ publications.create(gpe.publicationName.get(),
MavenPublication) { MavenPublication publication ->
+ publication.artifactId = gpe.artifactId.get()
+ publication.groupId = gpe.groupId.get()
if (gpe.addComponents.get()) {
- doAddArtefact(project, delegate)
+ doAddArtefact(project, publication)
def extraArtefact =
getDefaultExtraArtifact(project)
if (extraArtefact) {
- artifact extraArtefact
+ publication.artifact(extraArtefact)
}
}
- pom.withXml {
- Node pomNode = asNode()
-
- if
(!project.extensions.findByType(JavaPlatformExtension)) {
- // Prevent multiple dependencyManagement nodes
- if (pomNode.dependencyManagement) {
-
pomNode.dependencyManagement[0].replaceNode {}
- }
- }
-
- if (gpe != null) {
- pomNode.children().last() + {
- delegate.name gpe.title.get()
- delegate.description gpe.desc.get()
- delegate.url gpe.websiteUrl.get()
-
- def license = gpe.license
- if (license != null) {
- def concreteLicense =
GrailsPublishExtension.License.LICENSES.get(license.name)
- if (concreteLicense != null) {
- delegate.licenses {
- delegate.license {
- delegate.name
concreteLicense.name
- delegate.url
concreteLicense.url
- delegate.distribution
concreteLicense.distribution
- }
- }
- } else if (license.name &&
license.url) {
- delegate.licenses {
- delegate.license {
- delegate.name license.name
- delegate.url license.url
- delegate.distribution
license.distribution
- }
- }
+ publication.pom { MavenPom pom ->
+ pom.name.set(gpe.title.get())
+ pom.description.set(gpe.desc.get())
+ pom.url.set(gpe.websiteUrl.get())
Review Comment:
I actually want to call get in this case so that an error is thrown if it's
not set.
--
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]