diff --git a/doc/xooki b/doc/xooki
deleted file mode 160000
index 38eff00e6..000000000
--- a/doc/xooki
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 38eff00e65ec74803838b52a111cab542cb80bca
diff --git a/src/java/org/apache/ivy/Main.java b/src/java/org/apache/ivy/Main.java
index a274e64f2..94c04aca1 100644
--- a/src/java/org/apache/ivy/Main.java
+++ b/src/java/org/apache/ivy/Main.java
@@ -49,6 +49,7 @@
import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorWriter;
import org.apache.ivy.plugins.report.XmlReportParser;
+import org.apache.ivy.util.AbstractMessageLogger;
import org.apache.ivy.util.DefaultMessageLogger;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.cli.CommandLine;
@@ -69,136 +70,100 @@
public final class Main {
private static final int HELP_WIDTH = 80;
+ private static AbstractMessageLogger externalLogger = null;
+
static CommandLineParser getParser() {
- return new CommandLineParser()
- .addCategory("settings options")
- .addOption(
- new OptionBuilder("settings").arg("settingsfile")
- .description("use given file for settings").create())
- .addOption(
- new OptionBuilder("cache").arg("cachedir")
- .description("use given directory for cache").create())
- .addOption(
- new OptionBuilder("novalidate").description(
- "do not validate ivy files against xsd").create())
- .addOption(
- new OptionBuilder("m2compatible").description("use maven2 compatibility")
- .create())
- .addOption(
- new OptionBuilder("conf").arg("settingsfile").deprecated()
- .description("use given file for settings").create())
- .addOption(
- new OptionBuilder("useOrigin")
- .deprecated()
- .description(
- "use original artifact location "
- + "with local resolvers instead of copying to the cache")
- .create())
+ return new CommandLineParser().addCategory("settings options")
+ .addOption(new OptionBuilder("settings").arg("settingsfile")
+ .description("use given file for settings").create())
+ .addOption(new OptionBuilder("cache").arg("cachedir")
+ .description("use given directory for cache").create())
+ .addOption(new OptionBuilder("novalidate")
+ .description("do not validate ivy files against xsd").create())
+ .addOption(new OptionBuilder("m2compatible").description("use maven2 compatibility")
+ .create())
+ .addOption(new OptionBuilder("conf").arg("settingsfile").deprecated()
+ .description("use given file for settings").create())
+ .addOption(new OptionBuilder("useOrigin").deprecated()
+ .description("use original artifact location "
+ + "with local resolvers instead of copying to the cache")
+ .create())
.addCategory("resolve options")
- .addOption(
- new OptionBuilder("ivy").arg("ivyfile")
- .description("use given file as ivy file").create())
- .addOption(
- new OptionBuilder("refresh").description("refresh dynamic resolved revisions")
- .create())
- .addOption(
- new OptionBuilder("dependency")
- .arg("organisation")
- .arg("module")
- .arg("revision")
- .description(
- "use this instead of ivy file to do the rest "
- + "of the work with this as a dependency.").create())
- .addOption(
- new OptionBuilder("confs").arg("configurations").countArgs(false)
- .description("resolve given configurations").create())
- .addOption(
- new OptionBuilder("types").arg("types").countArgs(false)
- .description("comma separated list of accepted artifact types")
- .create())
- .addOption(
- new OptionBuilder("mode").arg("resolvemode")
- .description("the resolve mode to use").create())
- .addOption(
- new OptionBuilder("notransitive").description(
- "do not resolve dependencies transitively").create())
+ .addOption(new OptionBuilder("ivy").arg("ivyfile")
+ .description("use given file as ivy file").create())
+ .addOption(new OptionBuilder("refresh")
+ .description("refresh dynamic resolved revisions").create())
+ .addOption(new OptionBuilder("dependency").arg("organisation").arg("module")
+ .arg("revision")
+ .description("use this instead of ivy file to do the rest "
+ + "of the work with this as a dependency.")
+ .create())
+ .addOption(new OptionBuilder("confs").arg("configurations").countArgs(false)
+ .description("resolve given configurations").create())
+ .addOption(new OptionBuilder("types").arg("types").countArgs(false)
+ .description("comma separated list of accepted artifact types").create())
+ .addOption(new OptionBuilder("mode").arg("resolvemode")
+ .description("the resolve mode to use").create())
+ .addOption(new OptionBuilder("notransitive")
+ .description("do not resolve dependencies transitively").create())
.addCategory("retrieve options")
- .addOption(
- new OptionBuilder("retrieve").arg("retrievepattern")
- .description("use given pattern as retrieve pattern").create())
- .addOption(
- new OptionBuilder("ivypattern").arg("pattern")
- .description("use given pattern to copy the ivy files").create())
+ .addOption(new OptionBuilder("retrieve").arg("retrievepattern")
+ .description("use given pattern as retrieve pattern").create())
+ .addOption(new OptionBuilder("ivypattern").arg("pattern")
+ .description("use given pattern to copy the ivy files").create())
.addOption(
new OptionBuilder("sync").description("use sync mode for retrieve").create())
.addOption(
new OptionBuilder("symlink").description("create symbolic links").create())
.addCategory("cache path options")
- .addOption(
- new OptionBuilder("cachepath")
- .arg("cachepathfile")
- .description(
- "outputs a classpath consisting of all dependencies in cache "
- + "(including transitive ones) "
- + "of the given ivy file to the given cachepathfile")
- .create())
+ .addOption(new OptionBuilder("cachepath").arg("cachepathfile")
+ .description("outputs a classpath consisting of all dependencies in cache "
+ + "(including transitive ones) "
+ + "of the given ivy file to the given cachepathfile")
+ .create())
.addCategory("deliver options")
- .addOption(
- new OptionBuilder("deliverto").arg("ivypattern")
- .description("use given pattern as resolved ivy file pattern").create())
+ .addOption(new OptionBuilder("deliverto").arg("ivypattern")
+ .description("use given pattern as resolved ivy file pattern").create())
.addCategory("publish options")
- .addOption(
- new OptionBuilder("publish").arg("resolvername")
- .description("use given resolver to publish to").create())
- .addOption(
- new OptionBuilder("publishpattern").arg("artpattern")
- .description("use given pattern to find artifacts to publish").create())
- .addOption(
- new OptionBuilder("revision").arg("revision")
- .description("use given revision to publish the module").create())
- .addOption(
- new OptionBuilder("status").arg("status")
- .description("use given status to publish the module").create())
- .addOption(
- new OptionBuilder("overwrite").description(
- "overwrite files in the repository if they exist").create())
+ .addOption(new OptionBuilder("publish").arg("resolvername")
+ .description("use given resolver to publish to").create())
+ .addOption(new OptionBuilder("publishpattern").arg("artpattern")
+ .description("use given pattern to find artifacts to publish").create())
+ .addOption(new OptionBuilder("revision").arg("revision")
+ .description("use given revision to publish the module").create())
+ .addOption(new OptionBuilder("status").arg("status")
+ .description("use given status to publish the module").create())
+ .addOption(new OptionBuilder("overwrite")
+ .description("overwrite files in the repository if they exist").create())
.addCategory("http auth options")
- .addOption(
- new OptionBuilder("realm").arg("realm")
- .description("use given realm for HTTP AUTH").create())
- .addOption(
- new OptionBuilder("host").arg("host")
- .description("use given host for HTTP AUTH").create())
- .addOption(
- new OptionBuilder("username").arg("username")
- .description("use given username for HTTP AUTH").create())
- .addOption(
- new OptionBuilder("passwd").arg("passwd")
- .description("use given password for HTTP AUTH").create())
+ .addOption(new OptionBuilder("realm").arg("realm")
+ .description("use given realm for HTTP AUTH").create())
+ .addOption(new OptionBuilder("host").arg("host")
+ .description("use given host for HTTP AUTH").create())
+ .addOption(new OptionBuilder("username").arg("username")
+ .description("use given username for HTTP AUTH").create())
+ .addOption(new OptionBuilder("passwd").arg("passwd")
+ .description("use given password for HTTP AUTH").create())
.addCategory("launcher options")
- .addOption(
- new OptionBuilder("main").arg("main")
- .description("the FQCN of the main class to launch").create())
- .addOption(
- new OptionBuilder("args").arg("args").countArgs(false)
- .description("the arguments to give to the launched process").create())
- .addOption(
- new OptionBuilder("cp").arg("cp")
- .description("extra classpath to use when launching process").create())
+ .addOption(new OptionBuilder("main").arg("main")
+ .description("the FQCN of the main class to launch").create())
+ .addOption(new OptionBuilder("args").arg("args").countArgs(false)
+ .description("the arguments to give to the launched process").create())
+ .addOption(new OptionBuilder("cp").arg("cp")
+ .description("extra classpath to use when launching process").create())
.addCategory("message options")
.addOption(
new OptionBuilder("debug").description("set message level to debug").create())
- .addOption(
- new OptionBuilder("verbose").description("set message level to verbose")
- .create())
+ .addOption(new OptionBuilder("verbose").description("set message level to verbose")
+ .create())
.addOption(
new OptionBuilder("warn").description("set message level to warn").create())
.addOption(
@@ -208,9 +173,8 @@ static CommandLineParser getParser() {
.addOption(new OptionBuilder("?").description("display this help").create())
.addOption(
new OptionBuilder("deprecated").description("show deprecated options").create())
- .addOption(
- new OptionBuilder("version").description("displays version information")
- .create());
+ .addOption(new OptionBuilder("version").description("displays version information")
+ .create());
}
public static void main(String[] args) throws Exception {
@@ -225,19 +189,50 @@ public static void main(String[] args) throws Exception {
}
}
+ public static ResolveReport run(String[] args) throws Exception {
+ return run(args, false);
+ }
+
+ /*
+ * For backwards compatibility and testing
+ */
static void run(CommandLineParser parser, String[] args) throws Exception {
+ if (Arrays.asList(args).contains("-?")) {
+ usage(parser, false);
+ return;
+ }
+
+ run(parser.parse(args), true);
+ }
+
+ private static ResolveReport run(String[] args, boolean isCli) throws Exception {
+ CommandLineParser parser = getParser();
+
// parse the command line arguments
- CommandLine line = parser.parse(args);
+ CommandLine line;
+ try {
+ line = parser.parse(args);
+ } catch (ParseException pe) {
+ // display usage and and rethrow
+ usage(parser, false);
+ throw new ParseException(pe.getMessage());
+ }
if (line.hasOption("?")) {
usage(parser, line.hasOption("deprecated"));
- return;
+ return null;
}
+ return run(line, isCli);
+ }
+
+ // FIXME - promot upstream - enhancement request
+ static ResolveReport run(CommandLine line, boolean isCli) throws Exception {
+
if (line.hasOption("version")) {
System.out.println("Apache Ivy " + Ivy.getIvyVersion() + " - " + Ivy.getIvyDate()
+ " :: " + Ivy.getIvyHomeURL());
- return;
+ return null;
}
boolean validate = line.hasOption("novalidate") ? false : true;
@@ -247,8 +242,8 @@ static void run(CommandLineParser parser, String[] args) throws Exception {
IvySettings settings = initSettings(line, ivy);
ivy.pushContext();
- File cache = new File(settings.substitute(line.getOptionValue("cache", settings
- .getDefaultCache().getAbsolutePath())));
+ File cache = new File(settings.substitute(
+ line.getOptionValue("cache", settings.getDefaultCache().getAbsolutePath())));
if (line.hasOption("cache")) {
// override default cache path with user supplied cache path
@@ -273,9 +268,8 @@ static void run(CommandLineParser parser, String[] args) throws Exception {
String[] dep = line.getOptionValues("dependency");
ivyfile = File.createTempFile("ivy", ".xml");
ivyfile.deleteOnExit();
- DefaultModuleDescriptor md = DefaultModuleDescriptor
- .newDefaultInstance(ModuleRevisionId.newInstance(dep[0], dep[1] + "-caller",
- "working"));
+ DefaultModuleDescriptor md = DefaultModuleDescriptor.newDefaultInstance(
+ ModuleRevisionId.newInstance(dep[0], dep[1] + "-caller", "working"));
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md,
ModuleRevisionId.newInstance(dep[0], dep[1], dep[2]), false, false, true);
for (int i = 0; i < confs.length; i++) {
@@ -296,11 +290,8 @@ static void run(CommandLineParser parser, String[] args) throws Exception {
if (line.hasOption("useOrigin")) {
ivy.getSettings().useDeprecatedUseOrigin();
}
- ResolveOptions resolveOptions = new ResolveOptions()
- .setConfs(confs)
- .setValidate(validate)
- .setResolveMode(line.getOptionValue("mode"))
- .setArtifactFilter(
+ ResolveOptions resolveOptions = new ResolveOptions().setConfs(confs).setValidate(validate)
+ .setResolveMode(line.getOptionValue("mode")).setArtifactFilter(
FilterHelper.getArtifactTypeFilter(line.getOptionValues("types")));
if (line.hasOption("notransitive")) {
resolveOptions.setTransitive(false);
@@ -309,7 +300,7 @@ static void run(CommandLineParser parser, String[] args) throws Exception {
resolveOptions.setRefresh(true);
}
ResolveReport report = ivy.resolve(ivyfile.toURI().toURL(), resolveOptions);
- if (report.hasError()) {
+ if (report.hasError() && isCli) {
System.exit(1);
}
ModuleDescriptor md = report.getModuleDescriptor();
@@ -323,14 +314,9 @@ static void run(CommandLineParser parser, String[] args) throws Exception {
retrievePattern = retrievePattern + "/lib/[conf]/[artifact].[ext]";
}
String ivyPattern = settings.substitute(line.getOptionValue("ivypattern"));
- ivy.retrieve(
- md.getModuleRevisionId(),
- retrievePattern,
- new RetrieveOptions()
- .setConfs(confs)
- .setSync(line.hasOption("sync"))
- .setUseOrigin(line.hasOption("useOrigin"))
- .setDestIvyPattern(ivyPattern)
+ ivy.retrieve(md.getModuleRevisionId(), retrievePattern,
+ new RetrieveOptions().setConfs(confs).setSync(line.hasOption("sync"))
+ .setUseOrigin(line.hasOption("useOrigin")).setDestIvyPattern(ivyPattern)
.setArtifactFilter(
FilterHelper.getArtifactTypeFilter(line.getOptionValues("types")))
.setMakeSymlinks(line.hasOption("symlink"))
@@ -342,25 +328,22 @@ static void run(CommandLineParser parser, String[] args) throws Exception {
}
if (line.hasOption("revision")) {
- ivy.deliver(
- md.getResolvedModuleRevisionId(),
+ ivy.deliver(md.getResolvedModuleRevisionId(),
settings.substitute(line.getOptionValue("revision")),
settings.substitute(line.getOptionValue("deliverto", "ivy-[revision].xml")),
DeliverOptions.newInstance(settings)
.setStatus(settings.substitute(line.getOptionValue("status", "release")))
.setValidate(validate));
if (line.hasOption("publish")) {
- ivy.publish(
- md.getResolvedModuleRevisionId(),
+ ivy.publish(md.getResolvedModuleRevisionId(),
Collections.singleton(settings.substitute(line.getOptionValue("publishpattern",
"distrib/[type]s/[artifact]-[revision].[ext]"))),
line.getOptionValue("publish"),
new PublishOptions()
.setPubrevision(settings.substitute(line.getOptionValue("revision")))
.setValidate(validate)
- .setSrcIvyPattern(
- settings.substitute(line.getOptionValue("deliverto",
- "ivy-[revision].xml")))
+ .setSrcIvyPattern(settings.substitute(
+ line.getOptionValue("deliverto", "ivy-[revision].xml")))
.setOverwrite(line.hasOption("overwrite")));
}
}
@@ -385,6 +368,8 @@ static void run(CommandLineParser parser, String[] args) throws Exception {
}
ivy.getLoggerEngine().popLogger();
ivy.popContext();
+
+ return report;
}
/**
@@ -393,13 +378,13 @@ static void run(CommandLineParser parser, String[] args) throws Exception {
* All the files contained in the returned List exist, non existing files are simply skipped
* with a warning.
*
- *
+ *
* @param line
* the command line in which the cp option shold be parsed
* @return a List of files to include as extra classpath entries, or null if no cp
* option was provided.
*/
- private static List/* */getExtraClasspathFileList(CommandLine line) {
+ private static List/* */ getExtraClasspathFileList(CommandLine line) {
List fileList = null;
if (line.hasOption("cp")) {
fileList = new ArrayList/* */();
@@ -413,8 +398,8 @@ static void run(CommandLineParser parser, String[] args) throws Exception {
if (file.exists()) {
fileList.add(file);
} else {
- Message.warn("Skipping extra classpath '" + file
- + "' as it does not exist.");
+ Message.warn(
+ "Skipping extra classpath '" + file + "' as it does not exist.");
}
}
}
@@ -455,16 +440,20 @@ private static IvySettings initSettings(CommandLine line, Ivy ivy)
}
private static void initMessage(CommandLine line, Ivy ivy) {
- if (line.hasOption("debug")) {
- ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_DEBUG));
- } else if (line.hasOption("verbose")) {
- ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_VERBOSE));
- } else if (line.hasOption("warn")) {
- ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_WARN));
- } else if (line.hasOption("error")) {
- ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_ERR));
+ if (externalLogger != null) {
+ ivy.getLoggerEngine().pushLogger(externalLogger);
} else {
- ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_INFO));
+ if (line.hasOption("debug")) {
+ ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_DEBUG));
+ } else if (line.hasOption("verbose")) {
+ ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_VERBOSE));
+ } else if (line.hasOption("warn")) {
+ ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_WARN));
+ } else if (line.hasOption("error")) {
+ ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_ERR));
+ } else {
+ ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_INFO));
+ }
}
}
@@ -499,7 +488,8 @@ private static void outputCachePath(Ivy ivy, File cache, ModuleDescriptor md, St
System.out.println("cachepath output to " + outFile);
} catch (Exception ex) {
- throw new RuntimeException("impossible to build ivy cache path: " + ex.getMessage(), ex);
+ throw new RuntimeException("impossible to build ivy cache path: " + ex.getMessage(),
+ ex);
}
}
@@ -538,7 +528,8 @@ private static void invoke(Ivy ivy, File cache, ModuleDescriptor md, String[] co
}
}
} catch (Exception ex) {
- throw new RuntimeException("impossible to build ivy cache path: " + ex.getMessage(), ex);
+ throw new RuntimeException("impossible to build ivy cache path: " + ex.getMessage(),
+ ex);
}
URLClassLoader classLoader = new URLClassLoader((URL[]) urls.toArray(new URL[urls.size()]),
@@ -560,7 +551,8 @@ private static void invoke(Ivy ivy, File cache, ModuleDescriptor md, String[] co
} catch (IllegalAccessException e) {
throw new RuntimeException("No permissions to invoke main method: " + mainclass, e);
} catch (InvocationTargetException e) {
- throw new RuntimeException("Unexpected exception invoking main method: " + mainclass, e);
+ throw new RuntimeException("Unexpected exception invoking main method: " + mainclass,
+ e);
}
}
@@ -588,4 +580,14 @@ private static void usage(CommandLineParser parser, boolean showDeprecated) {
private Main() {
}
+
+ /**
+ * setLogger will send logging to an 'externally' defined logger
+ *
+ * @param logger
+ */
+ public static void setLogger(AbstractMessageLogger logger) {
+ externalLogger = logger;
+ }
+
}
diff --git a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
index 40a007a9e..dba479709 100644
--- a/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
+++ b/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
@@ -72,14 +72,13 @@ public class PomModuleDescriptorBuilder {
new String[] {"runtime", "master"}, true, null),
new Configuration("master", Visibility.PUBLIC,
"contains only the artifact published by this module itself, "
- + "with no transitive dependencies", new String[0], true, null),
+ + "with no transitive dependencies",
+ new String[0], true, null),
new Configuration("compile", Visibility.PUBLIC,
"this is the default scope, used if none is specified. "
+ "Compile dependencies are available in all classpaths.",
new String[0], true, null),
- new Configuration(
- "provided",
- Visibility.PUBLIC,
+ new Configuration("provided", Visibility.PUBLIC,
"this is much like compile, but indicates you expect the JDK or a container "
+ "to provide it. "
+ "It is only available on the compilation classpath, and is not transitive.",
@@ -87,20 +86,18 @@ public class PomModuleDescriptorBuilder {
new Configuration("runtime", Visibility.PUBLIC,
"this scope indicates that the dependency is not required for compilation, "
+ "but is for execution. It is in the runtime and test classpaths, "
- + "but not the compile classpath.", new String[] {"compile"}, true,
- null),
- new Configuration(
- "test",
- Visibility.PRIVATE,
+ + "but not the compile classpath.",
+ new String[] {"compile"}, true, null),
+ new Configuration("test", Visibility.PRIVATE,
"this scope indicates that the dependency is not required for normal use of "
+ "the application, and is only available for the test compilation and "
- + "execution phases.", new String[] {"runtime"}, true, null),
- new Configuration(
- "system",
- Visibility.PUBLIC,
+ + "execution phases.",
+ new String[] {"runtime"}, true, null),
+ new Configuration("system", Visibility.PUBLIC,
"this scope is similar to provided except that you have to provide the JAR "
+ "which contains it explicitly. The artifact is always available and is not "
- + "looked up in a repository.", new String[0], true, null),
+ + "looked up in a repository.",
+ new String[0], true, null),
new Configuration("sources", Visibility.PUBLIC,
"this configuration contains the source artifact of this module, if any.",
new String[0], true, null),
@@ -118,9 +115,9 @@ public class PomModuleDescriptorBuilder {
private static final String EXTRA_INFO_DELIMITER = "__";
- private static final Collection/* */JAR_PACKAGINGS = Arrays.asList(new String[] {
- "ejb", "bundle", "maven-plugin", "eclipse-plugin", "jbi-component",
- "jbi-shared-library", "orbit", "hk2-jar"});
+ private static final Collection/* */ JAR_PACKAGINGS = Arrays
+ .asList(new String[] {"ejb", "bundle", "maven-plugin", "eclipse-plugin",
+ "jbi-component", "jbi-shared-library", "orbit", "hk2-jar"});
static interface ConfMapper {
public void addMappingConfs(DefaultDependencyDescriptor dd, boolean isOptional);
@@ -292,12 +289,43 @@ public void addDependency(Resource res, PomDependencyData dep) {
return;
}
- DefaultDependencyDescriptor dd = new PomDependencyDescriptor(dep, ivyModuleDescriptor,
- moduleRevId);
+ // Add "new" dependency, or add new artifact to "existing" dependency
+ // https://issues.apache.org/jira/browse/IVY-1576
+ DefaultDependencyDescriptor dd = null;
+ DependencyDescriptor[] existingDeps = ivyModuleDescriptor.getDependencies();
+
+ for (int i = 0; i < existingDeps.length; ++i) {
+ DependencyDescriptor ddt = existingDeps[i];
+ ModuleRevisionId existingModuleId = ddt.getDependencyRevisionId();
+
+ if (existingModuleId.equals(moduleRevId)) {
+ // dd = ivyModuleDescriptor.getDependency(mRevId);
+ dd = (DefaultDependencyDescriptor) ddt;
+ break;
+ }
+ }
+
+ if (dd == null) {
+ // dependency not found create new one
+ dd = new PomDependencyDescriptor(dep, ivyModuleDescriptor, moduleRevId);
+ }
+
scope = (scope == null || scope.length() == 0) ? getDefaultScope(dep) : scope;
ConfMapper mapping = (ConfMapper) MAVEN2_CONF_MAPPING.get(scope);
mapping.addMappingConfs(dd, dep.isOptional());
Map extraAtt = new HashMap();
+
+ // If classifier is not null, then potentially its another artifact associated with "this"
+ // dependency descriptior.
+ // The way this is processed however a "new" dependency descriptor comes up and therein lies
+ // the problem
+ // as 3 artifacts have the same dependency descriptor and the 'resolution' will only solve
+ // for 1 dependency - although there are
+ // 3 actual artifacts. So, we should check to see if the DefaultDependencyDescriptor already
+ // exists from the
+ // ivyModuleDescriptor. If it does we add the new artifact with the different classifier
+ // value ..
+ Message.info(dd.toString());
if ((dep.getClassifier() != null)
|| ((dep.getType() != null) && !"jar".equals(dep.getType()))) {
String type = "jar";
@@ -306,6 +334,8 @@ public void addDependency(Resource res, PomDependencyData dep) {
}
String ext = type;
+ Message.info(" found classifier : " + dep.getClassifier());
+
// if type is 'test-jar', the extension is 'jar' and the classifier is 'tests'
// Cfr. http://maven.apache.org/guides/mini/guide-attached-tests.html
if ("test-jar".equals(type)) {
@@ -326,13 +356,28 @@ public void addDependency(Resource res, PomDependencyData dep) {
// compared to how m2 behave with classifiers
String optionalizedScope = dep.isOptional() ? "optional" : scope;
dd.addDependencyArtifact(optionalizedScope, depArtifact);
+ } else {
+ // non-classifier "default"/master artifact
+ // add it ?
+
+ String type = "jar";
+ if (dep.getType() != null) {
+ type = dep.getType();
+ }
+ String ext = type;
+
+ Message.info(" found master : " + dep);
+ String optionalizedScope = dep.isOptional() ? "optional" : scope;
+ DefaultDependencyArtifactDescriptor depArtifact = new DefaultDependencyArtifactDescriptor(
+ dd, dd.getDependencyId().getName(), type, ext, null, extraAtt);
+ dd.addDependencyArtifact(optionalizedScope, depArtifact);
}
// experimentation shows the following, excluded modules are
// inherited from parent POMs if either of the following is true:
// the element is missing or the element
// is present, but empty.
- List /* */excluded = dep.getExcludedModules();
+ List /* */ excluded = dep.getExcludedModules();
if (excluded.isEmpty()) {
excluded = getDependencyMgtExclusions(ivyModuleDescriptor, dep.getGroupId(),
dep.getArtifactId());
@@ -341,13 +386,16 @@ public void addDependency(Resource res, PomDependencyData dep) {
ModuleId excludedModule = (ModuleId) itExcl.next();
String[] confs = dd.getModuleConfigurations();
for (int k = 0; k < confs.length; k++) {
- dd.addExcludeRule(confs[k], new DefaultExcludeRule(new ArtifactId(excludedModule,
- PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION,
- PatternMatcher.ANY_EXPRESSION), ExactPatternMatcher.INSTANCE, null));
+ dd.addExcludeRule(confs[k],
+ new DefaultExcludeRule(
+ new ArtifactId(excludedModule, PatternMatcher.ANY_EXPRESSION,
+ PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION),
+ ExactPatternMatcher.INSTANCE, null));
}
}
ivyModuleDescriptor.addDependency(dd);
+ Message.info("added dependency " + dd.toString());
}
public void addDependency(DependencyDescriptor descriptor) {
@@ -380,10 +428,8 @@ public void addDependencyMgt(PomDependencyMgt dep) {
int index = 0;
for (final Iterator iter = dep.getExcludedModules().iterator(); iter.hasNext();) {
final ModuleId excludedModule = (ModuleId) iter.next();
- overwriteExtraInfoIfExists(
- exclusionPrefix + index,
- excludedModule.getOrganisation() + EXTRA_INFO_DELIMITER
- + excludedModule.getName());
+ overwriteExtraInfoIfExists(exclusionPrefix + index, excludedModule.getOrganisation()
+ + EXTRA_INFO_DELIMITER + excludedModule.getName());
index += 1;
}
}
@@ -413,7 +459,7 @@ public void addPlugin(PomDependencyMgt plugin) {
extraInfoByTagName.setContent(pluginExtraInfo);
}
- public static List /* */getPlugins(ModuleDescriptor md) {
+ public static List /* */ getPlugins(ModuleDescriptor md) {
List result = new ArrayList();
String plugins = md.getExtraInfoContentByTagName("m:maven.plugins");
if (plugins == null) {
@@ -457,7 +503,7 @@ public String getScope() {
return null;
}
- public List /* */getExcludedModules() {
+ public List /* */ getExcludedModules() {
return Collections.EMPTY_LIST; // probably not used?
}
}
@@ -465,8 +511,8 @@ public String getScope() {
private String getDefaultVersion(PomDependencyData dep) {
ModuleId moduleId = ModuleId.newInstance(dep.getGroupId(), dep.getArtifactId());
if (ivyModuleDescriptor.getDependencyManagementMap().containsKey(moduleId)) {
- return ((PomDependencyMgt) ivyModuleDescriptor.getDependencyManagementMap().get(
- moduleId)).getVersion();
+ return ((PomDependencyMgt) ivyModuleDescriptor.getDependencyManagementMap()
+ .get(moduleId)).getVersion();
}
String key = getDependencyMgtExtraInfoKeyForVersion(dep.getGroupId(), dep.getArtifactId());
return ivyModuleDescriptor.getExtraInfoContentByTagName(key);
@@ -476,10 +522,11 @@ private String getDefaultScope(PomDependencyData dep) {
String result;
ModuleId moduleId = ModuleId.newInstance(dep.getGroupId(), dep.getArtifactId());
if (ivyModuleDescriptor.getDependencyManagementMap().containsKey(moduleId)) {
- result = ((PomDependencyMgt) ivyModuleDescriptor.getDependencyManagementMap().get(
- moduleId)).getScope();
+ result = ((PomDependencyMgt) ivyModuleDescriptor.getDependencyManagementMap()
+ .get(moduleId)).getScope();
} else {
- String key = getDependencyMgtExtraInfoKeyForScope(dep.getGroupId(), dep.getArtifactId());
+ String key = getDependencyMgtExtraInfoKeyForScope(dep.getGroupId(),
+ dep.getArtifactId());
result = ivyModuleDescriptor.getExtraInfoContentByTagName(key);
}
if ((result == null) || !MAVEN2_CONF_MAPPING.containsKey(result)) {
@@ -488,7 +535,8 @@ private String getDefaultScope(PomDependencyData dep) {
return result;
}
- private static String getDependencyMgtExtraInfoKeyForVersion(String groupId, String artifaceId) {
+ private static String getDependencyMgtExtraInfoKeyForVersion(String groupId,
+ String artifaceId) {
return DEPENDENCY_MANAGEMENT + EXTRA_INFO_DELIMITER + groupId + EXTRA_INFO_DELIMITER
+ artifaceId + EXTRA_INFO_DELIMITER + "version";
}
@@ -508,7 +556,7 @@ private static String getDependencyMgtExtraInfoPrefixForExclusion(String groupId
+ artifaceId + EXTRA_INFO_DELIMITER + "exclusion_";
}
- private static List /* */getDependencyMgtExclusions(ModuleDescriptor descriptor,
+ private static List /* */ getDependencyMgtExclusions(ModuleDescriptor descriptor,
String groupId, String artifactId) {
if (descriptor instanceof PomModuleDescriptor) {
PomDependencyMgt dependencyMgt = (PomDependencyMgt) ((PomModuleDescriptor) descriptor)
@@ -518,15 +566,15 @@ private static String getDependencyMgtExtraInfoPrefixForExclusion(String groupId
}
}
String exclusionPrefix = getDependencyMgtExtraInfoPrefixForExclusion(groupId, artifactId);
- List /* */exclusionIds = new LinkedList /* */();
+ List /* */ exclusionIds = new LinkedList /* */();
for (ExtraInfoHolder extraInfoHolder : descriptor.getExtraInfos()) {
String key = extraInfoHolder.getName();
if (key.startsWith(exclusionPrefix)) {
String fullExclusion = extraInfoHolder.getContent();
String[] exclusionParts = fullExclusion.split(EXTRA_INFO_DELIMITER);
if (exclusionParts.length != 2) {
- Message.error(WRONG_NUMBER_OF_PARTS_MSG + exclusionParts.length + " : "
- + fullExclusion);
+ Message.error(
+ WRONG_NUMBER_OF_PARTS_MSG + exclusionParts.length + " : " + fullExclusion);
continue;
}
exclusionIds.add(ModuleId.newInstance(exclusionParts[0], exclusionParts[1]));
@@ -536,7 +584,7 @@ private static String getDependencyMgtExtraInfoPrefixForExclusion(String groupId
}
public static Map/* */
- getDependencyManagementMap(ModuleDescriptor md) {
+ getDependencyManagementMap(ModuleDescriptor md) {
Map ret = new LinkedHashMap();
if (md instanceof PomModuleDescriptor) {
for (final Iterator iterator = ((PomModuleDescriptor) md).getDependencyManagementMap()
@@ -586,7 +634,7 @@ public static List getDependencyManagements(ModuleDescriptor md) {
String version = md.getExtraInfoContentByTagName(versionKey);
String scope = md.getExtraInfoContentByTagName(scopeKey);
- List /* */exclusions = getDependencyMgtExclusions(md, parts[1],
+ List /* */ exclusions = getDependencyMgtExclusions(md, parts[1],
parts[2]);
result.add(new DefaultPomDependencyMgt(parts[1], parts[2], version, scope,
exclusions));
@@ -638,8 +686,8 @@ public static Map extractPomProperties(Map extraInfo) {
for (Iterator it = extraInfo.entrySet().iterator(); it.hasNext();) {
Map.Entry extraInfoEntry = (Map.Entry) it.next();
if (((String) extraInfoEntry.getKey()).startsWith(PROPERTIES)) {
- String prop = ((String) extraInfoEntry.getKey()).substring(PROPERTIES.length()
- + EXTRA_INFO_DELIMITER.length());
+ String prop = ((String) extraInfoEntry.getKey())
+ .substring(PROPERTIES.length() + EXTRA_INFO_DELIMITER.length());
r.put(prop, extraInfoEntry.getValue());
}
}
@@ -650,8 +698,8 @@ public static Map extractPomProperties(List extraInfos) {
Map r = new HashMap();
for (ExtraInfoHolder extraInfoHolder : extraInfos) {
if ((extraInfoHolder.getName()).startsWith(PROPERTIES)) {
- String prop = (extraInfoHolder.getName()).substring(PROPERTIES.length()
- + EXTRA_INFO_DELIMITER.length());
+ String prop = (extraInfoHolder.getName())
+ .substring(PROPERTIES.length() + EXTRA_INFO_DELIMITER.length());
r.put(prop, extraInfoHolder.getContent());
}
}
@@ -708,7 +756,7 @@ private PomDependencyDescriptor(PomDependencyData pomDependencyData,
/**
* Get PomDependencyData.
- *
+ *
* @return PomDependencyData
*/
public PomDependencyData getPomDependencyData() {
@@ -717,7 +765,7 @@ public PomDependencyData getPomDependencyData() {
}
public static class PomModuleDescriptor extends DefaultModuleDescriptor {
- private final Map/* */dependencyManagementMap = new HashMap();
+ private final Map/* */ dependencyManagementMap = new HashMap();
public PomModuleDescriptor(ModuleDescriptorParser parser, Resource res) {
super(parser, res);
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 000000000..9480c586b
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1 @@
+/repositories/