Eclipse WTP Deployment - multiple versions of dependency gets deployed


(Alexander Constantin) #1

Hi everyone,

the complete description can be viewed here: https://github.com/signal7/gradle-web-multiproject-sample which functions as the sample project to reproduce the described problems.

This Gradle Project consists of two projects.

  • webapp produces a war - common produces a jar and is required by webapp

The Problem: =======

webapp requires ‘’’‘common-math 2.2’’’’ and common has an older version of that: ‘’’‘common-math 2.1’’’’

Gradle itself knows that common-math 2.2 overwrites 2.1

compile - Compile classpath for source set ‘main’.

±-- org.apache.commons:commons-math:2.2

±-- master:common:unspecified

|

— org.apache.commons:commons-math:2.1 -> 2.2

— javax.servlet:servlet-api:2.5

default - Configuration for default artifacts.

±-- org.apache.commons:commons-math:2.2

±-- master:common:unspecified

|

— org.apache.commons:commons-math:2.1 -> 2.2

— javax.servlet:servlet-api:2.5

providedCompile - Additional compile classpath for libraries that should not be part of the WAR archive.

— javax.servlet:servlet-api:2.5

providedRuntime - Additional runtime classpath for libraries that should not be part of the WAR archive.

— javax.servlet:servlet-api:2.5

runtime - Runtime classpath for source set ‘main’.

±-- org.apache.commons:commons-math:2.2

±-- master:common:unspecified

|

— org.apache.commons:commons-math:2.1 -> 2.2

— javax.servlet:servlet-api:2.5

But when gradle generates the eclipse files and you deploy the webapp to a tomcat in eclipse, the deployment folder looks like that:

The following eclipse files are being generated by gradle

common/.classpath: here, the ‘’’‘common-math 2.1’’’’ dependency is contained, which is correct for the common project in isolation

common/.settings/org.eclipse.wst.common.component

webapp/.classpath: the common project dependency is contained

webapp/.settings/org.eclipse.wst.common.component: the common project dependency is part of the component descriptor and therefor part of the deployment. the problem is here, that all transitive dependencies are part of the deployment as well. and so is ‘’’‘commons-math-2.1.jar’’’’

Conclusion ======= The generated files for the common project seems right, because the depending project needs to determine if some transitive dependencies should be excluded or not. For this case it seems, that the webapp/.settings/org.eclipse.wst.common.component file needs to exclude ‘’’‘commons-math-2.2’’’’ from the dependent module.

We are not sure, if there is a way to accomplish this.

Looking forward to any workarounds, discussion points and opinions on this issue.

best wishes,

max and alex