Including/excluding artifacts when a project depends on another

View: New views
3 Messages — Rating Filter:   Alert me  

Including/excluding artifacts when a project depends on another

by Rafael Serrano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I'm using gradle's multi-project builds in order to simplify several related projects, but I'm not guessing how to import / export artifacts among them.

My use case: I have two projects using the WAR plugin, and they work as consumer / producer. "Producer" is deployed as a WAR, but also generates a JAR used by "consumer". The problem is that depending on "Producer" means both on the JAR and the WAR, but I want to exclude the WAR. How can this be done?

Here are the two snippets of my build.gradle files (my master project does not declare any dependency):
build.gradle (remoteService)
...
jar.enabled = true
artifacts {
        archives jar
}

build.gradle (client)
...
compile project(':remoteService) {
        transitive = false
}

Thanks in advance. Regards
Rafa

Re: Including/excluding artifacts when a project depends on another

by Adam Murdoch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Rafael Serrano wrote:

> Hi all,
>
> I'm using gradle's multi-project builds in order to simplify several related
> projects, but I'm not guessing how to import / export artifacts among them.
>
> My use case: I have two projects using the WAR plugin, and they work as
> consumer / producer. "Producer" is deployed as a WAR, but also generates a
> JAR used by "consumer". The problem is that depending on "Producer" means
> both on the JAR and the WAR, but I want to exclude the WAR. How can this be
> done?
>
> Here are the two snippets of my build.gradle files (my master project does
> not declare any dependency):
> build.gradle (remoteService)
> ...
> jar.enabled = true
> artifacts {
> archives jar
> }
>
> build.gradle (client)
> ...
> compile project(':remoteService) {
> transitive = false
> }
>
> Thanks in advance. Regards
> Rafa
>  

There's a JIRA issue for this problem:
http://jira.codehaus.org/browse/GRADLE-687

One possible work around is to remove the war artifact from the archives
configuration:
remoteService/build.gradle

configurations.archives.artifacts.each {
  if (it.archiveTask == war) {
    configurations.archives.removeArtifact(it)
  }
}

jar.enabled = true
artifacts {
   archives jar
}


Another option is to use a different configuration for project dependencies:

configurations {
   projectDependency
   runtime {
        extendsFrom = [projectDependency] as Set
  }
}

jar.enabled = true
artifacts {
    projectDependency jar
}


--
Adam Murdoch
Gradle Developer
http://www.gradle.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Including/excluding artifacts when a project depends on another

by Rafael Serrano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the answer! I finally found another workaround, but anyway I expect this bug to be fixed ASAP since it makes working with gradle not as fun as it usually is :)

Regards
Rafa