Question

I have an EJB/Web project that I have created with netbeans. I have created the project with netbeans so we would have a working prototype quickly. Now I'm converting this to Gradle. I'm using the ear plugin and my structur

-root
|-- ejb.jar
|-- web.war

is building. My dependencies are defined in the build.gradle file in each sub project (ejb and web). Now I want my dependencies to be in the ear/lib folder instead of being shatterd over the ejb/lib and web/lib folder. I know the concept of earlib dependencies, but I feel I do not need to specify this in my web and ejb project. Do I need to write an ant task to get this done or is there an elegant way. I'm trying to represent the netbeans build war as good as possible.

Was it helpful?

Solution

The proper solution is to manage the scope of your dependencies.

In the jar project, the dependencies are place in compile scope, this is ok, because a jar does not add the dependencies when packaging

In the war project, the dependencies are placed in providedCompile scope. This allows me to compile my war, but not to package my libaries.

In my root of my project I have my ear build file. In this build file I have re-added all the dependencies (this still feels wrong because I have defined my dependencies twice) with the earLib scope. By doing so, my dependencies are place in root of my project in my defined lib folder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top