[EMAIL PROTECTED] wrote:

I'm new to maven and I have a question regarding multiple projects and
how the can be linked.  I've created a "common code" project, and I
have another which depends upon this project.  I've got two
directories, two pom files, etc., and the common code project can
generate a jar file (mvn jar:jar).  The other project has a dependency
in the pom.xml file:

        <dependency>
                <groupId>com.x.common</groupId>
                <artifactId>x.common</artifactId>
                <version>0.0.1-SNAPSHOT</version>
        </dependency>
When the mvn process runs, it contacts the repositories and tries to
download this dependency, which will obviously fail.  How do I
configure mvn to look locally for a dependency, and in this case, run
mvn jar:jar in the common project directory to obtain the required
jar?

It depends on how you want to structure your code.

If the common code is likely to follow it's own release cycle, make a formal release of the common code, and then make your code depend on that formal release. Don't do this manually, use the release plugin to do this for you.

If the common code is likely to change alongside the other code, you might choose to build and release all the jars together in one go.

What you want to do is create a multi-module project by creating a parent pom project, and add each of the multi modules as children of this parent, using the <module> element in the pom. In each child project, add the <parent> tag pointing back to the parent pom.

When you build the parent, all the modules listed within the parent will be built.

If your dependencies are configured correctly, maven will figure out for itself what order things should be built in.

Hint: in your children projects, make them inherit the parent's version by putting in ${pom.version} as a variable. For example:

         <dependency>
                 <groupId>com.x.common</groupId>
                 <artifactId>x.common</artifactId>
                 <version>${pom.version}</version>
         </dependency>

When you release the parent, the children will be released and versioned automatically.

Regards,
Graham
--

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to