Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8499043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:33:50+00:00 2026-06-11T00:33:50+00:00

I’m having a hard time setting up a set of related maven projects with

  • 0

I’m having a hard time setting up a set of related maven projects with interdependencies between them.

Here’s my simplified case:

pom.xml     -- parent pom
\base\
    pom.xml
    src\main\java\Base.java     -- this is just a simple class
\derived\
    pom.xml
    src\main\java\Derived.java  -- this is a simple class that needs Base class to compile successfully, and has a main function

My goals are:

  1. be able to compile, on my machine, all projects:
    • i.e. mnv clean compile is successful in \
  2. be able to compile, on my machine, just one project:
    • i.e. mnv clean compile is successful in \base\ and \derived\ (though this may not work by design: Inter Project Dependencies in Maven)

      [edit: found the answer for this one: base needs to be published locally before derived in compiled: i.e. in \base, do mvn clean compile install instead of doing just doing mvn clean compile. Once this is done, doing mvn clean compile in \derived works fine. Still, it would be great to do this without touching global state, i.e. without having to install base — so if anyone knows a way of achieving this, please add it as an answer]
  3. be able to run derived project on my machine (mvn exec:run or equivalent) direcly from the source tree:
    • i.e. mvn exec:run in \derived\ should compile (if needed) and run the derived.jar
  4. the “shared component” use case: push the base artifact to the shared repository, where other people can consume it as a maven dependency (i.e. compile time dependency):
    • i.e. mvn clean compile ??? will push this to the shared repository specified in ~/.m2/config.xml
  5. the “image directory” use case: push the derived artifact and its depedencies to a local directory, where it can be run via “java -jar …” or it can exposed as an ftp/http share for other people to get it. I.e., use cases like those:
    • mvn clean compile ??? will push derived.jar and dependencies (like base.jar) to ~/.m2/maven.repo/…/derived or equivalent, and then I can cd ~/.m2/maven.repo/…/derived and run java -jar derived.jar to run it.
    • mvn clean compile ??? will push base.jar to ~/.m2/maven.repo/…/base (or derived.jar to its corresponding dir), which is already exposed as a download point via local web or ftp server.

How do I do the goals above?

Here’s the relevant section from parent pom:

...
<modelVersion>4.0.0</modelVersion>
<groupId>com.foo</groupId>
<artifactId>parentpom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>parentpom</name>

<modules>
    <module>base</module>
    <module>derived</module>
</modules>
...

Here’s the relevant section from base pom.xml:

...
<parent>
    <groupId>com.foo</groupId>
    <artifactId>parentpom</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.foo.base</groupId>
<artifactId>base</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>base</name>
...

Here’s the relevant section from derived pom.xml:

...
<parent>
    <groupId>com.foo</groupId>
    <artifactId>parentpom</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.foo.derived</groupId>
<artifactId>derived</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>derived</name>

<dependencies>
    <dependency>
        <groupId>com.foo</groupId>
        <artifactId>base</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>

...

Thank you in advance for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:33:51+00:00Added an answer on June 11, 2026 at 12:33 am

    Your parent pom looks good but your module/derived poms don’t: There are several issues which will produce some problems etc.

    First you are using different groupId’s for the derived/base module. If you have a multi-module build you shouldn’t do this. Furthermore, the version of derived/base is inherited by the parent and shouldn’t be set explicit which means you should have something like the following:

    <modelVersion>...</...>
    ...
    <parent>
        <groupId>com.foo</groupId>
        <artifactId>parentpom</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    
    <artifactId>base</artifactId>
    <packaging>jar</packaging>
    
    <name>base</name>
    

    The groupId is usually inherited. But sometimes you have a larger number of modules that may be sub-modules of sub-modules which results in a structure like this:

    +--- parent (pom.xml)
           +--- mod1 (pom.xml)
                  +--- mod11 (pom.xml)
                  +--- mod12 (pom.xml)
           +--- mod2 (pom.xml)
    

    In Such cases, the mod1 itself is a a pom packaging module:

    <modelVersion>...</...>
    ...
    <groupId>com.company.project<groupId>  
    <artifactId>parent</artifactId>
    <packaging>pom</packaging>
    <modules>
      <module>mod1</module>
      <module>mod2</module>
    </modules>
    

    mod1:

    <parent>
        <groupId>com.company.project<groupId>  
        <artifactId>parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    
    <groupId>com.company.project.mod1</groupId>
    <artifactId>mod1</artifactId>
    <packaging>pom</packaging>
    
    <modules>
      <module>mod11</module>
      <module>mod12</module>
    </modules>
    

    mod11:

    <parent>
        <groupId>com.company.project.mod1</groupId>
        <artifactId>mod1</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    
    <artifactId>mod11</artifactId>
    <packaging>pom</packaging>
    
    <modules>
      <module>mod11</module>
      <module>mod12</module>
    </modules>
    

    If you need to make a dependency between modules the solution is:

    <parent>
        <groupId>com.company.project.mod1</groupId>
        <artifactId>mod1</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    
    <artifactId>mod11</artifactId>
    <packaging>jar</packaging>
    
    <dependencies>
      <dependency>
        <!-- This shouldn't be a dep which is packaging: pom -->
        <groupId>${project.groupId}</groupId>
        <artifactId>mod2</artifactId>
        <version>${project.version}</version>
      </dependency>
    
    </dependencies>    
    

    To compile the whole project with all sub modules in one just go to parent folder and:

    mvn clean package

    will compile etc. If you like to compile only a single project you can do this by (from parent):

    mvn -pl mod1
    

    which will work only if you have installed the whole project once before. Another solution is:

    mvn -am -pl mod1
    

    To make the artifacts acessible for others the simplest solution is to install a repository manager and do:

    mvn deploy

    All others can use and artifact as a SNAPSHOT dependency.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.