You are viewing a plain text version of this content. The canonical link for it is here.
Posted to easyant-commits@incubator.apache.org by jl...@apache.org on 2012/07/24 11:44:57 UTC

svn commit: r1364988 - in /incubator/easyant/core/trunk/src/main: java/org/apache/easyant/tasks/AbstractImport.java java/org/apache/easyant/tasks/Import.java java/org/apache/easyant/tasks/ImportTestModule.java resources/org/apache/easyant/antlib.xml

Author: jlboudart
Date: Tue Jul 24 11:44:56 2012
New Revision: 1364988

URL: http://svn.apache.org/viewvc?rev=1364988&view=rev
Log:
Introduces a new ant task ImportTestModule designed to simplify module's test

Added:
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/AbstractImport.java
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ImportTestModule.java
Modified:
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java
    incubator/easyant/core/trunk/src/main/resources/org/apache/easyant/antlib.xml

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/AbstractImport.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/AbstractImport.java?rev=1364988&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/AbstractImport.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/AbstractImport.java Tue Jul 24 11:44:56 2012
@@ -0,0 +1,323 @@
+package org.apache.easyant.tasks;
+
+import java.io.File;
+import java.util.Iterator;
+
+import org.apache.easyant.core.EasyAntMagicNames;
+import org.apache.ivy.core.LogOptions;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.resolve.ResolveOptions;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.ImportTask;
+import org.apache.tools.ant.types.Path;
+
+
+/**
+ * This abstract task is used to include / import modules.
+ * 
+ * The include mechanism is similar to the current import task, excepts that it automatically prefix all targets of the
+ * used build module (=ant script). The prefix used by default is the name of the imported project, but it can be
+ * overriden when calling "include".
+ * 
+ * Include is useful to use features provided by a build module, while preserving a namespace isolation to avoid names
+ * collisions.
+ * 
+ * While possible, overriding a target defined in a included module is not recommended. To do so, the import mechanism
+ * is preferred.
+ * 
+ */
+public abstract class AbstractImport extends AbstractEasyAntTask {
+
+    private String as;
+    private String mode;
+    private boolean mandatory;
+    private String buildConfigurations;
+    private String mainConf = "default";
+    private String providedConf = "provided";
+
+    public AbstractImport() {
+        super();
+    }
+
+    /**
+     * Import a module
+     * 
+     * @param moduleRevisionId {@link ModuleRevisionId} of main artifact
+     * @param report
+     *            a resolved report of the module to import
+     */
+    protected void importModule(ModuleRevisionId moduleRevisionId,ResolveReport report) {
+        // Check dependency on core
+        checkCoreCompliance(report, providedConf);
+
+        Path path = createModulePath(moduleRevisionId);
+        File antFile = null;
+        for (int j = 0; j < report.getConfigurationReport(mainConf).getAllArtifactsReports().length; j++) {
+            ArtifactDownloadReport artifact = report.getConfigurationReport(mainConf).getAllArtifactsReports()[j];
+
+            if ("ant".equals(artifact.getType()) && "ant".equals(artifact.getExt())) {
+                antFile = artifact.getLocalFile();
+            } else if ("jar".equals(artifact.getType())) {
+                path.createPathElement().setLocation(artifact.getLocalFile());
+            } else {
+                handleOtherResourceFile(moduleRevisionId, artifact.getName(), artifact.getExt(), artifact.getLocalFile());
+            }
+        }
+        if (antFile != null && antFile.exists()) {
+            doEffectiveImport(antFile);
+        }
+    }
+
+    /**
+     * Do effective import of a given ant file
+     * 
+     * @param antFile
+     *            a given ant file
+     */
+    protected void doEffectiveImport(File antFile) {
+        ImportTask importTask = new ImportTask();
+        importTask.setProject(getProject());
+        importTask.setTaskName(getTaskName());
+        importTask.setOwningTarget(getOwningTarget());
+        importTask.setLocation(getLocation());
+        importTask.setFile(antFile.getAbsolutePath());
+        if (as != null) {
+            importTask.setAs(as);
+            importTask.setPrefixSeparator("");
+        }
+        if (mode != null && "include".equals(mode)) {
+            importTask.setTaskType(getMode());
+        }
+        importTask.execute();
+    }
+
+    /**
+     * <p>
+     * Register all location of other resource file in properties.
+     * </p>
+     * <p>
+     * Properties are composed with the following syntax : [organisation].[module].[artifact].[type].file
+     * </p>
+     * <p>
+     * The '.artifact' is optional when module name and artifact name are the same. [organisation].[module].[type].file
+     * </p>
+     * 
+     * @param moduleRevisionId a {@link ModuleRevisionId} of the main artifact
+     * @param artifactName artifact name
+     * @param artifactExtension artifact extension name
+     * @param localResourceFile
+     */
+    protected void handleOtherResourceFile(ModuleRevisionId moduleRevisionId, String artifactName, String artifactExtension, File localResourceFile) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(moduleRevisionId.getOrganisation());
+        sb.append("#");
+        sb.append(moduleRevisionId.getName());
+        sb.append(".");
+        if (!moduleRevisionId.getName().equals(artifactName)) {
+            sb.append(artifactName);
+            sb.append(".");
+        }
+        sb.append(artifactExtension);
+        sb.append(".file");
+
+        getProject().log("registering location of artifact " + artifactName + " ext" + artifactExtension + " on " +sb.toString(),Project.MSG_DEBUG);
+
+        getProject().setNewProperty(sb.toString(), localResourceFile.getAbsolutePath());
+    }
+
+    /**
+     * creates a classpath specific for each module, this classpath will contains all the required dependency .jars. The
+     * classpath is named [organisation]#[module].classpath
+     * 
+     * @param moduleRevisionId
+     * @return
+     */
+    protected Path createModulePath(ModuleRevisionId moduleRevisionId) {
+        Path path = new Path(getProject());
+        getProject().addReference(moduleRevisionId.getModuleId().toString() + ".classpath", path);
+        return path;
+    }
+
+    /**
+     * Configures resolve options
+     * 
+     * @return configured resolveOptions
+     */
+    protected ResolveOptions configureResolveOptions() {
+        // Here we do not specify explicit configuration to resolve as
+        // we want to check multiple configurations.
+        // If we make specify explicitly configurations to resolve, the
+        // resolution could through exceptions when configuration does
+        // not exist in resolved modules.
+        // resolveOptions.setConfs(new String[] { mainConf,providedConf });
+
+        // By default we consider that main conf is default.
+        // To verify core compliance we can have a dependency on
+        // easyant-core in a specific configuration.
+        // By default this configuration is provided.
+
+        // An error can be thrown if module contains non-public configurations.
+        ResolveOptions resolveOptions = new ResolveOptions();
+        resolveOptions.setLog(getResolveLog());
+
+        Boolean offline = Boolean.valueOf(getProject().getProperty(EasyAntMagicNames.EASYANT_OFFLINE));
+        resolveOptions.setUseCacheOnly(offline);
+        return resolveOptions;
+    }
+
+    /**
+     * Check dependency on easyant core with a given configuration. If dependency is found we'll check compliance with
+     * current core version. It uses {@link CoreRevisionCheckerTask} internally.
+     * 
+     * @param report
+     *            a {@link ResolveReport}
+     * @param confToCheck
+     *            configuration to check
+     */
+    protected void checkCoreCompliance(ResolveReport report, String confToCheck) {
+        if (report.getConfigurationReport(confToCheck) != null) {
+            log("checking module's provided dependencies ...", Project.MSG_DEBUG);
+            for (Iterator iterator = report.getConfigurationReport(confToCheck).getModuleRevisionIds().iterator(); iterator
+                    .hasNext();) {
+                ModuleRevisionId currentmrid = (ModuleRevisionId) iterator.next();
+                log("checking " + currentmrid.toString(), Project.MSG_DEBUG);
+                if (currentmrid.getOrganisation().equals("org.apache.easyant")
+                        && currentmrid.getName().equals("easyant-core")) {
+                    CoreRevisionCheckerTask checker = new CoreRevisionCheckerTask();
+                    checker.setRequiredRevision(currentmrid.getRevision());
+                    initTask(checker).execute();
+                }
+            }
+        }
+    }
+
+    public void setDynamicAttribute(String attributeName, String value) throws BuildException {
+        PropertyTask property = new PropertyTask();
+        property.setName(attributeName);
+        property.setValue(value);
+        initTask(property).execute();
+    }
+
+    /**
+     * Get resolve log settings
+     * 
+     * @return a string representing the log strategy
+     */
+    protected String getResolveLog() {
+        String downloadLog = getProject().getProperty(EasyAntMagicNames.MODULE_DOWNLOAD_LOG);
+        return downloadLog != null ? downloadLog : LogOptions.LOG_DOWNLOAD_ONLY;
+    }
+
+    /**
+     * Get the alias name
+     * 
+     * @return a string that represents the alias name
+     */
+    public String getAs() {
+        return as;
+    }
+
+    /**
+     * Set the alias name
+     * 
+     * @param as
+     *            a string that represents the alias name
+     */
+    public void setAs(String as) {
+        this.as = as;
+    }
+
+    /**
+     * Get the import mode
+     * 
+     * @return a string that represents the import mode (e.g. import / include)
+     */
+    public String getMode() {
+        return mode;
+    }
+
+    /**
+     * Set the import mode
+     * 
+     * @param mode
+     *            a string that represents the import mode (e.g. import / include)
+     */
+    public void setMode(String mode) {
+        this.mode = mode;
+    }
+
+    public String getBuildConfigurations() {
+        return buildConfigurations;
+    }
+
+    public void setBuildConfigurations(String conf) {
+        this.buildConfigurations = conf;
+    }
+
+    public void setConf(String conf) {
+        this.buildConfigurations = conf;
+    }
+
+    /**
+     * Get the main configuration where plugin are resolved
+     * 
+     * @return a string representing the main configuration
+     */
+    public String getMainConf() {
+        return mainConf;
+    }
+
+    /**
+     * Set the main configuration where plugin are resolved
+     * 
+     * @param mainConf
+     *            a string representing the main configuration
+     */
+    public void setMainConf(String mainConf) {
+        this.mainConf = mainConf;
+    }
+
+    /**
+     * Get the configuration that may contain dependency on easyant-core. This configuration is used to check core
+     * compliance at resolve time. It should not affect the plugin classpath
+     * 
+     * @return provided configuration
+     */
+    public String getProvidedConf() {
+        return providedConf;
+    }
+
+    /**
+     * Set the configuration that may contain dependency on easyant-core. This configuration is used to check core
+     * compliance at resolve time. It should not affect the plugin classpath
+     * 
+     * @return provided configuration
+     */
+    public void setProvidedConf(String providedConf) {
+        this.providedConf = providedConf;
+    }
+
+    /**
+     * Can we skip the load of this module?
+     * 
+     * return true if the module can't be skipped
+     */
+    public boolean isMandatory() {
+        return mandatory;
+    }
+
+    /**
+     * Can we skip the load of this module?
+     * 
+     * @param mandatory
+     *            true if the module can't be skipped
+     */
+    public void setMandatory(boolean mandatory) {
+        this.mandatory = mandatory;
+
+    }
+
+}
\ No newline at end of file

Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java?rev=1364988&r1=1364987&r2=1364988&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java Tue Jul 24 11:44:56 2012
@@ -17,40 +17,36 @@
  */
 package org.apache.easyant.tasks;
 
