Question

I just finished converting one of our in-house framework projects from ant to maven. The maven build runs fine, and deploys to our repository with no issues.

The problem is when other projects try to consume the framework, it does not work. The only thing downloaded is top level framework pom.

I have tried adding some dependency entries to one or more of the various modules, but no matter which one I add, I get a circular dependency error. I also tried creating a 2nd top level pom file with no modules and a few dependencies to overwrite the one in the repository manager. This causes some of the dependencies to be downloaded, but then the maven build will hang in random places. based on windows task manager, it looks like its in an endless loop. So a 2nd pom file does not appear to be the answer (or im doing it wrong).

my framework pom file looks something like this:

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>framework_snt</groupId>
  <artifactId>SFP</artifactId>
  <packaging>pom</packaging>
  <name>SFP framework</name>
  <version>6.3</version>

  <modules>
.... 50+ modules here
  </modules>

and then the usual properties, dependency management and pluginManagement entries for a top level pom.

in the consuming module I just have the following:

<dependency>
  <groupId>framework_snt</groupId>
  <artifactId>SFP</artifactId>
  <version>6.3</version>
  <type>pom</type>
</dependency>

This is in the top level pom so all submodules have access to the framework libraries to make it easier on the developers.

How do I set things up so so all the dependent jar files will be downloaded by my consuming projects ?

Was it helpful?

Solution

It sounds like your framework project produces several jar artifacts, one for each child module, but no jar artifact for the parent project. Thus, declaring a dependency on the parent project's pom is not what you want to do. Instead you need to declare a dependency on each of your framework project's child modules.

I have a similar setup where I have a "toolkit" project with several modules (each producing a jar artifact). Then in my other projects I declare dependencies on whatever modules I need to use. I do not, however, declare a dependency on my "toolkit" parent projects pom file. Instead I just declare dependencies on the child modules jar artifacts.

<dependency>
  <groupId>com.mycompany.toolkits</groupId>
  <artifactId>file-utils</artifactId>
  <version>1.0.0</version>
</dependency>

Notice that my dependency declaration points to one of my child module's and does not declare <type>pom</type> like you did. If you wanted to be really explicit you could declare <type>jar</type> instead.

OTHER TIPS

The framework pom as you call it is the parent pom of your multi-module project.

While the modules can depend on each other, it cannot depend on this parent pom. This is what is possibly causing the circular dependency.

You will need to relook at your modules and identify which modules depend on which and suitably specify the dependencies. Also, these dependencies are typically jar dependencies - a packaging which will contain sources and resources.

Maven By Example is one of the many resources available which gives further information.

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