[GRADLE-687] Project dependency on a war project includes the war in the compile classpath, not the jar or classes Created: 09/Oct/09 Updated: 04/Jan/13 Resolved: 16/Oct/11 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 0.8 |
Fix Version/s: | 1.0-milestone-5 |
Type: | Bug | ||
Reporter: | Adam Murdoch | Assignee: | Adam Murdoch |
Resolution: | Fixed | Votes: | 10 |
Issue Links: |
|
Comments |
Comment by Thomas Glaeser [ 08/Mar/10 ] |
Hans - I was wondering if this could be added to one of the next 0.9 builds as I'm in desperate need of a solution for this issue. I also think that it should rather be implemented at the AbstractArchiveTask level and not for wars only. In my situation, which is kind of a legacy Java application, we produce a resulting zip artifact which has a code/classes directory containing the Java packages that are required by a dependent project. The zip artifact also contains a code/jars directory containing jar archives that should be added to the archive configuration as well. So it is very similar to the more standardized war bundling. What about if we don't have a project dependency to this type of artifact but a dependency to the artifact itself after uploading it into the repository? It probably doesn't make a difference, but we have written our own plugins and tasks and would need to access this functionality from within there only, not from the build.gradle. |
Comment by Michal Galet [ 25/May/11 ] |
Is there a workaround for this? |
Comment by Michal Galet [ 25/May/11 ] |
The workaround is already described in |
Comment by Scott Yancey [ 22/Jun/11 ] |
Is there any plan to address this completely? Meaning, a way to include the project simply in jar format only, without also pulling in the war? That workaround does "work," but the price is some serious bloat by having both the war and jar in the classpath. |
Comment by Spencer Allain [ 05/Jul/11 ] |
While not particularly pretty, and uses an internal api, this gets rid of the war file from the archives (and the classpath), so that normal dependencies work. import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact; Configuration archivesConfig = project.getConfigurations().getByName("archives") Task warTask = project.getTasks().getByName("war") for (PublishArtifact publishArtifact : archivesConfig.getAllArtifacts()) { if (publishArtifact instanceof ArchivePublishArtifact) { ArchivePublishArtifact archivePublishArtifact = (ArchivePublishArtifact)publishArtifact; if (archivePublishArtifact.getArchiveTask() == warTask) { archivesConfig.removeArtifact(publishArtifact); } } } You can also check the mailing list, where I describe this pattern, plus some additions that allow for easily wiring up multiple wars to one or more ears. http://markmail.org/message/retujvgi7jjmza73 -Spencer |