ccc
ccc

Reputation: 2385

Maven overlays and Eclipse

I have 2 Maven web projects A and B. B contains some common parts and A depends on B.

In A's pom.xml I have:

<dependencies>
    <dependency>
        <groupId>com.mygroup</groupId>
        <artifactId>B</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>war</type>
        <scope>compile</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
        </plugin>
    </plugins>
</build>

I have 2 problems:

  1. When making some changes in B, if I run a maven build on A I don't see the changes in the resulting exploded archive.

  2. Trying to deploy A from Eclipse does not work - the contents of B are not included in the resulting war/exploded archive.

Thanks for your help.

Upvotes: 1

Views: 2840

Answers (2)

Sri Sankaran
Sri Sankaran

Reputation: 8310

Amplifying @AndreiBodnarescu's point, you may not be seeing the changes you made to project-B when you build project-A because the changes aren't available in the Maven repository.

If project-B is being built on the same machine can you ensure that you used mvn install to install to your local repository? If project-B is being derived from a build on a different machine then use mvn deploy to deploy project-B to a common shared repository. In this case you may still not pick up project-B if you aren't using SNAPSHOTted versioning or you don't increment project-B's version number.

I see that B is of type war. What is the packaging of A? Is it an EAR? If so using the maven-war-plugin with project-A is not going to be of help.

Upvotes: 4

Shivan Dragon
Shivan Dragon

Reputation: 15219

Well, if you changes stuff in B, you have to re-install it into your local maven repo (mvn install) for other local projects that have it as dependency to receive the latest modifications.

When building a maven project it's best if you build it using Maven (like with commands such as mvn package) and not using some other building tool (such as Eclipse). If you wanna build it a la Maven but from the comfort of your Eclipse GUI, you can istall m2_eclipse plugin from :

http://m2eclipse.sonatype.org/installing-m2eclipse.html

which integrates Maven with Eclipse. Then, when you rigth click on your project in Eclipse, under the "Run..." options you'll have the one that allows your to Maven build it, redirecting all console output to the Eclipse console window.

And as a final note, in a setup such as the one aboce, ideally you'd create a parent Maven project (packaged as "pom") which has as child projects B and A (in that order). This way if you've modified stuff in both projects and you want everything to be build with the latest modifs, you can just do a maven install on the parent pom and Maven will take care of everything.

Upvotes: 4

Related Questions