nebula-plugins/nebula-publishing-plugin — pull request #4 by jmcgarr (2014-05-22 02:52:35+00:00)
Title: Add only one component to Maven publication

The current implementation of the NebulaMavenPublishingPlugin will try to add both the Java and Web components if the corresponding plugins are present. The DefaultMavenPublication class only allows one Component to be assign to a Publication. Without this change, adding both the NebulaMavenPublishingPlugin and the WarPlugin with throw the following exception:
```
Caused by:
org.gradle.api.InvalidUserDataException: Maven publication 'mavenJava' cannot include multiple components
at org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication.from(DefaultMavenPublication.java:86)
at nebula.plugin.publishing.maven.NebulaMavenPublishingPlugin.includeWarComponent_closure4(NebulaMavenPublishingPlugin.groovy:85)
at groovy.lang.Closure.call(Closure.java:412)
at groovy.lang.Closure.call(Closure.java:425)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
at org.gradle.api.internal.Actions$FilteredAction.execute(Actions.java:203)
at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:110)
at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:115)
at org.gradle.api.internal.DefaultDomainObjectCollection.withType(DefaultDomainObjectCollection.java:126)
at nebula.plugin.publishing.maven.NebulaBaseMavenPublishingPlugin.withMavenPublication_closure4_closure9(NebulaBaseMavenPublishingPlugin.groovy:74)
at groovy.lang.Closure.call(Closure.java:412)
at groovy.lang.Closure.call(Closure.java:425)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
at org.gradle.api.internal.Actions$FilteredAction.execute(Actions.java:203)
at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:110)
at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:115)
at org.gradle.api.internal.DefaultDomainObjectCollection.withType(DefaultDomainObjectCollection.java:126)
at nebula.plugin.publishing.maven.NebulaBaseMavenPublishingPlugin.withMavenPublication_closure4(NebulaBaseMavenPublishingPlugin.groovy:72)
at groovy.lang.Closure.call(Closure.java:412)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
... 4 more
```
I would love to take suggestions on a better way to remedy this issue. I intentionally put the if statement inside the closure so it would execute as late as possible.