On 24/03/2011, at 10:36 PM, Rolf Suurd wrote:

> Hello, 
> 
> I have a project that consists of several subprojects. One of these 
> subprojects 
> uses the application plugin. I want to upload all archives to my nexus 
> repository, using the maven plugin.
> 
> Because the maven and application plugin do not play nice (due to both adding 
> an 
> 'install' task to the project, i decided to just let the root project have 
> the 
> maven plugin, and let it collect all jars for publishing.
> 
> Here's the relevant part of the build script of the rootProject:
> 
> // collect all artifacts here
> artifacts {
>    subprojects.each {project ->
>        project.tasks.withType(Jar).each {archiveTask ->
>            archives archiveTask
>        }
>    }
> }
> 
> uploadArchives {
>    def nexusRepositories = "http://172.20.2.2:8081/nexus/content/repositories";
> 
>    repositories.mavenDeployer {
>        //releases and snapshots are uploaded to different repos
>        repository(url: "${nexusRepositories}/releases") {
>            authentication(userName: "foo", password: "bar")
>        }
> 
>        snapshotRepository(url: "${nexusRepositories}/snapshots") {
>            authentication(userName: "foo", password: "bar")
>        }
> 
>        // because we deal with multiple artifacts in 1 project,
>        // add a filter for each single jar
>        subprojects.each { project ->
>            addFilter(project.name) {artifact, file ->
>                artifact.name == project.name
>            }
> 
>            // i'd love to do some pom configuration here, but then the
>            // subprojects would need the maven plugin
>        }
>    }
> }
> 
> My problem is (as pointed out in the build script) that i can't adjust the 
> poms 
> of the subproject, because that would require the maven plugin for those 
> subprojects, which would conflict with my subproject that uses the 
> application 
> plugin.
> 
> I suppose i could rename the "install" task of the application plugin to 
> "installApp" or something similar, but this would require me to build a 
> custom 
> version of gradle, and distribute it among all my teammembers.
> 
> Another option is to drop the application plugin, and define my own "run" and 
> "distZip" tasks, but maybe someone else knows a workaround?

Could you add a jira issue for this problem?

Here's a work around, but it isn't pretty:

apply plugin: 'maven'

Field storeField = 
org.gradle.api.internal.DefaultNamedDomainObjectContainer.class.getDeclaredField('store')
storeField.accessible = true
storeField.get(tasks).objects.remove('install')

apply plugin: 'application'


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
Co-Founder and VP of Engineering, Gradleware Inc. - Gradle Training, Support, 
Consulting
http://www.gradleware.com

Reply via email to