Allow ivy types that need to be appended to import classpath configurable (if not specified 'jar' and 'bundle' types are used by default)
git-svn-id: https://svn.apache.org/repos/asf/ant/easyant/core/trunk@1585649 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java b/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java
index 79db35e..acc7cf5 100644
--- a/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java
+++ b/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java
@@ -209,4 +209,9 @@
*/
String MULTIMODULE_LOGGER = "multimodule.logger";
+ /**
+ * Name of the property containing a comma separated list of ivy type that must be appended to immort classpath
+ */
+ String IMPORT_CLASSPATH_TYPES = "import.classpath.types";
+
}
diff --git a/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java b/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java
index dee3ede..6bd5225 100644
--- a/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java
+++ b/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java
@@ -190,7 +190,7 @@
if ("ant".equals(artifact.getType())) {
antFile = artifact.getLocalFile();
- } else if ("jar".equals(artifact.getType())) {
+ } else if (shouldBeAddedToClasspath(artifact)) {
path.createPathElement().setLocation(artifact.getLocalFile());
} else {
handleOtherResourceFile(moduleRevisionId, artifact.getName(), artifact.getExt(),
diff --git a/src/main/java/org/apache/easyant/tasks/AbstractImport.java b/src/main/java/org/apache/easyant/tasks/AbstractImport.java
index 1501cd8..3cd8da5 100644
--- a/src/main/java/org/apache/easyant/tasks/AbstractImport.java
+++ b/src/main/java/org/apache/easyant/tasks/AbstractImport.java
@@ -78,7 +78,7 @@
ArtifactDownloadReport artifact = report.getConfigurationReport(mainConf).getAllArtifactsReports()[j];
if ("ant".equals(artifact.getType())) {
antFile = artifact.getLocalFile();
- } else if ("jar".equals(artifact.getType())) {
+ } else if (shouldBeAddedToClasspath(artifact)) {
path.createPathElement().setLocation(artifact.getLocalFile());
} else {
handleOtherResourceFile(moduleRevisionId, artifact.getName(), artifact.getExt(),
@@ -91,6 +91,21 @@
}
}
+ public boolean shouldBeAddedToClasspath(ArtifactDownloadReport artifact) {
+ String[] types = null;
+ if (getProject().getProperty(EasyAntMagicNames.IMPORT_CLASSPATH_TYPES) != null) {
+ types = getProject().getProperty(EasyAntMagicNames.IMPORT_CLASSPATH_TYPES).split(",");
+ } else {
+ types = new String[] { "jar", "bundle" };
+ }
+ for (int i = 0; i < types.length; i++) {
+ if (artifact.getType().equals(types[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Do effective import of a given ant file
*
diff --git a/src/main/java/org/apache/easyant/tasks/ImportDeferred.java b/src/main/java/org/apache/easyant/tasks/ImportDeferred.java
index 95f9b61..0810a98 100644
--- a/src/main/java/org/apache/easyant/tasks/ImportDeferred.java
+++ b/src/main/java/org/apache/easyant/tasks/ImportDeferred.java
@@ -107,7 +107,7 @@
Path path = createModulePath(moduleId);
for (int i = 0; i < confReport.getAllArtifactsReports().length; i++) {
ArtifactDownloadReport artifactReport = confReport.getAllArtifactsReports()[i];
- if ("jar".equals(artifactReport.getType())) {
+ if (shouldBeAddedToClasspath(artifactReport)) {
path.createPathElement().setLocation(artifactReport.getLocalFile());
}
}
diff --git a/src/main/java/org/apache/easyant/tasks/ImportTestModule.java b/src/main/java/org/apache/easyant/tasks/ImportTestModule.java
index 72a18d5..cf632c6 100644
--- a/src/main/java/org/apache/easyant/tasks/ImportTestModule.java
+++ b/src/main/java/org/apache/easyant/tasks/ImportTestModule.java
@@ -92,7 +92,7 @@
for (int j = 0; j < report.getConfigurationReport(getMainConf()).getAllArtifactsReports().length; j++) {
ArtifactDownloadReport artifact = report.getConfigurationReport(getMainConf()).getAllArtifactsReports()[j];
- if ("jar".equals(artifact.getType())) {
+ if (shouldBeAddedToClasspath(artifact)) {
path.createPathElement().setLocation(artifact.getLocalFile());
}
}