When setting jgitver.resolve-project-version to true the properties in the pom file are rewritten but these are stored in a java.util.Properties which in turn is a java.util.Hashtable<Object,Object>. So when these properties are serialized to a new pom.xml file, the order of the properties is mixed up.
This can easily be fixed by using a custom Properties class which returns the key set as a TreeSet:
package fr.brouillard.oss.jgitver;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
class SortedProperties extends Properties {
public SortedProperties(Properties properties) {
properties.forEach((key, value) -> setProperty(key.toString(), value.toString()));
}
@Override
public Set<Object> keySet() {
return new TreeSet<>(super.keySet());
}
}
Use this class as properties for the model that is rewritten as the new pom.xml file. Insert at JGitverUtils:219:
That way, the properties are nicely sorted instead of being mixed up.
I'm not able to build the project myself because I get a [ERROR] java.lang.ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider when building with ./mvnw package. I installed it locally by building without tests and verified the result in a project.
When setting
jgitver.resolve-project-version
totrue
the properties in the pom file are rewritten but these are stored in ajava.util.Properties
which in turn is ajava.util.Hashtable<Object,Object>
. So when these properties are serialized to a new pom.xml file, the order of the properties is mixed up.This can easily be fixed by using a custom
Properties
class which returns the key set as aTreeSet
:Use this class as properties for the model that is rewritten as the new pom.xml file. Insert at JGitverUtils:219:
That way, the properties are nicely sorted instead of being mixed up.
I'm not able to build the project myself because I get a
[ERROR] java.lang.ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider
when building with ./mvnw package. I installed it locally by building without tests and verified the result in a project.