Skip to content

Commit

Permalink
Merge pull request #123 from nebula-plugins/MavenDeveloperPlugin/stro…
Browse files Browse the repository at this point in the history
…ng-typing

enable strong typing for MavenDeveloperPlugin
  • Loading branch information
rpalcolea authored Jan 7, 2019
2 parents 880ad0d + 8e17934 commit 94af237
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package nebula.plugin.publishing.contacts

import nebula.plugin.contacts.BaseContactsPlugin
import nebula.plugin.contacts.Contact
import org.gradle.api.publish.maven.MavenPublication

class BaseContactPluginConfigurator {

static void configureContacts(BaseContactsPlugin contactsPlugin, MavenPublication publication) {
publication.pom.developers {
def myContacts = contactsPlugin.getAllContacts()
myContacts.each { Contact contact ->
developer {
if (contact.github) {
id = contact.github
} else if (contact.twitter) {
id = contact.twitter
}
if (contact.moniker) {
name = contact.moniker
}

email = contact.email
if (contact.roles) {
roles = contact.roles
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nebula.plugin.publishing.maven

import nebula.plugin.publishing.contacts.BaseContactPluginConfigurator
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPublication
Expand All @@ -30,37 +31,14 @@ class MavenDeveloperPlugin implements Plugin<Project> {
withType(MavenPublication) { publication ->
if (! project.state.executed) {
project.afterEvaluate {
configureContacts(contactsPlugin, publication)
BaseContactPluginConfigurator.configureContacts(contactsPlugin, publication)
}
} else {
configureContacts(contactsPlugin, publication)
BaseContactPluginConfigurator.configureContacts(contactsPlugin, publication)
}
}
}
}
}
}

private void configureContacts(contactsPlugin, MavenPublication publication) {
publication.pom.developers {
def myContacts = contactsPlugin.getAllContacts()
myContacts.each { contact ->
developer {
if (contact.github) {
id = contact.github
} else if (contact.twitter) {
id = contact.twitter
}
if (contact.moniker) {
name = contact.moniker
}

email = contact.email
if (contact.roles) {
roles = contact.roles
}
}
}
}
}
}

0 comments on commit 94af237

Please sign in to comment.