0

I have two Gradle projects, project A which is a war and project B which is a jar. Project A depends on project B. Project B has a compile dependency C. When I build project B the compile dependency C is not included in the generated jar which is what I expect. When I build project A project B is included in the lib directory of my war along with compile dependency C.

What I want is the output of the jar task for project B to be included in the lib directory of my war file, how can I do this? I've pasted the relevant fragments of my Gradle build file below.

project A

apply plugin: 'war'
dependencies {
   compile project(':B') 
}

project B

apply plugin: 'java'
dependencies {
   compile (group: 'org.apache.openejb', name: 'C', version: '5.0-3') 
}
Jared
  • 39,513
  • 29
  • 110
  • 145
  • I've got some troubles understanding what you mean. You say you get B in lib directory of the war. Then you say you want to have B in the lib directory of the war. It's not clear what is lacking. – thoredge Jul 07 '11 at 07:01

1 Answers1

0

Inside project A you can use providedCompile configuration to exclude some of the transitive dependecies from being included in WAR:

dependencies {
   compile project(':B') 
   providedCompile (group: 'org.apache.openejb', name: 'C', version: '5.0-3') 
}

You can read more about it in WAR plugin documentation.

Andrey Adamovich
  • 20,285
  • 14
  • 94
  • 132