-import java.io.File;
-import java.util.Iterator;
+import java.io.IOException;
+import java.text.ParseException;
 
 import org.apache.easyant.core.BuildConfigurationHelper;
-import org.apache.easyant.core.EasyAntMagicNames;
-import org.apache.ivy.Ivy;
-import org.apache.ivy.core.LogOptions;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
-import org.apache.ivy.core.report.ArtifactDownloadReport;
 import org.apache.ivy.core.report.ResolveReport;
-import org.apache.ivy.core.resolve.ResolveOptions;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DynamicAttribute;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.ImportTask;
-import org.apache.tools.ant.types.Path;
 
 /**
- * This task is used to include / import scripts.
+ * Default import implementation, resolution is done through give arguments. Example :
  * 
- * The include mechanism is similar to the current import task, excepts that it
- * automatically prefix all targets of the used build module (=ant script). The
- * prefix used by default is the name of the imported project, but it can be
- * overriden when calling "include".
+ * <pre>
+ * &lt;import mrid="org.apache.easyant.plugins#compile-java;0.9"/&gt;
+ * </pre>
  * 
- * This is useful to use features provided by a build module, while preserving a
- * namespace isolation to avoid names collisions.
+ * exploded style
  * 
- * While possible, overriding a target defined in a included module is not
- * recommended. To do so, the import mechanism is preferred.
+ * <pre>
+ * &lt;import organisation="org.apache.easyant.plugins" module="compile-java" revision="0.9"/&gt;
+ * </pre>
  * 
- * The import mechanism is equivalent to the current import mechanism.
+ * exploded style with shortcut attributes
+ * 
+ * <pre>
+ * &lt;import org="org.apache.easyant.plugins" module="compile-java" rev="0.9"/&gt;
+ * </pre>
  */
