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

  • Home
  • SEARCH
  • 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 7607951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:47:48+00:00 2026-05-31T00:47:48+00:00

Im working on a large multi-module project which uses an internal framework as one

  • 0

Im working on a large multi-module project which uses an internal framework as one of its dependencies. The framework version is set in the top level pom at the beginning of a project, and has to stay constant. If any submodule uses a different version, I want the build to fail.

Ive tried declaring the dependency as a single version:

<dependency>
  <groupId>framework_snt</groupId>
  <artifactId>SFP</artifactId>
  <version>[6.1]</version>
  <type>pom</type>
</dependency>

Ive tried using the enforcer plugin with banned dependencies:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>1.0.1</version>
  <executions>
    <execution>
      <id>enforce-versions</id>
      <goals>
        <goal>enforce</goal>
      </goals>
      <configuration>
        <rules>
          <requireJavaVersion>
            <version>[1.6.0-21]</version>
          </requireJavaVersion>
          <requireMavenVersion>
            <version>[3.0.3]</version>
          </requireMavenVersion>
          <bannedDependencies>
            <excludes>
              <exclude>framework_snt:SFP</exclude>
            </excludes>
            <includes>
              <include>framework_snt:SFP:6.1.2</include>
            </includes>
          </bannedDependencies>
        </rules>
      </configuration>
    </execution>
  </executions>
</plugin>

Ive also tried adding the <DependencyConvergence/> tag as mentioned here, but none of these approaches work.

So given this top level pom fragment:

<project>
  <groupId>glb</groupId>
  <artifactId>GLB</artifactId>
  <packaging>pom</packaging>
  <name>Global</name>
  <version>1.0</version>
  ........
  <dependencies>
    <dependency>
      <groupId>framework_snt</groupId>
      <artifactId>SFP</artifactId>
      <version>[6.1.2]</version>
      <type>pom</type>
    </dependency>
  </dependencies>  
  .....
</project>

And this (invalid) submmodule:

<project>
  <groupId>glb</groupId>
  <artifactId>CORE</artifactId>
  <packaging>jar</packaging>
  <name>Core</name>
  <version>1.0</version>

  <parent>
    <groupId>glb</groupId>
    <artifactId>GLB</artifactId>
    <version>1.0</version>
  </parent>

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

how do I setup maven so the build will fail when using the child module above, but when I remove the tag <version>6.3</version> it succeeds (or I change the version to match the one from the top level pom?

  • 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-05-31T00:47:50+00:00Added an answer on May 31, 2026 at 12:47 am

    Well after much search and trying stuff with various plugins and getting nowhere, I decided to write my own plugin to do conflict checking. Using the dependency:tree plugin source as a base I wrote the following:

       /**
        * Walks the dependency tree looking for anything marked as a conflict, and fails the build if one is found
        * code ripped from the dependency:tree plugin
        *
        * @param rootNode
        * the dependency tree root node to check
        *
        */
       private void checkForConflicts( DependencyNode rootNode ) throws MojoExecutionException
       {
       StringWriter writer = new StringWriter();
       boolean conflicts=false;
    
       // build the tree
       DependencyNodeVisitor visitor = new SerializingDependencyNodeVisitor( writer, SerializingDependencyNodeVisitor.STANDARD_TOKENS);
       visitor = new BuildingDependencyNodeVisitor( visitor );
       rootNode.accept( visitor );
    
       getLog().debug("Root: "+rootNode.toNodeString() );
    
       DependencyNode node;
       Artifact actual, conflict;
       DependencyTreeInverseIterator iter = new DependencyTreeInverseIterator(rootNode);
       while (iter.hasNext() )
         {
          node = (DependencyNode)iter.next();
          if (node.getState() == DependencyNode.OMITTED_FOR_CONFLICT)
            {
             actual = node.getArtifact();
             conflict = node.getRelatedArtifact();
             getLog().debug("conflict node: " + node.toNodeString() );
             getLog().debug("conflict with: "+conflict.toString() );
    
             getLog().error(actual.getGroupId()+":"+actual.getArtifactId()+":"+actual.getType()+" Conflicting versions: "+actual.getVersion()+" and "+conflict.getVersion() );
             conflicts=true;
            }
         }
    
        if (conflicts)
          throw new MojoExecutionException( "version conflict detected");
       }
    

    You can call this from your existing plugin using the following:

    try
      {
       rootNode = dependencyTreeBuilder.buildDependencyTree( project, localRepository, artifactFactory, artifactMetadataSource, null, artifactCollector );
       checkForConflicts( rootNode );
      }
    catch ( DependencyTreeBuilderException e)
      {
       throw new MojoExecutionException( "Cannot build project dependency tree", e);
      }
    

    Then in your plugin pom.xml, include dependencies from the existing dependency plugin source and your good to go.

    This works for our project — but if anyone knows a cleaner or better way, please let me know.

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

Sidebar

Related Questions

I'm converting a large, multi-project CVS repository into Subversion using cvs2svn. It's working really
Currently I am working on a Large Scale Application which uses GWT with Hibenate.
We are working on a large project with a measure of new/modified GUI functionality.
I'm working with a large (270+ project) VS.Net solution. Yes, I know this is
I am working on a large C++ project in Visual Studio 2008, and there
I have a very old, very very large, fully working, C program which plays
I've moved all image resources in a large multi-project solution to a new project
I'm working in a multi-developer environment in Oracle with a large package. We have
We have a large, multi-module product we are writing in Flex 4.1 running on
I'm working on a large homework which implements the use of Threads and synchronized

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.