[Git][java-team/maven-repo-helper][master] 7 commits: Removed the noParent variables in POMTransformerTest
Emmanuel Bourg
gitlab at salsa.debian.org
Wed Aug 7 23:28:50 BST 2019
Emmanuel Bourg pushed to branch master at Debian Java Maintainers / maven-repo-helper
Commits:
5873b80c by Emmanuel Bourg at 2019-08-07T15:56:11Z
Removed the noParent variables in POMTransformerTest
- - - - -
95528fc4 by Emmanuel Bourg at 2019-08-07T15:56:58Z
Improved the error message when a test resource isn't found
- - - - -
63b04aa5 by Emmanuel Bourg at 2019-08-07T17:44:41Z
Switched to Java 7 and updated the syntax
- - - - -
4ac9814e by Emmanuel Bourg at 2019-08-07T17:44:54Z
Removed the noParent variables in POMCleanerTest
- - - - -
6b40d231 by Emmanuel Bourg at 2019-08-07T17:44:55Z
Removed the Strings.propertyLine() method
- - - - -
9aa18036 by Emmanuel Bourg at 2019-08-07T17:44:55Z
Fixed the parsing of substvars files when the variable's names contain ':'
- - - - -
f2deb8d9 by Emmanuel Bourg at 2019-08-07T17:44:56Z
Added a unit test for Substvars.write()
- - - - -
23 changed files:
- debian/changelog
- debian/control
- pom.xml
- src/main/java/org/debian/maven/cliargs/ArgumentsMap.java
- src/main/java/org/debian/maven/repo/Dependency.java
- src/main/java/org/debian/maven/repo/DependencyRuleSet.java
- src/main/java/org/debian/maven/repo/ListOfPOMs.java
- src/main/java/org/debian/maven/repo/POMCleaner.java
- src/main/java/org/debian/maven/repo/POMInfo.java
- src/main/java/org/debian/maven/repo/POMOptions.java
- src/main/java/org/debian/maven/repo/POMReader.java
- src/main/java/org/debian/maven/repo/POMTransformer.java
- src/main/java/org/debian/maven/repo/Repository.java
- src/main/java/org/debian/maven/repo/Substvars.java
- src/main/java/org/debian/maven/repo/TreePath.java
- src/main/java/org/debian/maven/util/Strings.java
- src/test/java/org/debian/maven/TemporaryPomFolder.java
- src/test/java/org/debian/maven/repo/ListOfPOMsTest.java
- src/test/java/org/debian/maven/repo/POMCleanerTest.java
- src/test/java/org/debian/maven/repo/POMTransformerTest.java
- + src/test/java/org/debian/maven/repo/SubstvarsTest.java
- src/test/java/org/debian/maven/repo/TreePathTest.java
- + src/test/resources/libcommons-compress-java.substvars
Changes:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+maven-repo-helper (1.9.4) UNRELEASED; urgency=medium
+
+ * Team upload.
+ * Require Java 7 or higher
+ * Fixed the parsing of substvars files when the variable's names contain ":"
+
+ -- Emmanuel Bourg <ebourg at apache.org> Wed, 07 Aug 2019 18:17:46 +0200
+
maven-repo-helper (1.9.3) unstable; urgency=medium
* Team upload.
=====================================
debian/control
=====================================
@@ -10,7 +10,7 @@ Build-Depends:
ant-optional,
cdbs,
debhelper (>= 10),
- default-jdk,
+ default-jdk (>= 2:1.7),
help2man,
junit4,
libcommons-io-java,
@@ -23,7 +23,7 @@ Homepage: https://wiki.debian.org/Java/MavenRepoSpec
Package: maven-repo-helper
Architecture: all
-Depends: ${misc:Depends}, default-jre-headless (>= 1:1.6) | java6-runtime-headless
+Depends: ${misc:Depends}, default-jre-headless (>= 2:1.7) | java7-runtime-headless
Recommends: debhelper (>= 10)
Suggests: maven-debian-helper
Breaks: maven-debian-helper (<= 1.6.6)
=====================================
pom.xml
=====================================
@@ -53,8 +53,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>7</source>
+ <target>7</target>
</configuration>
</plugin>
<plugin>
=====================================
src/main/java/org/debian/maven/cliargs/ArgumentsMap.java
=====================================
@@ -11,9 +11,9 @@ import java.util.Map;
public class ArgumentsMap {
private static final List<String> EMPTY_LIST = Collections.emptyList();
- private final Map<String, List<String>> longMap = new HashMap<String, List<String>>();
- private final Map<String, List<String>> shortMap = new HashMap<String, List<String>>();
- private final List<String> args = new ArrayList<String>();
+ private final Map<String, List<String>> longMap = new HashMap<>();
+ private final Map<String, List<String>> shortMap = new HashMap<>();
+ private final List<String> args = new ArrayList<>();
public ArgumentsMap(final ArgumentsIterable arguments) {
for (Argument argument : arguments) {
@@ -83,7 +83,7 @@ public class ArgumentsMap {
}
public List<String> getValueList(String longName, String shortName) {
- List<String> result = new ArrayList<String>();
+ List<String> result = new ArrayList<>();
result.addAll(getAllValues(longMap, longName));
result.addAll(getAllValues(shortMap, shortName));
return result;
=====================================
src/main/java/org/debian/maven/repo/Dependency.java
=====================================
@@ -326,7 +326,7 @@ public class Dependency implements Comparable<Dependency>, Cloneable {
if (dependencies == null) {
return null;
}
- List<Dependency> result = new ArrayList<Dependency>();
+ List<Dependency> result = new ArrayList<>();
for (Dependency dependency: dependencies) {
result.add(dependency.applyRules(rules));
}
@@ -337,7 +337,7 @@ public class Dependency implements Comparable<Dependency>, Cloneable {
if (dependencies == null) {
return null;
}
- List<Dependency> result = new ArrayList<Dependency>();
+ List<Dependency> result = new ArrayList<>();
for (Dependency dependency: dependencies) {
if (dependency.findMatchingRule(ignoreRules) == null) {
result.add(new Dependency(dependency));
@@ -435,7 +435,7 @@ public class Dependency implements Comparable<Dependency>, Cloneable {
public final static Map<String, Field> map;
static {
- map = new HashMap<String, Field>();
+ map = new HashMap<>();
for(Field field : Field.values()) {
map.put(field.TAG, field);
}
=====================================
src/main/java/org/debian/maven/repo/DependencyRuleSet.java
=====================================
@@ -86,7 +86,7 @@ public class DependencyRuleSet implements Iterable<DependencyRule> {
}
public Set<DependencyRule> findMatchingRules(Dependency dependency) {
- Set<DependencyRule> matchingRules = new HashSet<DependencyRule>();
+ Set<DependencyRule> matchingRules = new HashSet<>();
for (DependencyRule rule : rules) {
if (rule.matches(dependency)) {
matchingRules.add(rule);
=====================================
src/main/java/org/debian/maven/repo/ListOfPOMs.java
=====================================
@@ -194,7 +194,7 @@ public class ListOfPOMs {
return;
}
- pomOptions = new LinkedHashMap<String, POMOptions>();
+ pomOptions = new LinkedHashMap<>();
if (poms == null || !poms.exists()) {
return;
=====================================
src/main/java/org/debian/maven/repo/POMCleaner.java
=====================================
@@ -43,7 +43,7 @@ public class POMCleaner extends POMTransformer {
"parent", "licenses", "scm", "developers", "contributors", "issueManagement",
"mailingLists", "inceptionYear", "url", "organization");
private boolean keepAllElements = false;
- private Collection<String> keepElements = new ArrayList<String>();
+ private Collection<String> keepElements = new ArrayList<>();
public POMCleaner() {
}
@@ -85,10 +85,8 @@ public class POMCleaner extends POMTransformer {
pomProps.store(pomWriter, "POM properties");
pomWriter.close();
- } catch (IOException ex) {
- log.log(Level.SEVERE, null, ex);
- } catch (XMLStreamException ex) {
- log.log(Level.SEVERE, null, ex);
+ } catch (IOException | XMLStreamException e) {
+ log.log(Level.SEVERE, null, e);
}
}
@@ -268,10 +266,10 @@ public class POMCleaner extends POMTransformer {
File rulesFile = null;
File publishedRulesFile = null;
File mavenRepo = null;
- List<String> rulesExtra = new ArrayList<String>();
- List<String> publishedRulesExtra = new ArrayList<String>();
- List<String> ignoreRulesExtra = new ArrayList<String>();
- List<File> ignoreRulesFiles = new ArrayList<File>();
+ List<String> rulesExtra = new ArrayList<>();
+ List<String> publishedRulesExtra = new ArrayList<>();
+ List<String> ignoreRulesExtra = new ArrayList<>();
+ List<File> ignoreRulesFiles = new ArrayList<>();
while (i < args.length && (args[i].trim().startsWith("-") || args[i].trim().length() == 0)) {
String arg = args[i].trim();
if ("--verbose".equals(arg) || "-v".equals(arg)) {
=====================================
src/main/java/org/debian/maven/repo/POMInfo.java
=====================================
@@ -86,11 +86,11 @@ public class POMInfo implements Cloneable {
}
public void setProperties(Map<String, String> properties) {
- this.properties = new TreeMap<String, String>(properties);
+ this.properties = new TreeMap<>(properties);
}
public Set<DependencyRule> getPublishedRules() {
- Set<DependencyRule> rules = new TreeSet<DependencyRule>();
+ Set<DependencyRule> rules = new TreeSet<>();
if (getProperties() == null) {
return rules;
}
@@ -125,13 +125,13 @@ public class POMInfo implements Cloneable {
result.setOriginalPom(getThisPom());
result.setThisPom(getThisPom().applyRules(rules));
- Map<DependencyType, List<Dependency>> dependencies = new EnumMap<DependencyType, List<Dependency>>(DependencyType.class);
+ Map<DependencyType, List<Dependency>> dependencies = new EnumMap<>(DependencyType.class);
for(DependencyType depType : DependencyType.values()) {
dependencies.put(depType, Dependency.applyRules(this.dependencies.get(depType), rules));
}
result.setDependencies(dependencies);
- result.setProperties(new TreeMap<String, String>(getProperties()));
+ result.setProperties(new TreeMap<>(getProperties()));
result.setModules(getModules());
result.setParent(getParent());
@@ -259,7 +259,7 @@ public class POMInfo implements Cloneable {
}
public static Map<DependencyType, List<Dependency>> initDependenciesMultiMap() {
- Map<DependencyType, List<Dependency>> dependencies = new EnumMap<DependencyType, List<Dependency>>(DependencyType.class);
+ Map<DependencyType, List<Dependency>> dependencies = new EnumMap<>(DependencyType.class);
for (DependencyType depType : DependencyType.values()) {
dependencies.put(depType, new ArrayList<Dependency>());
}
@@ -285,7 +285,7 @@ public class POMInfo implements Cloneable {
EXTENSIONS("extension");
- private static final Map<String, DependencyType> byPatternMap = new HashMap<String, DependencyType>();
+ private static final Map<String, DependencyType> byPatternMap = new HashMap<>();
static {
for(DependencyType type : values()) {
byPatternMap.put(type.pattern, type);
=====================================
src/main/java/org/debian/maven/repo/POMOptions.java
=====================================
@@ -167,7 +167,7 @@ public class POMOptions {
}
public List<Dependency> getRelocatedArtifacts() {
- List<Dependency> artifacts = new ArrayList<Dependency>();
+ List<Dependency> artifacts = new ArrayList<>();
if (relocate != null) {
for (String element : relocate.split(",")) {
String[] coordinates = element.split(":");
=====================================
src/main/java/org/debian/maven/repo/POMReader.java
=====================================
@@ -61,14 +61,14 @@ public class POMReader {
XMLStreamReader parser = factory.createXMLStreamReader(new BufferedReader(originalPom));
// Stack of the XML path currently parsed. Most deepest XML element is first in the list.
- TreePath<String> path = new TreePath<String>();
+ TreePath<String> path = new TreePath<>();
// http://maven.apache.org/pom.html#Aggregation:
// "the ordering of the modules [...] is not important"
// However the POMTransformer depends on the ordering...
- List<String> modules = new ArrayList<String>();
+ List<String> modules = new ArrayList<>();
- Map<String, String> properties = new TreeMap<String, String>();
+ Map<String, String> properties = new TreeMap<>();
Map<DependencyType, List<Dependency>> dependencies = POMInfo.initDependenciesMultiMap();
Dependency thisPom = new Dependency(Dependency.PROTO_JAR);
Dependency parent = null;
@@ -181,7 +181,7 @@ public class POMReader {
thisPom.setVersion(parent.getVersion());
}
- Map<String, String> inferedProperties = new TreeMap<String, String>(properties);
+ Map<String, String> inferedProperties = new TreeMap<>(properties);
inferedProperties.put("pom.groupId", thisPom.getGroupId());
inferedProperties.put("project.groupId", thisPom.getGroupId());
=====================================
src/main/java/org/debian/maven/repo/POMTransformer.java
=====================================
@@ -54,7 +54,7 @@ public class POMTransformer extends POMReader {
private static final List<String> DEBIAN_DOC_IGNORED_ELEMENTS = Arrays.asList("reports", "reporting", "site");
private static final List<String> INFO_ELEMENTS = Arrays.asList("groupId", "artifactId", "packaging", "version");
private DependencyRuleSetFiles depRules = new DependencyRuleSetFiles();
- private Map<File, Set<String>> ignoredModules = new HashMap<File, Set<String>>();
+ private Map<File, Set<String>> ignoredModules = new HashMap<>();
private Repository repository;
private boolean verbose;
private boolean isDebianBuild;
@@ -136,7 +136,7 @@ public class POMTransformer extends POMReader {
pomFile = pomFile.getAbsoluteFile();
Set<String> modules = ignoredModules.get(pomFile);
if (modules == null) {
- modules = new HashSet<String>();
+ modules = new HashSet<>();
ignoredModules.put(pomFile, modules);
}
modules.add(module);
@@ -235,7 +235,7 @@ public class POMTransformer extends POMReader {
+ original.getParent().getArtifactId() + " * * * *"));
}
- Set<DependencyRule> allRules = new TreeSet<DependencyRule>(depRules.get(RULES).getRules());
+ Set<DependencyRule> allRules = new TreeSet<>(depRules.get(RULES).getRules());
allRules.addAll(depRules.get(AUTOMATIC).getRules());
POMInfo info = original.newPOMFromRules(allRules, repository);
if (hasPackageVersion) {
@@ -260,7 +260,7 @@ public class POMTransformer extends POMReader {
// Second pass - create the new document
// Stack of the XML path currently parsed. Most deepest XML element is first in the list.
- TreePath<String> path = new TreePath<String>();
+ TreePath<String> path = new TreePath<>();
int inIgnoredElement = 0;
int inCopyOnlyElement = 0;
int inDependency = 0;
@@ -271,9 +271,9 @@ public class POMTransformer extends POMReader {
boolean sawVersion = false;
List<Dependency> dependencyList = null;
int dependencyIndex = -1;
- Map<DependencyType, Integer> dependencyIndexes = new HashMap<DependencyType, Integer>();
+ Map<DependencyType, Integer> dependencyIndexes = new HashMap<>();
int moduleDependencyIndex = 0;
- Set<String> visitedProperties = new HashSet<String>();
+ Set<String> visitedProperties = new HashSet<>();
Dependency dependency = null;
Dependency parentDependency = null;
String element = null;
=====================================
src/main/java/org/debian/maven/repo/Repository.java
=====================================
@@ -49,19 +49,19 @@ public class Repository {
/** The base directory of the repository typically (/usr/share/maven-repo) */
private File baseDir;
- private Map<File, POMInfo> unresolvedPoms = new HashMap<File, POMInfo>();
+ private Map<File, POMInfo> unresolvedPoms = new HashMap<>();
/** The dependency (groupId+artifactId+version+type) to pom mapping */
- private Map<Dependency, POMInfo> dep2info = new HashMap<Dependency, POMInfo>();
+ private Map<Dependency, POMInfo> dep2info = new HashMap<>();
/** The pom files specifying a parent pom not found in the repository */
- private Map<File, POMInfo> pomsWithMissingParent = new HashMap<File, POMInfo>();
+ private Map<File, POMInfo> pomsWithMissingParent = new HashMap<>();
/** The pom files specifying a plugin or a dependency without version */
- private Map<File, POMInfo> pomsWithMissingVersions = new HashMap<File, POMInfo>();
+ private Map<File, POMInfo> pomsWithMissingVersions = new HashMap<>();
/** The resolved poms, that is the poms with a resolved parent */
- private Map<File, POMInfo> resolvedPoms = new HashMap<File, POMInfo>();
+ private Map<File, POMInfo> resolvedPoms = new HashMap<>();
/** The Maven super pom defining the default plugins */
private POMInfo superPom;
@@ -131,7 +131,7 @@ public class Repository {
}
protected List<POMInfo> getAllPoms() {
- List<POMInfo> allPoms = new ArrayList<POMInfo>(resolvedPoms.values());
+ List<POMInfo> allPoms = new ArrayList<>(resolvedPoms.values());
allPoms.addAll(unresolvedPoms.values());
return allPoms;
}
@@ -151,7 +151,7 @@ public class Repository {
return pom;
}
- Map<DependencyRule, POMInfo> potentialMatches = new TreeMap<DependencyRule, POMInfo>();
+ Map<DependencyRule, POMInfo> potentialMatches = new TreeMap<>();
for (POMInfo testPom : getAllPoms()) {
Set<DependencyRule> rules = testPom.getPublishedRules();
rules.add(MAVEN_PLUGINS_KEEP_VERSION_RULE);
@@ -171,7 +171,7 @@ public class Repository {
}
public List<POMInfo> searchMatchingPOMsIgnoreVersion(Dependency dependency) {
- List<POMInfo> result = new ArrayList<POMInfo>();
+ List<POMInfo> result = new ArrayList<>();
POMInfo pom = searchMatchingPOM(dependency);
if (pom != null) {
result.add(pom);
@@ -257,8 +257,8 @@ public class Repository {
writer.printSectionEnd();
}
- Set<String> issues = new TreeSet<String>();
- Map<File, List<Dependency>> pomsWithIssues = new HashMap<File, List<Dependency>>();
+ Set<String> issues = new TreeSet<>();
+ Map<File, List<Dependency>> pomsWithIssues = new HashMap<>();
for (Entry<File, POMInfo> entry : resolvedPoms.entrySet()) {
File pom = entry.getKey();
POMInfo pomInfo = entry.getValue();
@@ -273,7 +273,7 @@ public class Repository {
issues.add("Unpackaged dependency: " + dependency + " in " + pom);
List<Dependency> pomIssues = pomsWithIssues.get(pom);
if (pomIssues == null) {
- pomIssues = new ArrayList<Dependency>();
+ pomIssues = new ArrayList<>();
pomsWithIssues.put(pom, pomIssues);
}
pomIssues.add(dependency);
@@ -284,7 +284,7 @@ public class Repository {
issues.add("Unpackaged plugin: " + dependency + " in " + pom);
List<Dependency> pomIssues = pomsWithIssues.get(pom);
if (pomIssues == null) {
- pomIssues = new ArrayList<Dependency>();
+ pomIssues = new ArrayList<>();
pomsWithIssues.put(pom, pomIssues);
}
pomIssues.add(dependency);
@@ -300,14 +300,14 @@ public class Repository {
writer.printSectionEnd();
// Find the poms with most issues
- Map<Integer, List<File>> pomsWithNumberOfIssues = new TreeMap<Integer, List<File>>(Collections.reverseOrder());
+ Map<Integer, List<File>> pomsWithNumberOfIssues = new TreeMap<>(Collections.reverseOrder());
for (Entry<File, List<Dependency>> entry : pomsWithIssues.entrySet()) {
File pom = entry.getKey();
List<Dependency> missingDeps = entry.getValue();
int count = missingDeps.size();
List<File> orderedPoms = pomsWithNumberOfIssues.get(count);
if (orderedPoms == null) {
- orderedPoms = new ArrayList<File>();
+ orderedPoms = new ArrayList<>();
pomsWithNumberOfIssues.put(count, orderedPoms);
}
orderedPoms.add(pom);
@@ -332,7 +332,7 @@ public class Repository {
}
// Find the dependencies that need packaging most
- Map<Dependency, Integer> missingDependenciesCounts = new HashMap<Dependency, Integer>();
+ Map<Dependency, Integer> missingDependenciesCounts = new HashMap<>();
for (Entry<File, List<Dependency>> entry : pomsWithIssues.entrySet()) {
List<Dependency> missingDeps = entry.getValue();
for (Dependency missingDependency : missingDeps) {
@@ -343,7 +343,7 @@ public class Repository {
missingDependenciesCounts.put(missingDependency, lastCount + 1);
}
}
- List<Map.Entry<Dependency, Integer>> missingDependenciesCountList = new ArrayList<Map.Entry<Dependency, Integer>>(missingDependenciesCounts.entrySet());
+ List<Map.Entry<Dependency, Integer>> missingDependenciesCountList = new ArrayList<>(missingDependenciesCounts.entrySet());
Collections.sort(missingDependenciesCountList, new Comparator<Map.Entry<Dependency, Integer>>() {
public int compare(Map.Entry<Dependency, Integer> entry1, Map.Entry<Dependency, Integer> entry2) {
@@ -370,7 +370,7 @@ public class Repository {
private void resolveAll(Map<File, POMInfo> file2pom) {
// copy to avoid concurrent modifications
- Map<File, POMInfo> copy = new HashMap<File, POMInfo>(file2pom);
+ Map<File, POMInfo> copy = new HashMap<>(file2pom);
for (Entry<File, POMInfo> entry : copy.entrySet()) {
try {
registerPom(entry.getKey(), entry.getValue());
=====================================
src/main/java/org/debian/maven/repo/Substvars.java
=====================================
@@ -1,5 +1,6 @@
package org.debian.maven.repo;
+import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
@@ -9,8 +10,6 @@ import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.debian.maven.util.Strings;
-
public class Substvars {
private static final Logger log = Logger.getLogger(Substvars.class.getName());
@@ -23,8 +22,16 @@ public class Substvars {
File substvarsFile = Substvars.substvarsFile(outputDirectory, packageName);
Properties depVars = new Properties();
if (substvarsFile.exists()) {
- try {
- depVars.load(new FileReader(substvarsFile));
+ try (BufferedReader in = new BufferedReader(new FileReader(substvarsFile))) {
+ String line;
+ while ((line = in.readLine()) != null) {
+ if (!line.startsWith("#")) {
+ int pos = line.indexOf("=");
+ String key = line.substring(0, pos).trim();
+ String value = line.substring(pos + 1).trim();
+ depVars.setProperty(key, value);
+ }
+ }
} catch (IOException ex) {
log.log(Level.SEVERE, "Error while reading file " + substvarsFile, ex);
}
@@ -39,7 +46,7 @@ public class Substvars {
out.write("#List of dependencies for " + packageName + ", generated for use by debian/control\n");
for (String propName : substvars.stringPropertyNames()) {
- out.write(Strings.propertyLine(propName, substvars.get(propName).toString()));
+ out.write(propName + "=" + substvars.get(propName) + "\n");
}
out.close();
} catch (IOException ex) {
=====================================
src/main/java/org/debian/maven/repo/TreePath.java
=====================================
@@ -25,7 +25,7 @@ import java.util.LinkedList;
*/
class TreePath<S> {
- private LinkedList<S> path = new LinkedList<S>();
+ private LinkedList<S> path = new LinkedList<>();
/**
* Appends an element to the path.
=====================================
src/main/java/org/debian/maven/util/Strings.java
=====================================
@@ -30,18 +30,4 @@ public class Strings {
}
return sb.toString();
}
-
- /**
- * Format a line feed terminated property line for a java properties file.
- *
- * e.g.: mypropertyname=mypropertyvalue\n
- */
- public static String propertyLine(String name, String value) {
- StringBuilder sb = new StringBuilder(name.length() + value.length() + 2);
- sb.append(name);
- sb.append("=");
- sb.append(value);
- sb.append("\n");
- return sb.toString();
- }
}
=====================================
src/test/java/org/debian/maven/TemporaryPomFolder.java
=====================================
@@ -26,6 +26,9 @@ public class TemporaryPomFolder extends TemporaryFolder {
public File copyResource(String resource, File file) throws IOException {
InputStream in = this.getClass().getResourceAsStream("/" + resource);
+ if (in == null) {
+ throw new IOException("Test resource not found: " + resource);
+ }
FileOutputStream out = new FileOutputStream(file);
IOUtils.copy(in, out);
in.close();
@@ -40,7 +43,11 @@ public class TemporaryPomFolder extends TemporaryFolder {
}
public Reader read(String resource) throws IOException {
- Reader r = Readers.read(this.getClass().getResourceAsStream("/" + resource));
+ InputStream in = this.getClass().getResourceAsStream("/" + resource);
+ if (in == null) {
+ throw new IOException("Test resource not found: " + resource);
+ }
+ Reader r = Readers.read(in);
openedReaders.add(r);
return r;
}
=====================================
src/test/java/org/debian/maven/repo/ListOfPOMsTest.java
=====================================
@@ -86,8 +86,8 @@ public class ListOfPOMsTest {
public void testForeachPom() {
ListOfPOMs poms = new ListOfPOMs(TemporaryPomFolder.getFileInClasspath("libplexus-components-java.poms"));
- final List<File> pomFiles = new ArrayList<File>();
- final List<File> ignoredPomFiles = new ArrayList<File>();
+ final List<File> pomFiles = new ArrayList<>();
+ final List<File> ignoredPomFiles = new ArrayList<>();
poms.foreachPoms(new POMHandler() {
@Override
=====================================
src/test/java/org/debian/maven/repo/POMCleanerTest.java
=====================================
@@ -54,10 +54,9 @@ public class POMCleanerTest {
public void testCleanMavenPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("maven.xml");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus-container-default jar s/1\\.0-alpha-.*/1.0-alpha/"));
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "maven2");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, true, true, false, false, null, "maven2");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -72,9 +71,8 @@ public class POMCleanerTest {
public void testCleanModelloPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("modello-core.xml");
- boolean noParent = false;
instance.getRulesFiles().addDefaultRules();
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libmodello-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, false, true, false, false, null, "libmodello-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -84,7 +82,7 @@ public class POMCleanerTest {
assertEquals("1.0-alpha-22", pomInfo.get("version"));
assertEquals("debian", pomInfo.get("debianVersion"));
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, false, true, true, null, "libmodello-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, false, false, true, true, null, "libmodello-java");
assertXMLEqual(tmpDir.read("modello-core.keep.cleaned"), tmpDir.read(tmpDir.updatedPom()));
pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -100,9 +98,8 @@ public class POMCleanerTest {
public void testCleanWagonPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("wagon-http-lightweight.xml");
- boolean noParent = false;
instance.getRulesFiles().addDefaultRules();
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libwagon-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, false, true, false, false, null, "libwagon-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -117,10 +114,9 @@ public class POMCleanerTest {
public void testCleanPlexusContainerDefaultPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("plexus-container-default.xml");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus-container-default jar s/1\\.0-alpha-.*/1.0-alpha/"));
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libplexus-container-default-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, true, true, false, false, null, "libplexus-container-default-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -135,12 +131,11 @@ public class POMCleanerTest {
public void testCleanPlexusActiveCollectionsPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("plexus-active-collections.pom");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("junit junit jar s/3\\..*/3.x/"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus-container-default jar s/1\\.0-alpha.*/1.0-alpha/"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus-maven-plugin maven-plugin s/.*/1.3.8/"));
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libplexus-active-collections-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, true, true, false, false, null, "libplexus-active-collections-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -155,9 +150,8 @@ public class POMCleanerTest {
public void testCleanPlexusArchiverPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("plexus-archiver.pom");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libplexus-archiver-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, true, true, false, false, null, "libplexus-archiver-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -172,9 +166,8 @@ public class POMCleanerTest {
public void testCleanSlf4jPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("slf4j.xml");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libslf4j-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, true, true, false, false, null, "libslf4j-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -189,10 +182,9 @@ public class POMCleanerTest {
public void testCleanCommonsValidatorPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("commons-validator.xml");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("junit junit jar s/3\\..*/3.x/"));
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libcommons-validator-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, true, true, false, false, null, "libcommons-validator-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -207,10 +199,9 @@ public class POMCleanerTest {
public void testCleanServletApiPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("servlet-api.pom");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("s/org.apache.tomcat/javax.servlet/ servlet-api jar s/.*/2.5/"));
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libservlet2.5-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, true, true, false, false, null, "libservlet2.5-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -225,11 +216,10 @@ public class POMCleanerTest {
public void testCleanHibernateValidatorParentPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("hibernate-validator-parent.pom");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(IGNORE).add(new DependencyRule("org.apache.maven.wagon wagon-webdav jar *"));
instance.getRulesFiles().get(IGNORE).add(new DependencyRule("org.jboss.maven.plugins maven-jdocbook-plugin maven-plugin *"));
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libhibernate-validator-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, true, true, false, false, null, "libhibernate-validator-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -244,7 +234,6 @@ public class POMCleanerTest {
public void testCleanApacheParentPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("apache.pom");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.apache apache-jar-resource-bundle * s/1\\..*/1.x/"));
instance.getRulesFiles().get(IGNORE).add(new DependencyRule("org.apache.maven.plugins maven-archetype-plugin * *"));
@@ -259,7 +248,7 @@ public class POMCleanerTest {
instance.getRulesFiles().get(IGNORE).add(new DependencyRule("org.apache.maven.plugins maven-source-plugin * *"));
instance.addElementToKeep("build");
instance.addElementToKeep("reporting");
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, false, false, false, null, "libmaven-parent-poms");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, true, false, false, false, null, "libmaven-parent-poms");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -274,12 +263,11 @@ public class POMCleanerTest {
public void testCleanPlexusUtils2Pom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("plexus-utils2.pom");
- boolean noParent = false;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus-utils jar s/2\\..*/2.x/ * *"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus pom s/2\\..*/2.x/ * *"));
instance.getRulesFiles().get(IGNORE).add(new DependencyRule("org.apache.maven.plugins maven-release-plugin * *"));
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libplexus-utils2-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, false, true, false, false, null, "libplexus-utils2-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
@@ -294,7 +282,6 @@ public class POMCleanerTest {
public void testCleanMojoParentPom() throws Exception {
pomProperties = tmpDir.newFile("pom.properties");
File pom = tmpDir.usePom("mojo-parent.pom");
- boolean noParent = false;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("junit junit jar s/3\\..*/3.x/ * *"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus codehaus-parent pom s/.*/debian/ * *"));
@@ -308,7 +295,7 @@ public class POMCleanerTest {
instance.getRulesFiles().get(IGNORE).add(new DependencyRule("org.codehaus.mojo cobertura-maven-plugin * * * *"));
instance.addElementToKeep("build");
instance.addElementToKeep("reporting");
- instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, noParent, true, false, false, null, "libmojo-parent-java");
+ instance.cleanPom(pom, tmpDir.updatedPom(), pomProperties, false, true, false, false, null, "libmojo-parent-java");
assertCleanedXMLEqual();
Properties pomInfo = new Properties();
pomInfo.load(new FileInputStream(pomProperties));
=====================================
src/test/java/org/debian/maven/repo/POMTransformerTest.java
=====================================
@@ -54,21 +54,19 @@ public class POMTransformerTest {
@Test
public void testTransformMavenPom() throws Exception {
File pom = tmpDir.usePom("maven.xml");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus-container-default jar s/1\\.0-alpha-.*/1.0-alpha/"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.apache.maven.plugins maven-assembly-plugin maven-plugin s/.*/2.2/"));
- instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, false, false, null, null);
+ instance.transformPom(pom, tmpDir.updatedPom(), true, true, false, false, null, null);
assertCleanedXMLEqual();
}
@Test
public void testTransformMavenCorePom() throws Exception {
File pom = tmpDir.usePom("maven-core.xml");
- boolean noParent = false;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus-container-default jar s/1\\.0-alpha-.*/1.0-alpha/"));
- instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, false, false, null, "maven2");
+ instance.transformPom(pom, tmpDir.updatedPom(), false, true, false, false, null, "maven2");
assertCleanedXMLEqual();
}
@@ -77,13 +75,12 @@ public class POMTransformerTest {
XMLUnit.setIgnoreComments(true);
File pom = tmpDir.usePom("maven-javadoc-plugin.xml");
- boolean noParent = true;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.modello modello-maven-plugin maven-plugin s/.*/1.0.1/"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.mojo clirr-maven-plugin * *"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.apache.bcel bcel jar s/5\\..*/5.x/"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("* maven-plugin-plugin maven-plugin s/.*/2.5/"));
- POMInfo transformedPOM = instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, false, false, null, null);
+ POMInfo transformedPOM = instance.transformPom(pom, tmpDir.updatedPom(), true, true, false, false, null, null);
assertCleanedXMLEqual();
assertNull(transformedPOM.getParent());
}
@@ -91,9 +88,8 @@ public class POMTransformerTest {
@Test
public void testTransformModelloPom() throws Exception {
File pom = tmpDir.usePom("modello-core.xml");
- boolean noParent = false;
instance.getRulesFiles().addDefaultRules();
- instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, false, false, null, "libmodello-java");
+ instance.transformPom(pom, tmpDir.updatedPom(), false, true, false, false, null, "libmodello-java");
assertCleanedXMLEqual();
}
@@ -109,17 +105,15 @@ public class POMTransformerTest {
@Test
public void testTransformDoxiaFmlPom() throws Exception {
File pom = tmpDir.usePom("doxia-module-fml.xml");
- boolean noParent = false;
instance.setRepository(getRepository());
instance.getRulesFiles().addDefaultRules();
- instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, true, false, null, "libdoxia-java");
+ instance.transformPom(pom, tmpDir.updatedPom(), false, true, true, false, null, "libdoxia-java");
assertCleanedXMLEqual();
}
@Test
public void testTransformAntlr3Pom() throws Exception {
File pom = tmpDir.usePom("antlr3.xml");
- boolean noParent = false;
instance.setRepository(getRepository());
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.antlr stringtemplate * s/3\\..*/3.x/ *"));
@@ -128,7 +122,7 @@ public class POMTransformerTest {
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.antlr antlr3-maven-plugin maven-plugin s/.*/3.2/"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.antlr stringtemplate jar s/3\\..*/3.x/ *"));
instance.getRulesFiles().get(IGNORE).add(new DependencyRule("org.codehaus.mojo findbugs-maven-plugin maven-plugin *"));
- POMInfo transformedPOM = instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, true, true, null, "libantlr3-java");
+ POMInfo transformedPOM = instance.transformPom(pom, tmpDir.updatedPom(), false, true, true, true, null, "libantlr3-java");
assertCleanedXMLEqual();
assertEquals("3.2", transformedPOM.getParent().getVersion());
assertEquals(1, transformedPOM.getDependencies().get(DEPENDENCIES).size());
@@ -142,7 +136,6 @@ public class POMTransformerTest {
@Test
public void testTransformAntlr3ParentPom() throws Exception {
File pom = tmpDir.usePom("antlr3-parent.xml");
- boolean noParent = false;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.antlr stringtemplate * s/3\\..*/3.x/ *"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("antlr antlr jar s/2\\..*/2.x/ *"));
@@ -156,7 +149,7 @@ public class POMTransformerTest {
instance.addIgnoreModule(pom, "gunit");
instance.addIgnoreModule(pom, "gunit-maven-plugin");
- instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, true, false, null, "libantlr3-java");
+ instance.transformPom(pom, tmpDir.updatedPom(), false, true, true, false, null, "libantlr3-java");
assertCleanedXMLEqual();
}
@@ -165,7 +158,6 @@ public class POMTransformerTest {
XMLUnit.setIgnoreComments(true);
File pom = tmpDir.usePom("antlr3-tools.xml");
- boolean noParent = false;
instance.setRepository(getRepository());
instance.getRulesFiles().addDefaultRules();
@@ -183,47 +175,44 @@ public class POMTransformerTest {
instance.addIgnoreModule(pom, "gunit");
instance.addIgnoreModule(pom, "gunit-maven-plugin");
- instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, true, true, null, "libantlr3-java");
+ instance.transformPom(pom, tmpDir.updatedPom(), false, true, true, true, null, "libantlr3-java");
assertCleanedXMLEqual();
}
@Test
public void testTransformHivernateValidatorTckRunnerPom() throws Exception {
File pom = tmpDir.usePom("hibernate-validator-tck-runner.pom");
- boolean noParent = false;
instance.setRepository(getRepository());
instance.getRulesFiles().addDefaultRules();
instance.usePluginVersionsFromRepository();
- instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, true, true, null, "libhibernate-validator-java");
+ instance.transformPom(pom, tmpDir.updatedPom(), false, true, true, true, null, "libhibernate-validator-java");
assertCleanedXMLEqual();
}
@Test
public void testTransformHivernateValidatorPom() throws Exception {
File pom = tmpDir.usePom("hibernate-validator.pom");
- boolean noParent = false;
instance.setRepository(getRepository());
instance.getRulesFiles().addDefaultRules();
instance.usePluginVersionsFromRepository();
- instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, true, true, null, "libhibernate-validator-java");
+ instance.transformPom(pom, tmpDir.updatedPom(), false, true, true, true, null, "libhibernate-validator-java");
assertCleanedXMLEqual();
}
@Test
public void testTransformPlexusUtils2Pom() throws Exception {
File pom = tmpDir.usePom("plexus-utils2.pom");
- boolean noParent = false;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus-utils jar s/2\\../2.x/ * *"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus pom s/2\\..*/2.x/ * *"));
instance.getRulesFiles().get(IGNORE).add(new DependencyRule("org.apache.maven.plugins maven-release-plugin * *"));
- POMInfo transformedPOM = instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, true, false, null, "libplexus-utils2-java");
+ POMInfo transformedPOM = instance.transformPom(pom, tmpDir.updatedPom(), false, true, true, false, null, "libplexus-utils2-java");
assertCleanedXMLEqual();
assertEquals("2.x", transformedPOM.getParent().getVersion());
}
@@ -231,7 +220,6 @@ public class POMTransformerTest {
@Test
public void testTransformAntlrMavenPluginPom() throws Exception {
File pom = tmpDir.usePom("antlr-maven-plugin.pom");
- boolean noParent = true;
instance.setRepository(getRepository());
instance.getRulesFiles().addDefaultRules();
@@ -241,7 +229,7 @@ public class POMTransformerTest {
instance.getRulesFiles().get(RULES).add(new DependencyRule("s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-plugin-testing-tools * s/.*/debian/ *"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("s/org.apache.maven.shared/org.apache.maven.plugin-testing/ maven-test-tools * s/.*/debian/ *"));
- POMInfo transformedPom = instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, true, false, null, "libantlr-maven-plugin-java");
+ POMInfo transformedPom = instance.transformPom(pom, tmpDir.updatedPom(), true, true, true, false, null, "libantlr-maven-plugin-java");
assertCleanedXMLEqual();
assertEquals("2.3", transformedPom.getDependencies().get(PLUGIN_MANAGEMENT).get(2).getVersion());
}
@@ -249,13 +237,12 @@ public class POMTransformerTest {
@Test
public void testTransformMavenPackagerUtilsPom() throws Exception {
File pom = tmpDir.usePom("maven-packager-utils.pom");
- boolean noParent = false;
instance.getRulesFiles().addDefaultRules();
instance.getRulesFiles().get(RULES).add(new DependencyRule("junit junit jar s/3\\..*/3.x/"));
instance.getRulesFiles().get(RULES).add(new DependencyRule("org.codehaus.plexus plexus-container-default jar s/1\\.0-alpha-.*/1.0-alpha/"));
- POMInfo transformedPOM = instance.transformPom(pom, tmpDir.updatedPom(), noParent, true, true, true, null, "maven-repo-helper");
+ POMInfo transformedPOM = instance.transformPom(pom, tmpDir.updatedPom(), false, true, true, true, null, "maven-repo-helper");
assertCleanedXMLEqual();
assertEquals("1.2", transformedPOM.getParent().getVersion());
}
=====================================
src/test/java/org/debian/maven/repo/SubstvarsTest.java
=====================================
@@ -0,0 +1,35 @@
+package org.debian.maven.repo;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class SubstvarsTest {
+
+ @Test
+ public void testLoad() throws IOException {
+ Properties substvars = Substvars.loadSubstvars(new File("src/test/resources/"), "libcommons-compress-java");
+ assertNotNull(substvars);
+
+ assertEquals("maven:OptionalDepends", "libxz-java (>= 1.8)", substvars.get("maven:OptionalDepends"));
+ assertEquals("maven:TestDepends", "", substvars.get("maven:TestDepends"));
+ }
+
+ @Test
+ public void testWrite() throws IOException {
+ Properties substvars = Substvars.loadSubstvars(new File("target/test-classes"), "libcommons-compress-java");
+ assertNotNull(substvars);
+
+ Substvars.write(new File("target/test-classes"), "libcommons-compress2-java", substvars);
+
+ Properties substvars2 = Substvars.loadSubstvars(new File("target/test-classes"), "libcommons-compress2-java");
+
+ for (Object name : substvars.keySet()) {
+ assertEquals("variable " + name, substvars.get(name), substvars2.get(name));
+ }
+ }
+}
=====================================
src/test/java/org/debian/maven/repo/TreePathTest.java
=====================================
@@ -24,7 +24,7 @@ public class TreePathTest {
@Test
public void testMatches() {
- TreePath<String> path = new TreePath<String>();
+ TreePath<String> path = new TreePath<>();
path.add("a");
path.add("b");
path.add("c");
=====================================
src/test/resources/libcommons-compress-java.substvars
=====================================
@@ -0,0 +1,11 @@
+#List of dependencies for libcommons-compress-java, generated for use by debian/control
+maven:DocOptionalDepends=
+maven:Depends=libcommons-parent-java (>= 43)
+maven:OptionalDepends=libxz-java (>= 1.8)
+maven:CompileDepends=libmaven-antrun-plugin-java (>= 1.8), libmaven-bundle-plugin-java (>= 3.5.1), libmaven-compiler-plugin-java (>= 3.8.1), libmaven-jar-plugin-java (>= 3.1.2)
+maven:DocDepends=
+maven:TestDepends=
+java:Depends=libxz-java
+java:Recommends=
+misc:Depends=
+misc:Pre-Depends=
View it on GitLab: https://salsa.debian.org/java-team/maven-repo-helper/compare/6ed2858a80ede5957323f979486759f28a5290b0...f2deb8d9500b5dfe0dee8c9566ba76b2fb7fb1ba
--
View it on GitLab: https://salsa.debian.org/java-team/maven-repo-helper/compare/6ed2858a80ede5957323f979486759f28a5290b0...f2deb8d9500b5dfe0dee8c9566ba76b2fb7fb1ba
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20190807/f456cf8c/attachment.html>
More information about the pkg-java-commits
mailing list