-public class Import extends AbstractEasyAntTask implements DynamicAttribute {
+public class Import extends AbstractImport implements DynamicAttribute {
 
     private String module;
     private String organisation;
@@ -58,13 +54,59 @@ public class Import extends AbstractEasy
 
     private String mrid;
 
-    private String as;
-    private String mode;
-    private boolean mandatory;
-    private String buildConfigurations;
+    public void execute() {
+        ModuleRevisionId moduleRevisionId = null;
+        if (mrid != null) {
+            moduleRevisionId = ModuleRevisionId.parse(mrid);
+        } else if (organisation != null && module != null && revision != null) {
+            moduleRevisionId = ModuleRevisionId.newInstance(organisation, module, revision);
+        } else {
+            throw new BuildException(
+                    "The module to import is not properly specified, you must set the mrid attribute or set organisation / module / revision attributes");
+        }
+        String moduleName = moduleRevisionId.toString();
+        if (!BuildConfigurationHelper.isBuildConfigurationActive(getBuildConfigurations(), getProject(), "module"
+                + getModule())) {
+            log("no matching build configuration for module " + moduleName + " this module will be skipped ",
+                    Project.MSG_DEBUG);
+            return;
+        }
+
+        // if no as attribute was given use module name
+        if (getAs() == null && "include".equals(getMode())) {
+            // when using mrid style
+            if (mrid != null) {
+                setAs(moduleRevisionId.getName());
+                // when using exploded style
+            } else if (getModule() != null) {
+                setAs(getModule());
+            }
+        }
+
+        // check if a property skip.${module} or skip.${as} is set
+        boolean toBeSkipped = getProject().getProperty("skip." + moduleName) != null
+                || getProject().getProperty("skip." + getAs()) != null;
 
-    private String mainConf = "default";
-    private String providedConf = "provided";
+        if (isMandatory() && toBeSkipped) {
+            log("Impossible to skip a mandatory module : " + moduleName, Project.MSG_WARN);
+        }
+
+        // a module can be skipped *only* if it is not mandatory
+        if (!isMandatory() && toBeSkipped) {
+            log(moduleName + " skipped !");
+        } else {
+            try {
+                ResolveReport report = getEasyAntIvyInstance().getResolveEngine().resolve(moduleRevisionId,
+                        configureResolveOptions(), true);
+                importModule(moduleRevisionId,report);
+            } catch (ParseException e) {
+                throw new BuildException("Can't parse module descriptor", e);
+            } catch (IOException e) {
+                throw new BuildException("Can't parse module descriptor", e);
+            }
+
+        }
+    }
 
     /**
      * Get the module name to import
@@ -161,284 +203,4 @@ public class Import extends AbstractEasy
     public void setMrid(String mrid) {
         this.mrid = mrid;
     }
-
-    /**
-     * Get the alias name
-     * 
-     * @return a string that represents the alias name
-     */
-    public String getAs() {
-        return as;
-    }
-
-    /**
-     * Set the alias name
-     * 
-     * @param as
-     *            a string that represents the alias name
-     */
-    public void setAs(String as) {
-        this.as = as;
-    }
-
-    /**
-     * Get the import mode
-     * 
-     * @return a string that represents the import mode (e.g. import / include)
-     */
-    public String getMode() {
-        return mode;
-    }
-
-    /**
-     * Set the import mode
-     * 
-     * @param mode
-     *            a string that represents the import mode (e.g. import /
-     *            include)
-     */
-    public void setMode(String mode) {
-        this.mode = mode;
-    }
-
-    public String getBuildConfigurations() {
-        return buildConfigurations;
-    }
-
-    public void setBuildConfigurations(String conf) {
-        this.buildConfigurations = conf;
-    }
-
-    public void setConf(String conf) {
-        this.buildConfigurations = conf;
-    }
-
-    /**
-     * Get the main configuration where plugin are resolved
-     * 
-     * @return a string representing the main configuration
-     */
-    public String getMainConf() {
-        return mainConf;
-    }
-
-    /**
-     * Set the main configuration where plugin are resolved
-     * 
-     * @param mainConf
-     *            a string representing the main configuration
-     */
-    public void setMainConf(String mainConf) {
-        this.mainConf = mainConf;
-    }
-
-    /**
-     * Get the configuration that may contain dependency on easyant-core. This
-     * configuration is used to check core compliance at resolve time. It should
-     * not affect the plugin classpath
-     * 
-     * @return provided configuration
-     */
-    public String getProvidedConf() {
-        return providedConf;
-    }
-
-    /**
-     * Set the configuration that may contain dependency on easyant-core. This
-     * configuration is used to check core compliance at resolve time. It should
-     * not affect the plugin classpath
-     * 
-     * @return provided configuration
-     */
-    public void setProvidedConf(String providedConf) {
-        this.providedConf = providedConf;
-    }
-
-    /**
-     * Get resolve log settings
-     * 
-     * @return a string representing the log strategy
-     */
-    public String getResolveLog() {
-        String downloadLog = getProject().getProperty(
-                EasyAntMagicNames.MODULE_DOWNLOAD_LOG);
-        return downloadLog != null ? downloadLog : LogOptions.LOG_DOWNLOAD_ONLY;
-    }
-
-    public void execute() throws BuildException {
-    	ModuleRevisionId moduleRevisionId = null;
-        if (mrid != null) {
-        	moduleRevisionId = ModuleRevisionId.parse(mrid);
-        } else if (organisation != null && module != null && revision != null) {
-        	moduleRevisionId = ModuleRevisionId.newInstance(organisation,
-        								module, revision);
-        } else {
-            throw new BuildException(
-            		"The module to import is not properly specified, you must set the mrid attribute or set organisation / module / revision attributes");
-        }
-        String moduleName = moduleRevisionId.toString();
-        if (!BuildConfigurationHelper.isBuildConfigurationActive(
-                getBuildConfigurations(), getProject(), "module" + getModule())) {
-            log("no matching build configuration for module " + moduleName
-                    + " this module will be skipped ", Project.MSG_DEBUG);
-            return;
-        }
-        
-        //if no as attribute was given use module name
-        if (as==null && "include".equals(getMode())) {
-            //when using mrid style
-            if (mrid!=null) {
-                as = moduleRevisionId.getName();
-            //when using exploded style
-            } else if (getModule() != null) {
-                as=getModule();
-            }
-        }
-        
-        // check if a property skip.${module} or skip.${as} is set
-        boolean toBeSkipped = getProject().getProperty("skip." + moduleName) != null
-        						|| getProject().getProperty("skip." + getAs()) != null;
-
-        if (mandatory && toBeSkipped) {
-            log("Impossible to skip a mandatory module : " + moduleName,
-                    Project.MSG_WARN);
-        }
-
-        // a module can be skipped *only* if it is not mandatory
-        if (!mandatory && toBeSkipped) {
-            log(moduleName + " skipped !");
-        } else {
-            try {
-            	Ivy ivy = getEasyAntIvyInstance();
-                ResolveOptions resolveOptions = new ResolveOptions();
-                // TODO: This should be configurable
-
-                resolveOptions.setLog(getResolveLog());
-
-                Boolean offline = Boolean.valueOf(getProject().getProperty(EasyAntMagicNames.EASYANT_OFFLINE));
-                resolveOptions.setUseCacheOnly(offline);
-
-                // Here we do not specify explicit configuration to resolve as
-                // we want to check multiple configurations.
-                // If we make specify explicitly configurations to resolve, the
-                // resolution could through exceptions when configuration does
-                // not exist in resolved modules.
-                // resolveOptions.setConfs(new String[] { mainConf,providedConf });
-                
-                // By default we consider that main conf is default.
-                // To verify core compliance we can have a dependency on
-                // easyant-core in a specific configuration.
-                // By default this configuration is provided.
-                
-                // An error can be thrown if module contains non-public configurations.
-                ResolveReport report = ivy.getResolveEngine().resolve(
-                								moduleRevisionId, resolveOptions, true);
-                // Check dependency on core
-                checkCoreCompliance(report, providedConf);
-
-                Path path = new Path(getProject());
-                getProject().addReference(
-                        moduleRevisionId.getModuleId().toString()
-                                + ".classpath", path);
-                File antFile = null;
-                for (int j = 0; j < report.getConfigurationReport(mainConf)
-                        .getAllArtifactsReports().length; j++) {
-                    ArtifactDownloadReport artifact = report
-                            .getConfigurationReport(mainConf)
-                            .getAllArtifactsReports()[j];
-
-					if ("ant".equals(artifact.getType())
-							&& "ant".equals(artifact.getExt())) {
-						antFile = artifact.getLocalFile();
-					} else if ("jar".equals(artifact.getType())) {
-                        path.createPathElement().setLocation(
-                                artifact.getLocalFile());
-                    } else {
-                        StringBuilder sb = new StringBuilder();
-                        sb.append(moduleRevisionId.getOrganisation());
-                        sb.append("#");
-                        sb.append(moduleRevisionId.getName());
-                        sb.append(".");
-                        if (!moduleRevisionId.getName().equals(
-                                artifact.getName())) {
-                            sb.append(artifact.getName());
-                            sb.append(".");
-                        }
-                        sb.append(artifact.getExt());
-                        sb.append(".file");
-                        getProject().setNewProperty(sb.toString(),
-                                artifact.getLocalFile().getAbsolutePath());
-                    }
-                }
-                if (antFile != null && antFile.exists()) {
-                    ImportTask importTask = new ImportTask();
-                    importTask.setProject(getProject());
-                    importTask.setTaskName(getTaskName());
-                    importTask.setOwningTarget(getOwningTarget());
-                    importTask.setLocation(getLocation());
-                    importTask.setFile(antFile.getAbsolutePath());
-                    if (as != null) {
-                        importTask.setAs(as);
-                        importTask.setPrefixSeparator("");
-                    }
-                    if (mode != null && "include".equals(mode)) {
-                        importTask.setTaskType(getMode());
-                    }
-                    importTask.execute();
-                }
-
-            } catch (Exception e) {
-                throw new BuildException(e);
-            }
-
-        }
-    }
-
-    /**
-     * Check dependency on easyant core with a given configuration. If
-     * dependency is found we'll check compliance with current core version. It
-     * uses {@link CoreRevisionCheckerTask} internally.
-     * 
-     * @param report
-     *            a {@link ResolveReport}
-     * @param confToCheck
-     *            configuration to check
-     */
-    private void checkCoreCompliance(ResolveReport report, String confToCheck) {
-        if (report.getConfigurationReport(confToCheck) != null) {
-            log("checking module's provided dependencies ...",
-                    Project.MSG_DEBUG);
-            for (Iterator iterator = report.getConfigurationReport(confToCheck)
-                    .getModuleRevisionIds().iterator(); iterator.hasNext();) {
-                ModuleRevisionId currentmrid = (ModuleRevisionId) iterator
-                        .next();
-                log("checking " + currentmrid.toString(), Project.MSG_DEBUG);
-                if (currentmrid.getOrganisation().equals("org.apache.easyant")
-                        && currentmrid.getName().equals("easyant-core")) {
-                    CoreRevisionCheckerTask checker = new CoreRevisionCheckerTask();
-                    checker.setRequiredRevision(currentmrid.getRevision());
-                    initTask(checker).execute();
-                }
-            }
-        }
-    }
-
-    /**
-     * Can we skip the load of this module?
-     * 
-     * @param mandatory
-     *            true if the module can't be skipped
-     */
-    public void setMandatory(boolean mandatory) {
-        this.mandatory = mandatory;
-
-    }
-
-    public void setDynamicAttribute(String attributeName, String value)
-            throws BuildException {
-        PropertyTask property = new PropertyTask();
-        property.setName(attributeName);
-        property.setValue(value);
-        initTask(property).execute();
-    }
 }

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ImportTestModule.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ImportTestModule.java?rev=1364988&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ImportTestModule.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ImportTestModule.java Tue Jul 24 11:44:56 2012
@@ -0,0 +1,104 @@
+package org.apache.easyant.tasks;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
+
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.core.report.ResolveReport;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * Alternative Import module implementation. This implementation is designed for test purpose. It doesn't take in
+ * consideration : skipping module or buildConfiguration features.
+ * Example :
+ *  <pre>
+ * &lt;import-test-module moduleIvy="/path/to/module.ivy" /&gt;
+ * </pre>
+ * Same example specifying sourceDirectory 
+ * <pre>
+ * &lt;import-test-module moduleIvy="/path/to/module.ivy" sourceDirectory="/path/to/sourcedirectory"/&gt;
+ * </pre>
+ */
+public class ImportTestModule extends AbstractImport {
+
+    private File moduleIvy;
+    private File sourceDirectory;
+
+    public void execute() throws BuildException {
+        if (moduleIvy == null || !moduleIvy.exists()) {
+            throw new BuildException("moduleIvy is not specified, or the requested file doesn't exists");
+        }
+        if (sourceDirectory == null) {
+            throw new BuildException("sourceDirectory is not specified");
+        }
+        if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) {
+            throw new BuildException("sourceDirectory does not exists or is not a directory");
+        }
+
+        try {
+             
+            ResolveReport report = getEasyAntIvyInstance().getResolveEngine().resolve(moduleIvy);
+            //tiny hack report.getModuleDescriptor.getModuleRevisionId() return a caller instance
+            ModuleRevisionId moduleRevisionId =report.getModuleDescriptor().getAllArtifacts()[0].getModuleRevisionId();
+            importModule(moduleRevisionId,report);
+
+        } catch (ParseException e) {
+            throw new BuildException("Can't parse module descriptor", e);
+        } catch (IOException e) {
+            throw new BuildException("Can't parse module descriptor", e);
+        }
+
+    }
+
+    @Override
+    protected void importModule(ModuleRevisionId moduleRevisionId,ResolveReport report) {
+        // Check dependency on core
+        checkCoreCompliance(report, getProvidedConf());
+
+        Path path = createModulePath(moduleRevisionId);
+        File antFile = null;
+        // handle downloaded resources
+        for (int j = 0; j < report.getConfigurationReport(getMainConf()).getAllArtifactsReports().length; j++) {
+            ArtifactDownloadReport artifact = report.getConfigurationReport(getMainConf()).getAllArtifactsReports()[j];
+
+            if ("jar".equals(artifact.getType())) {
+                path.createPathElement().setLocation(artifact.getLocalFile());
+            }
+        }
+        // handle local resources (ant file, and all additional files such as properties)
+        for (int i = 0; i < report.getModuleDescriptor().getAllArtifacts().length; i++) {
+            Artifact artifact = report.getModuleDescriptor().getAllArtifacts()[i];
+            File localResourceFile = new File(sourceDirectory, artifact.getName() + "." + artifact.getExt());
+            if ("ant".equals(artifact.getType()) && "ant".equals(artifact.getExt())) {
+                antFile = localResourceFile;
+            } else {
+                handleOtherResourceFile(moduleRevisionId,artifact.getName(),artifact.getExt(), localResourceFile);
+            }
+        }
+        // do effective import
+        if (antFile != null && antFile.exists()) {
+            doEffectiveImport(antFile);
+        }
+    }
+
+    public File getModuleIvy() {
+        return moduleIvy;
+    }
+
+    public void setModuleIvy(File moduleIvy) {
+        this.moduleIvy = moduleIvy;
+    }
+
+    public File getSourceDirectory() {
+        return sourceDirectory;
+    }
+
+    public void setSourceDirectory(File sourceDirectory) {
+        this.sourceDirectory = sourceDirectory;
+    }
+
+}

Modified: incubator/easyant/core/trunk/src/main/resources/org/apache/easyant/antlib.xml
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/resources/org/apache/easyant/antlib.xml?rev=1364988&r1=1364987&r2=1364988&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/resources/org/apache/easyant/antlib.xml (original)
+++ incubator/easyant/core/trunk/src/main/resources/org/apache/easyant/antlib.xml Tue Jul 24 11:44:56 2012
@@ -20,6 +20,7 @@
     <taskdef name="parameter" classname="org.apache.easyant.tasks.ParameterTask"/>
     
     <taskdef name="import" classname="org.apache.easyant.tasks.Import"/>
+    <taskdef name="import-test-module" classname="org.apache.easyant.tasks.ImportTestModule"/>
     <taskdef name="loadmodule" classname="org.apache.easyant.tasks.LoadModule"/>
     <taskdef name="submodule" classname="org.apache.easyant.tasks.SubModule"/>
     <taskdef name="core-version" classname="org.apache.easyant.tasks.CoreRevisionCheckerTask"/>