Problems with Maven class orders

Does anyone know how to set a specific class path order in Maven2, and not the random ordering that I seem to be experiencing at the moment?

There are a number of legitimate reasons for this:

  • The supplier provided a patch patch that contains overriding classes for a previously released jar, and therefore the patch patch must first be displayed in sort order by class.
  • The two containers found in the class path discovered by crossing pom dependencies contain the same class in the same package with different values. For example:

jboss jbossall client 4.2.0.GA

org.hibernate winter 3.1

both contain: org.hibernate.util.ReflectHelper.class, but the getFastClass method is missing in the jbossall-client version.

From googling, I see that this is perhaps the point of contention between maven enthusiasts and the people facing this particular problem, but there are certainly legitimate reasons for organizing classes.

Any advice from anyone who solved this particular difficulty would be greatly appreciated!

thank

+38
classpath maven-2
Apr 27 '09 at 10:58
source share
2 answers

Starting with version 2.0.9, maven uses the pom order for the class path, so now you can manipulate it. We mainly suppress transient dependencies to external libraries, which we also include directly.

From the maven 2.0.9 release notes:

MNG-1412 / MNG-3111 introduced deterministic ordering of class path dependencies. Previously, natural ordering was used, which led to odd results. Now the order is saved from your pom, and the dependencies are added by the last addition. In assemblies with conflicting or duplicate dependencies, this can lead to a change in output. In short, if you have strange problems with 2.0.9, look at the dependencies to see if you have conflicts somewhere.

+36
Apr 27 '09 at 12:00
source share

Maven 2.0.9 adds the correct order, so you absolutely need this version or higher to work below.

Secondly, you need an updated plugin. The guys from Maven are working on a fix, fix it in their jail, but this is what I urgently need. So for now, I fixed it myself, and you can pull the Modified Plugin source code from github.

Edit: see http://jira.codehaus.org/browse/MECLIPSE-388

There are two ways to install it: either pull my modified code, or install it, or load a pre-assembled jar and just add it.

Build plugin

Run maven install from the plugin drop-down directory and add the following to your plugins section of your pom projects:

 <build> </plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.8-cpfix</version> </plugin> </plugins> </build> 

Download the jar

Alternatively, if you do not want to download and compile yourself, you can simply get the jar file and install it yourself.

After starting the file

 mvn install:install-file -Dfile=<path-to-file> -DgroupId=org.apache.maven.plugins \ -DartifactId=maven-eclipse-plugin -Dversion=2.8-cpfix -Dpackaging=jar 

Regardless of how you installed it now, when you run mvn eclipse:eclipse , it will pick up the modified code and order the dependencies based on the order you specified in the pom file, without alphabetical order. It also places the JRE container at the top of the dependencies.

I hope the real version of this code comes out soon, but at the same time, this fix worked for me in my project, and I hope it can help others.

+1
Jul 17 '10 at 17:06
source share



All Articles