Andrew
Andrew

Reputation: 2823

Maven JAR module depends on classes in WAR

I have an application which is packaged as a .war file. It has GWT code and a set of web-services.

I want to move the web-services code to a separate jar file, so the application can be build without them.

Services depend on code which is currently packaged into .war file, so in pom.xml for jar file I specify the following dependency:

<dependency>
    <groupId>my.group</groupId>
    <artifactId>my-war</artifactId>
    <version>1.0.4</version>
</dependency>

But to package the .war archive I also need to specify a dependency for the jar, like this:

<dependency>
    <groupId>my.group</groupId>
    <artifactId>my-services-jar</artifactId>
    <version>1.0.4</version>
    <scope>test</scope>
</dependency>

Which results in Circular Dependency.

How do I solve this? Or maybe I should follow a different approach? Thanks.

Upvotes: 2

Views: 815

Answers (1)

Biju Kunjummen
Biju Kunjummen

Reputation: 49935

Modularize a little more - introduce say a core jar with the dependencies common between my-war and my-services-jar and then your dependency structure will not have the circular dependency.

my-war
    - core-jar
my-services-jar
    - core-jar

Upvotes: 7

Related Questions