Giter VIP home page Giter VIP logo

gradle-web-multiproject-sample's Introduction

gradle-web-multiproject-sample

This Gradle Project Constists 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:

Tomcat Deployment Folder

The following eclipse files are being generated by gradle

common/.classpath

the common-math 2.1 dependency is contained, which is correct for the common project in isolation

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="output" path="bin"/>
	<classpathentry kind="src" path="src/main/java"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/>
	<classpathentry sourcepath=".../commons-math-2.1-sources.jar" kind="lib" path=".../commons-math-2.1.jar" exported="true">
		<attributes>
			<attribute name="org.eclipse.jst.component.dependency" value="../"/>
		</attributes>
   </classpathentry>
</classpath>

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

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="2.0">
	<wb-module deploy-name="common">
		<wb-resource deploy-path="/" source-path="src/main/java"/>
	</wb-module>
</project-modules>

webapp/.classpath

the common project dependency is contained

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="output" path="bin"/>
	<classpathentry kind="src" path="src/main/java"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" exported="true"/>
	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container" exported="true"/>
	<classpathentry kind="src" path="/common" exported="true"/>
	<classpathentry sourcepath=".../commons-math-2.2-sources.jar" kind="lib" path=".../commons-math-2.2.jar" exported="true">
		<attributes>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
	<classpathentry sourcepath=".../servlet-api-2.5-sources.jar" kind="lib" path=".../servlet-api-2.5.jar" exported="true">
		<attributes>
			<attribute name="org.eclipse.jst.component.nondependency" value=""/>
		</attributes>
	</classpathentry>
</classpath>

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

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="2.0">
	<wb-module deploy-name="webapp">
		<property name="context-root" value="webapp"/>
		<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
		<wb-resource deploy-path="/" source-path="src/main/webapp"/>
		<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/common/common">
			<dependency-type>uses</dependency-type>
		</dependent-module>
		<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/.../commons-math-2.2.jar">
			<dependency-type>uses</dependency-type>
		</dependent-module>
	</wb-module>
</project-modules>

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:

<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/common/common">
	<dependency-type>uses</dependency-type>
</dependent-module>

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

gradle-web-multiproject-sample's People

Contributors

aconstantin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.