incubator-easyant-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1071697 [21/42] - in /incubator/easyant: buildtypes/ buildtypes/trunk/ buildtypes/trunk/build-osgi-bundle-java/ buildtypes/trunk/build-osgi-bundle-java/src/ buildtypes/trunk/build-osgi-bundle-java/src/main/ buildtypes/trunk/build-osgi-bund...
Date Thu, 17 Feb 2011 17:01:56 GMT
Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CheckResolver.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CheckResolver.java?rev=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CheckResolver.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CheckResolver.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,111 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant.tasks;
+
+import org.apache.ivy.ant.IvyTask;
+import org.apache.tools.ant.BuildException;
+
+/**
+ * This task is responsible of checking existance of a resolver in a given ivy instance
+ *
+ */
+public class CheckResolver extends IvyTask {
+	
+	private String resolver;
+	
+	private String description;
+
+	@Override
+	public void doExecute() throws BuildException {
+		if (resolver ==null || resolver.equals("")) {
+			throw new BuildException("resolver attribute is mandatory");
+		}
+		String resolverProperty = getProject().getProperty(resolver);
+		if (resolverProperty==null) {
+			throw new BuildException("Can't check resolvers :Unknown property " + resolver);
+		}
+		if (!getSettings().getResolverNames().contains(resolverProperty)) {
+			StringBuilder sb = new StringBuilder();
+			sb.append("resolver ").append(resolverProperty);
+			sb.append(" does not exist in current project, please check your project ivysettings.xml file.");
+			sb.append("\n");
+			if (getDescription() != null) {
+				sb.append(resolver);
+				sb.append(" : ");
+				sb.append(getDescription());
+				sb.append("\n");
+			}
+			sb.append("Available resolvers : ");
+			sb.append(getSettings().getResolverNames().toString());
+			throw new BuildException(sb.toString());
+		}
+		
+	}
+
+	/**
+	 * Get property resolver name to check
+	 * @return the property name representing the resolver 
+	 */
+	public String getResolver() {
+		return resolver;
+	}
+
+	/**
+	 * Set the property resolver name to check
+	 * @param resolver a property name representing the resolver 
+	 */
+	public void setResolver(String resolver) {
+		this.resolver = resolver;
+	}
+	
+	/**
+	 * Get a description to the property / path / phase
+	 * @return the description
+	 */
+	public String getDescription() {
+		return description;
+	}
+
+	/**
+	 * set a description to the property / path / phase
+	 * @param description the description
+	 */
+	public void setDescription(String description) {
+		this.description = description;
+	}
+	
+	/**
+	 * Appends CDATA text inside the Ant task to description
+	 * @see #setDescription(String)
+	 */
+	public void addText(String descriptionText) {
+		if (descriptionText.trim().length() > 0) {
+			descriptionText = getProject().replaceProperties(descriptionText);
+			if (getDescription() == null) {
+				setDescription(descriptionText);
+			} else {
+				setDescription(getDescription()+descriptionText);
+			}
+		}
+	}
+
+
+	
+	
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CheckResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CheckResolver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CheckResolver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ConfigureBuildScopedRepository.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ConfigureBuildScopedRepository.java?rev=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ConfigureBuildScopedRepository.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ConfigureBuildScopedRepository.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,171 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+
+package org.apache.easyant.tasks;
+
+import java.io.File;
+
+import org.apache.easyant.core.EasyAntMagicNames;
+import org.apache.ivy.ant.IvyTask;
+import org.apache.ivy.core.cache.DefaultRepositoryCacheManager;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.resolver.ChainResolver;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.apache.ivy.plugins.resolver.FileSystemResolver;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * This task is used to configure a build scoped repository This can be
+ * particularly usefull if we are working in a multi-module project with
+ * interdependencies.
+ * 
+ */
+public class ConfigureBuildScopedRepository extends IvyTask {
+
+	private String buildScopedRepositoryName = "build";
+	private boolean dictator=false;
+
+	private String target;
+
+	/**
+	 * Get the build scoped repository name
+	 * 
+	 * @return a build scoped repository name
+	 */
+	public String getBuildScopedRepositoryName() {
+		return buildScopedRepositoryName;
+	}
+
+	/**
+	 * Set the build scoped repository name
+	 * 
+	 * @param buildScopedRepositoryName
+	 *            a build scoped repository name
+	 */
+	public void setBuildScopedRepositoryName(String buildScopedRepositoryName) {
+		this.buildScopedRepositoryName = buildScopedRepositoryName;
+	}
+
+	/**
+	 * Get the target directory where both build scoped repository and cache
+	 * will be instanciated
+	 * 
+	 * @return a target directory
+	 */
+	public String getTarget() {
+		if (target == null) {
+			target = getProject().getProperty(EasyAntMagicNames.TARGET);
+			if (target == null) {
+				target = getProject().getBaseDir() + "/target";
+			}
+		}
+		return target;
+	}
+
+	/**
+	 * 
+	 * Set the target directory where both build scoped repository and cache
+	 * will be instanciated
+	 * 
+	 * @param target
+	 *            a target directory
+	 */
+	public void setTarget(String target) {
+		this.target = target;
+	}
+	
+	/**
+	 * Is the build scoped repository a dictator resolver?
+	 * @return true if build scoped repository is a dictator resolver
+	 */
+	public boolean isDictator() {
+		return dictator;
+	}
+
+	/**
+	 * Set the build scoped repository as a dictator resolver
+	 * @param dictator true if build scoped repository is a dictator resolver
+	 */
+	public void setDictator(boolean dictator) {
+		this.dictator = dictator;
+	}
+
+	@Override
+	public void doExecute() throws BuildException {
+		String target = getTarget();
+		// be sure that we have an absolute path
+		File targetDir = new File(target);
+		target = targetDir.getAbsolutePath();
+
+		final String DEFAULT_BUILD_SCOPED_REPOSITORY_DIR = target
+				+ "/repository";
+		final String DEFAULT_CACHE_BUILD_SCOPED_REPO = target + "/cache";
+		getProject().log(
+				"Registering build scoped repository in "
+						+ DEFAULT_BUILD_SCOPED_REPOSITORY_DIR,
+				Project.MSG_DEBUG);
+		final String CACHENAME = "build-scoped-cache";
+		// Get the project ivy instance
+		IvySettings settings = getSettings();
+
+		// Create a cache for build scoped repository
+		File cacheDir = new File(DEFAULT_CACHE_BUILD_SCOPED_REPO);
+		DefaultRepositoryCacheManager rcm = new DefaultRepositoryCacheManager(
+				CACHENAME, settings, cacheDir);
+		rcm.setUseOrigin(true); // no need to copy temporary build artifacts
+								// into temporary cache.
+		// Register the repository cache
+		settings.addConfigured(rcm);
+
+		// Create the build scoped repository
+		FileSystemResolver buildRepository = new FileSystemResolver();
+		buildRepository.setName(buildScopedRepositoryName);
+		buildRepository
+				.addArtifactPattern(DEFAULT_BUILD_SCOPED_REPOSITORY_DIR
+						+ "/[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]");
+		buildRepository.addIvyPattern(DEFAULT_BUILD_SCOPED_REPOSITORY_DIR
+				+ "/[organisation]/[module]/[revision]/[module].ivy");
+		// bind to the repocache
+		buildRepository.setCache(CACHENAME);
+		settings.addResolver(buildRepository);
+
+		// Bind to the default resolver
+		DependencyResolver dr = settings.getDefaultResolver();
+		if (dr == null) {
+			throw new BuildException("Unable to find a default resolver");
+		}
+
+		// wrap the default resolver in a chain resolver, which first checks
+		// the build-scoped repository.
+		String globalResolver = buildScopedRepositoryName + ".wrapper";
+
+		ChainResolver resolver = new ChainResolver();
+		resolver.setName(globalResolver);
+		resolver.setReturnFirst(true);
+		resolver.add(buildRepository);
+		resolver.add(dr);
+
+		settings.addResolver(resolver);
+		if (dictator)
+			settings.setDictatorResolver(resolver);
+
+	}
+
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ConfigureBuildScopedRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ConfigureBuildScopedRepository.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ConfigureBuildScopedRepository.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CoreRevisionCheckerTask.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CoreRevisionCheckerTask.java?rev=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CoreRevisionCheckerTask.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CoreRevisionCheckerTask.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,159 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+
+package org.apache.easyant.tasks;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.easyant.core.EasyAntMagicNames;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+/**
+ * <p>
+ * The core-version task is used to define the compatibility between core and
+ * modules.
+ * </p>
+ * <p>
+ * This tasks support :
+ * <ul>
+ * <li>static version (Example : 0.5)</li>
+ * <li>dynamic version (Example : latest.revision) even if we do not recommend
+ * to use it</li>
+ * <li>listed version (Example : (0.1,0.3,0.5))</li>
+ * <li>range version (Example : [0.5,0.8] means from 0.5 to 0.8. Example2 :
+ * [0.5,+] means all version superior to 0.5)</li>
+ * </ul>
+ * </p>
+ */
+public class CoreRevisionCheckerTask extends AbstractEasyAntTask {
+
+	private String requiredRevision;
+	private String message;
+
+	/**
+	 * Set the error message to display if the core revision check fails.
+	 */
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	/**
+	 * Appends CDATA text inside the Ant task to the error message used if
+	 * the revision check fails.
+	 * @see #setMessage(String)
+	 */
+	public void addText(String messageText) {
+		if (messageText.trim().length() > 0) {
+			messageText = getProject().replaceProperties(messageText);
+			if (this.message == null) {
+				this.message = messageText;
+			} else {
+				this.message += messageText;
+			}
+		}
+	}
+	
+	/**
+	 * Get the requiredRevision
+	 * 
+	 * @return a string that represent the required revision
+	 */
+	public String getRequiredRevision() {
+		return requiredRevision;
+	}
+
+	/**
+	 * Set the requiredRevision
+	 * 
+	 * @param requiredRevision
+	 *            a string that represent the required revision
+	 */
+	public void setRequiredRevision(String requiredRevision) {
+		this.requiredRevision = requiredRevision;
+	}
+	
+	private static String easyantSpecVersion = null;
+	public static synchronized String getEasyAntSpecVersion() throws BuildException {
+		if (easyantSpecVersion == null) {
+			try {
+				Properties props = new Properties();
+				InputStream in = CoreRevisionCheckerTask.class
+						.getResourceAsStream("/META-INF/version.properties");
+				props.load(in);
+				in.close();
+				easyantSpecVersion = props.getProperty("SPEC-VERSION");
+			} catch (IOException ioe) {
+				throw new BuildException(
+						"Could not load the version information:"
+								+ ioe.getMessage());
+			} catch (NullPointerException npe) {
+				throw new BuildException(
+						"Could not load the version information.");
+			}
+		} 
+		return easyantSpecVersion;
+	}
+
+	public void execute() throws BuildException {
+		if (requiredRevision == null) {
+			throw new BuildException("requiredRevision argument is required!");
+		}
+
+		if (getProject().getProperty(
+				EasyAntMagicNames.SKIP_CORE_REVISION_CHECKER) != null
+				&& "true".equals(getProject().getProperty(
+						EasyAntMagicNames.SKIP_CORE_REVISION_CHECKER))) {
+			log(
+					"core revision checker is disabled, this should not append in production.",
+					Project.MSG_DEBUG);
+			return;
+		}
+
+		String easyantVersion = getEasyAntSpecVersion();
+		if (easyantVersion == null) {
+			throw new BuildException("Unable to find easyant version.");
+		}
+		ModuleRevisionId easyantMrid = ModuleRevisionId
+				.parse("org.apache.ant#easyant;" + easyantVersion);
+		ModuleRevisionId requiredMrid = ModuleRevisionId
+				.parse("org.apache.ant#easyant;" + requiredRevision);
+		
+		
+		// Should we loop on each VersionMatchers?
+		if (!getEasyAntIvyInstance().getSettings().getVersionMatcher()
+				.accept(requiredMrid, easyantMrid)) {
+			throw new BuildException(getErrorMessage());
+		}
+
+	}
+
+	protected String getErrorMessage() {
+		if (message != null) {
+			return message;
+		} else {
+			//no custom message provided, return default error message.
+			return "This module requires easyant " + requiredRevision;
+		}
+	}
+	
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CoreRevisionCheckerTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CoreRevisionCheckerTask.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CoreRevisionCheckerTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java?rev=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,121 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+
+package org.apache.easyant.tasks;
+
+import java.io.File;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.easyant.core.EasyAntConfiguration;
+import org.apache.easyant.core.EasyAntEngine;
+import org.apache.easyant.core.factory.EasyantConfigurationFactory;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class EasyAntRunner extends Task {
+
+	private boolean fork = true;
+
+	private EasyAntConfiguration easyantConfiguration = new EasyAntConfiguration();
+
+	@Override
+	public void execute() throws BuildException {
+		EasyAntEngine eaEngine = new EasyAntEngine(getEasyantConfiguration());
+		if (fork)  {
+			eaEngine.doBuild();
+		} else {
+			eaEngine.initProject(getProject());
+			getProject().executeTargets(getEasyantConfiguration().getTargets());
+		}
+	}
+
+	public boolean isFork() {
+		return fork;
+	}
+
+	public void setFork(boolean fork) {
+		this.fork = fork;
+	}
+
+	public void setTargets(String targets) {
+		String[] targetsArray = targets.split(",");
+		for (int i = 0; i < targetsArray.length; i++) {
+			getEasyantConfiguration().getTargets().add(targetsArray[i]);
+		}
+	}
+
+	public void setConfigurationFile(String configurationFile) {
+		File f = new File(configurationFile);
+		try {
+			EasyantConfigurationFactory.getInstance()
+					.createConfigurationFromFile(getEasyantConfiguration(),
+							f.toURL());
+		} catch (Exception e) {
+			throw new BuildException(
+					"Can't create easyantConfiguration from File "
+							+ configurationFile, e);
+		}
+	}
+
+	public void setConfigurationUrl(String configurationUrl) {
+		try {
+			URL url = new URL(configurationUrl);
+			EasyantConfigurationFactory
+					.getInstance()
+					.createConfigurationFromFile(getEasyantConfiguration(), url);
+
+		} catch (Exception e) {
+			throw new BuildException(
+					"Can't create easyantConfiguration from URL "
+							+ configurationUrl, e);
+		}
+	}
+
+	public void setBuildConfiguration(String buildConfiguration) {
+		String[] buildConfs = buildConfiguration.split(",");
+		Set<String> buildConfigurations = new HashSet<String>();
+		for (String conf : buildConfs) {
+			buildConfigurations.add(conf);
+		}
+		getEasyantConfiguration().setActiveBuildConfigurations(
+				buildConfigurations);
+	}
+
+	public void setModuleIvy(String moduleIvy) {
+		File f = new File(moduleIvy);
+		getEasyantConfiguration().setBuildModule(f);
+	}
+
+	public void setModuleAnt(String moduleAnt) {
+		File f = new File(moduleAnt);
+		getEasyantConfiguration().setBuildFile(f);
+	}
+
+	public EasyAntConfiguration getEasyantConfiguration() {
+		return easyantConfiguration;
+	}
+
+	public void setEasyantConfiguration(
+			EasyAntConfiguration easyantConfiguration) {
+		this.easyantConfiguration = easyantConfiguration;
+	}
+
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,643 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+
+package org.apache.easyant.tasks;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Iterator;
+
+import org.apache.easyant.core.BuildConfigurationHelper;
+import org.apache.easyant.core.EasyAntMagicNames;
+import org.apache.easyant.core.ivy.IvyInstanceHelper;
+import org.apache.ivy.Ivy;
+import org.apache.ivy.ant.IvyAntSettings;
+import org.apache.ivy.core.LogOptions;
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+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 an EasyAnt module, such as a buildtype
+ * or plugin. The module is located using one of three methods:
+ * <ol>
+ * <li>A full Ivy Module Revision ID is specified with {@link #setMrid(String)
+ * mrid}. The Ivy descriptor and other artifacts for the module are then located
+ * in Ivy repositories.</li>
+ * <li>Module Revision ID is specified with the {@link #setOrganisation(String)
+ * org}, {@link #setModule(String) module}, and {@link #setRevision(String) rev}
+ * attributes.</li>
+ * <li>a filesystem path to the module Ivy descriptor is given with
+ * {@link #setFile(String) file}. Other module artifacts (Ant scripts, etc) are
+ * assumed to be in the same parent directory as this file.</li>
+ * </ol>
+ * 
+ * <p>
+ * The include mechanism is similar to the Ant import task, excepts that it
+ * automatically prefix all targets of the module ant script with the value of
+ * {@link #setAs(String) as} attribute. The prefix used by default is the name
+ * of the imported project, but it can be overridden when calling "include".
+ * This is useful to use features provided by many build modules, while
+ * preserving a namespace isolation to avoid collisions.
+ * </p>
+ * 
+ * <p>
+ * While possible, overriding a target defined in an included module is not
+ * recommended. To do so, the normal Ant import mechanism is preferred.
+ * </p>
+ */
+public class Import extends AbstractEasyAntTask implements DynamicAttribute {
+
+	private String module;
+	private String organisation;
+	private String revision;
+
+	private String mrid;
+
+	private String file;
+	private String settingsRef;
+
+	private String as;
+	private String mode;
+	private boolean mandatory;
+	private String buildConfigurations;
+
+	private String mainConf = "default";
+	private String providedConf = "provided";
+
+	/**
+	 * Get the module name to import
+	 * 
+	 * @return the module name
+	 */
+	public String getModule() {
+		return module;
+	}
+
+	/**
+	 * Set the module name to import
+	 * 
+	 * @param module
+	 *            the module name
+	 */
+	public void setModule(String module) {
+		this.module = module;
+	}
+
+	/**
+	 * Get the organisation of the module to import
+	 * 
+	 * @return the organisation name
+	 */
+	public String getOrganisation() {
+		return organisation;
+	}
+
+	/**
+	 * Set the organisation of the module to import
+	 * 
+	 * @param organisation
+	 *            the organisation name
+	 */
+	public void setOrganisation(String organisation) {
+		this.organisation = organisation;
+	}
+
+	/**
+	 * Set the organisation of the module to import
+	 * 
+	 * @param organisation
+	 *            the organisation name
+	 */
+	public void setOrg(String org) {
+		this.organisation = org;
+	}
+
+	/**
+	 * Get the revision of the module to import
+	 * 
+	 * @return the revision
+	 */
+	public String getRevision() {
+		return revision;
+	}
+
+	/**
+	 * Set th revision of the module to import
+	 * 
+	 * @param revision
+	 *            the revision
+	 */
+	public void setRevision(String revision) {
+		this.revision = revision;
+	}
+
+	/**
+	 * Set th revision of the module to import
+	 * 
+	 * @param revision
+	 *            the revision
+	 */
+	public void setRev(String rev) {
+		this.revision = rev;
+	}
+
+	/**
+	 * Get the full mrid of the module to import
+	 * 
+	 * @return the mrid to import
+	 */
+	public String getMrid() {
+		return mrid;
+	}
+
+	/**
+	 * Set the full mrid of the module to import
+	 * 
+	 * @param mrid
+	 *            the mrid to import
+	 */
+	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;
+	}
+
+	public String getFile() {
+		return file;
+	}
+
+	/**
+	 * Set the filesystem location of the module descriptor to load. This is an
+	 * alternative to specifying a repository location using
+	 * {@link #setMrid(String)} or {@link #setModule(String)}
+	 */
+	public void setFile(String file) {
+		this.file = file;
+	}
+
+	public String getSettingsRef() {
+		return settingsRef;
+	}
+
+	/**
+	 * Optionally specify the Ivy settings instance used to resolve module
+	 * dependencies and publications. If unspecified, the EasyAnt Ivy settings
+	 * are used.
+	 */
+	public void setSettingsRef(String settingsRef) {
+		this.settingsRef = settingsRef;
+	}
+
+	/**
+	 * 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 {
+
+		ImportStrategy strategy = null;
+		if (mrid != null) {
+			strategy = new RepositoryImportStrategy(ModuleRevisionId
+					.parse(mrid));
+		} else if (organisation != null && module != null && revision != null) {
+			strategy = new RepositoryImportStrategy(ModuleRevisionId
+					.newInstance(organisation, module, revision));
+		} else if (file != null) {
+			strategy = new FileImportStrategy(new File(file));
+		} else {
+
+			throw new BuildException(
+					"You must specify exactly ONE of:  mrid, organisation + module + revision, or file");
+		}
+		String moduleName = strategy.getModuleName();
+		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) {
+				ModuleRevisionId moduleRevisionId=ModuleRevisionId.parse(mrid);
+				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 = strategy.isSkipped()
+				|| 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 {
+				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 = strategy.resolveModule(resolveOptions);
+				// Check dependency on core
+				checkCoreCompliance(report, providedConf);
+
+				ModuleRevisionId moduleRevisionId = strategy
+						.getModuleRevisionId(report);
+
+				Path path = new Path(getProject());
+				getProject().addReference(
+						moduleRevisionId.getModuleId().toString()
+								+ ".classpath", path);
+				File antFile = strategy.findAntScript(mainConf, report);
+				for (int j = 0; j < report.getConfigurationReport(mainConf)
+						.getAllArtifactsReports().length; j++) {
+					ArtifactDownloadReport artifact = report
+							.getConfigurationReport(mainConf)
+							.getAllArtifactsReports()[j];
+
+					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;
+
+	}
+
+	/**
+	 * Get the Ivy instance used to load the module artifacts.
+	 * 
+	 * @see #setSettingsRef(String)
+	 */
+	private Ivy getIvyInstance() {
+		if (settingsRef != null) {
+			IvyAntSettings settings = IvyInstanceHelper.getIvyAntSettings(getProject(),settingsRef);
+			if (settings == null) {
+				throw new BuildException("Unable to find Ivy settings named '"
+						+ settingsRef + "'");
+			}
+			return settings.getConfiguredIvyInstance(this);
+		} else {
+			return getEasyAntIvyInstance();
+		}
+	}
+
+	/**
+	 * Abstracts the mechanism used to locate a single module Ivy descriptor and
+	 * its artifacts.
+	 */
+	private static interface ImportStrategy {
+
+		/**
+		 * Resolve the module using the given resolution options.
+		 */
+		public ResolveReport resolveModule(ResolveOptions options)
+				throws ParseException, IOException;
+
+		public ModuleRevisionId getModuleRevisionId(ResolveReport report);
+
+		public File findAntScript(String conf, ResolveReport report);
+
+		/**
+		 * Get this module's name, for logging purposes.
+		 */
+		public String getModuleName();
+
+		/**
+		 * @return true if this module should not be imported.
+		 */
+		public boolean isSkipped();
+
+	}
+
+	/**
+	 * Load the requested module and its artifacts from an Ivy repository.
+	 */
+	private class RepositoryImportStrategy implements ImportStrategy {
+		private ModuleRevisionId mrid;
+
+		protected RepositoryImportStrategy(ModuleRevisionId mrid) {
+			this.mrid = mrid;
+		}
+
+		public ModuleRevisionId getModuleRevisionId(ResolveReport report) {
+			return mrid;
+		}
+
+		public ResolveReport resolveModule(ResolveOptions options)
+				throws ParseException, IOException {
+            Ivy ivy = getIvyInstance();
+            ivy.pushContext();
+            try {
+                return ivy.getResolveEngine().resolve(mrid, options, !options.isUseCacheOnly());
+            } finally {
+                ivy.popContext();
+            }
+		}
+
+		public String getModuleName() {
+			return mrid.toString();
+		}
+
+		public boolean isSkipped() {
+			return getProject().getProperty("skip." + getModuleName()) != null;
+		}
+
+		public File findAntScript(String conf, ResolveReport report) {
+			for (int j = 0; j < report.getConfigurationReport(conf)
+					.getAllArtifactsReports().length; j++) {
+				ArtifactDownloadReport artifact = report
+						.getConfigurationReport(conf).getAllArtifactsReports()[j];
+
+				if ("ant".equals(artifact.getType())
+						&& "ant".equals(artifact.getExt())) {
+					return artifact.getLocalFile();
+				}
+			}
+			return null;
+		}
+	}
+
+	/**
+	 * Load the requested module and its artifacts directly from the filesystem.
+	 */
+	private class FileImportStrategy implements ImportStrategy {
+		private File descriptorFile;
+
+		private FileImportStrategy(File descriptorFile) {
+			this.descriptorFile = descriptorFile;
+		}
+
+		public ModuleRevisionId getModuleRevisionId(ResolveReport report) {
+			return report.getModuleDescriptor().getModuleRevisionId();
+		}
+
+		public ResolveReport resolveModule(ResolveOptions options)
+				throws ParseException, IOException {
+			return getIvyInstance().getResolveEngine().resolve(
+					descriptorFile.toURL(), options);
+		}
+
+		public String getModuleName() {
+			return descriptorFile.getAbsolutePath();
+		}
+
+		public boolean isSkipped() {
+			return false;
+		}
+
+		public File findAntScript(String conf, ResolveReport report) {
+			ModuleDescriptor descriptor = report.getModuleDescriptor();
+			Artifact[] artifacts = descriptor.getArtifacts(conf);
+			for (int i = 0; i < artifacts.length; ++i) {
+				Artifact artifact = artifacts[i];
+				if ("ant".equals(artifact.getType())
+						&& "ant".equals(artifact.getExt())) {
+					File file = getLocalArtifact(artifact.getName(), artifact
+							.getExt());
+					if (file.isFile()) {
+						return file;
+					}
+				}
+			}
+			return null;
+		}
+
+		private File getLocalArtifact(String name, String ext) {
+			return new File(descriptorFile.getParentFile(), name + "." + ext);
+		}
+	}
+
+	@Override
+	public void setDynamicAttribute(String attributeName, String value)
+			throws BuildException {
+		PropertyTask property = new PropertyTask();
+		property.setName(attributeName);
+		property.setValue(value);
+		initTask(property).execute();
+	}
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/Import.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java?rev=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,540 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant.tasks;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.easyant.core.BuildConfigurationHelper;
+import org.apache.easyant.core.EasyAntConstants;
+import org.apache.easyant.core.EasyAntMagicNames;
+import org.apache.easyant.core.descriptor.AdvancedInheritableItem;
+import org.apache.easyant.core.descriptor.EasyAntModuleDescriptor;
+import org.apache.easyant.core.descriptor.PhaseMappingDescriptor;
+import org.apache.easyant.core.descriptor.PluginDescriptor;
+import org.apache.easyant.core.descriptor.PropertyDescriptor;
+import org.apache.easyant.core.ivy.InheritableScope;
+import org.apache.easyant.core.ivy.IvyInstanceHelper;
+import org.apache.easyant.core.parser.DefaultEasyAntXmlModuleDescriptorParser;
+import org.apache.easyant.core.parser.EasyAntModuleDescriptorParser;
+import org.apache.ivy.Ivy;
+import org.apache.ivy.ant.IvyAntSettings;
+import org.apache.ivy.ant.IvyConfigure;
+import org.apache.ivy.ant.IvyInfo;
+import org.apache.ivy.core.cache.DefaultRepositoryCacheManager;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
+import org.apache.ivy.plugins.repository.url.URLResource;
+import org.apache.ivy.plugins.resolver.ChainResolver;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.apache.ivy.plugins.resolver.FileSystemResolver;
+import org.apache.ivy.util.StringUtils;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.ImportTask;
+
+/**
+ * This task is the main class, used to parse module.ivy and execute the all the
+ * statement behind the easyant tag.
+ */
+public class LoadModule extends AbstractEasyAntTask {
+
+	private File buildFile;
+	private File buildModule;
+	private String easyAntMDParserClassName;
+	private Boolean useBuildRepository;
+
+	/**
+	 * Get the file name that will be loaded
+	 * 
+	 * @return a file that represents a module descriptor
+	 */
+	public File getBuildModule() {
+		return buildModule;
+	}
+
+	/**
+	 * set the file name that will be loaded
+	 * 
+	 * @param file
+	 *            represents a module descriptor
+	 */
+	public void setBuildModule(File file) {
+		this.buildModule = file;
+	}
+
+	public File getBuildFile() {
+		return buildFile;
+	}
+
+	public void setBuildFile(File buildFile) {
+		this.buildFile = buildFile;
+	}
+
+	public void setUseBuildRepository(boolean value) {
+		this.useBuildRepository = value;
+	}
+
+	/**
+	 * Set the classname of the easyant parser you want to use
+	 * 
+	 * @param easyAntMDParserClassName
+	 */
+	public void setEasyAntMDParserClassName(String easyAntMDParserClassName) {
+		this.easyAntMDParserClassName = easyAntMDParserClassName;
+	}
+
+	public void execute() throws BuildException {
+		if (buildModule != null && buildModule.exists()) {
+			IvyInfo info = new IvyInfo();
+			info.setFile(buildModule);
+			// Not sure we should bound IvyInfo to easyantIvyInstance
+			info.setSettingsRef(IvyInstanceHelper
+					.buildEasyAntIvyReference(getProject()));
+			initTask(info).execute();
+			getProject().setName(getProject().getProperty("ivy.module"));
+		}
+		if (buildModule != null && buildModule.exists()) {
+			// make sure it's not a directory (this falls into the ultra
+			// paranoid lets check everything category
+
+			if (buildModule.isDirectory()) {
+				System.out.println("What? buildModule: " + buildModule
+						+ " is a dir!");
+				throw new BuildException("Build failed");
+			}
+			// load override buildFile before buildModule to allow target/phase
+			// override
+			File f = new File(buildModule.getParent(),
+					EasyAntConstants.DEFAULT_OVERRIDE_BUILD_FILE);
+			if (f.exists()) {
+				log("Loading override build file : "
+						+ buildFile.getAbsolutePath());
+				loadBuildFile(f);
+			}
+
+			log("Loading build module : " + buildModule.getAbsolutePath());
+			loadBuildModule(buildModule);
+		}
+
+		// load buildFile before buildModule to allow target/phase override
+		if (buildFile != null && buildFile.exists()) {
+			// make sure it's not a directory (this falls into the ultra
+			// paranoid lets check everything category
+
+			if (buildFile.isDirectory()) {
+				System.out.println("What? buildFile: " + buildFile
+						+ " is a dir!");
+				throw new BuildException("Build failed");
+			}
+
+			log("Loading build file : " + buildFile.getAbsolutePath());
+			loadBuildFile(buildFile);
+		}
+
+		String projectIvyInstanceProp = IvyInstanceHelper
+				.getProjectIvyInstanceName(getProject());
+
+		// create project ivy instance except if project ivy instance is linked
+		// to easyant ivy instance
+		if (!EasyAntMagicNames.EASYANT_IVY_INSTANCE
+				.equals(projectIvyInstanceProp)) {
+			configureProjectIvyinstance(projectIvyInstanceProp);
+
+		}
+
+		if (shouldUseBuildRepository()) {
+			configureBuildRepository(IvyInstanceHelper
+					.getProjectIvyAntSettings(getProject()));
+		}
+
+		if (getProject().getDefaultTarget() == null
+				&& getProject().getTargets().containsKey(
+						EasyAntConstants.DEFAULT_TARGET)) {
+			getProject().setDefault(EasyAntConstants.DEFAULT_TARGET);
+		}
+	}
+
+	/**
+	 * 
+	 */
+	private void configureProjectIvyinstance(String projectIvyInstanceName) {
+		IvyConfigure projectIvyInstance = new IvyConfigure();
+		projectIvyInstance.setSettingsId(projectIvyInstanceName);
+		if (getProject()
+				.getProperty(EasyAntMagicNames.PROJECT_IVY_SETTING_FILE) != null) {
+			File projectIvyFile = new File(getProject().getProperty(
+					EasyAntMagicNames.PROJECT_IVY_SETTING_FILE));
+			projectIvyInstance.setFile(projectIvyFile);
+		}
+		if (getProject().getProperty(EasyAntMagicNames.PROJECT_IVY_SETTING_URL) != null) {
+			String url = getProject().getProperty(
+					EasyAntMagicNames.PROJECT_IVY_SETTING_URL);
+			try {
+				projectIvyInstance.setUrl(url);
+			} catch (MalformedURLException malformedUrl) {
+				throw new BuildException(
+						"Unable to parse project ivysettings from the following url : "
+								+ url, malformedUrl);
+			}
+		}
+		String defaultUrl = this.getClass().getResource(
+				"/org/apache/easyant/core/default-project-ivysettings.xml")
+				.toExternalForm();
+		getProject().setNewProperty(
+				EasyAntMagicNames.PROJECT_DEFAULT_IVYSETTINGS, defaultUrl);
+		if (getProject()
+				.getProperty(EasyAntMagicNames.PROJECT_IVY_SETTING_FILE) == null
+				&& getProject().getProperty(
+						EasyAntMagicNames.PROJECT_IVY_SETTING_URL) == null) {
+			File localSettings = new File(buildModule.getParent(),
+					"ivysettings.xml");
+			if (localSettings.exists()) {
+				getProject().log("loading local project settings file...",
+						Project.MSG_VERBOSE);
+				projectIvyInstance.setFile(localSettings);
+				getProject().setNewProperty(
+						EasyAntMagicNames.PROJECT_IVY_SETTING_FILE,
+						localSettings.getAbsolutePath());
+
+			} else {
+				getProject().log("no settings file found, using default...",
+						Project.MSG_VERBOSE);
+				getProject().setNewProperty(
+						EasyAntMagicNames.PROJECT_IVY_SETTING_URL,
+						defaultUrl.toString());
+				try {
+					projectIvyInstance.setUrl(defaultUrl);
+				} catch (MalformedURLException e) {
+					throw new BuildException(
+							"Unable to parse project ivysettings from the following url : "
+									+ defaultUrl, e);
+				}
+			}
+		}
+		initTask(projectIvyInstance).execute();
+	}
+
+	protected void loadBuildFile(File buildModule) {
+		ImportTask importTask = new ImportTask();
+		importTask.setFile(buildModule.getAbsolutePath());
+		importTask.setOptional(true);
+		initTask(importTask).execute();
+	}
+
+	protected void loadBuildModule(File buildModule) {
+		EasyAntModuleDescriptorParser parser = getEasyAntModuleDescriptorParser(buildModule);
+		log(
+				"Loading EasyAnt module descriptor :"
+						+ parser.getClass().getName(), Project.MSG_DEBUG);
+
+		try {
+			parser.setActiveBuildConfigurations(getProject().getProperty(
+					EasyAntMagicNames.ACTIVE_BUILD_CONFIGURATIONS));
+			parser.parseDescriptor(getEasyAntIvyInstance().getSettings(),
+					buildModule.toURL(), new URLResource(buildModule.toURL()),
+					true);
+			EasyAntModuleDescriptor md = parser.getEasyAntModuleDescriptor();
+			ModuleRevisionId currentModule = md.getIvyModuleDescriptor()
+					.getModuleRevisionId();
+
+			String buildConfigurations = null;
+			for (String conf : md.getBuildConfigurations()) {
+				if (buildConfigurations == null) {
+					buildConfigurations = conf;
+				} else {
+					buildConfigurations = buildConfigurations + "," + conf;
+				}
+			}
+			getProject().setProperty(
+					EasyAntMagicNames.AVAILABLE_BUILD_CONFIGURATIONS,
+					buildConfigurations);
+			updateMainConfs();
+
+			for (Iterator<PropertyDescriptor> iterator = md.getProperties()
+					.values().iterator(); iterator.hasNext();) {
+				PropertyDescriptor property = iterator.next();
+				if (canInherit(property, currentModule)) {
+					PropertyTask propTask = new PropertyTask();
+					propTask.setName(property.getName());
+					propTask.setValue(property.getValue());
+					propTask.setBuildConfigurations(property
+							.getBuildConfigurations());
+					initTask(propTask).execute();
+				}
+			}
+			if (md.getBuildType() != null) {
+				Import importTask = new Import();
+				importTask.setMrid(md.getBuildType());
+				initTask(importTask).execute();
+			}
+			for (Iterator<?> iterator = md.getPlugins().iterator(); iterator
+					.hasNext();) {
+				PluginDescriptor plugin = (PluginDescriptor) iterator.next();
+
+				if (canInherit(plugin, currentModule)) {
+					Import importTask = new Import();
+					importTask.setMrid(plugin.getMrid());
+					importTask.setMode(plugin.getMode());
+					importTask.setAs(plugin.getAs());
+					importTask.setMandatory(plugin.isMandatory());
+					importTask.setBuildConfigurations(plugin
+							.getBuildConfigurations());
+					initTask(importTask).execute();
+				}
+			}
+			// Apply PhaseMapping
+			for (PhaseMappingDescriptor phaseMapping : md.getPhaseMappings()) {
+				BindTarget bindTarget = new BindTarget();
+				bindTarget.setTarget(phaseMapping.getTarget());
+				bindTarget.setToPhase(phaseMapping.getToPhase());
+				bindTarget.setBuildConfigurations(phaseMapping
+						.getBuildConfigurations());
+				initTask(bindTarget).execute();
+			}
+		} catch (Exception e) {
+			throw new BuildException("problem while parsing Ivy module file: "
+					+ e.getMessage(), e);
+		}
+	}
+
+	/**
+	 * Check if an inheritable item can be inherited by verifying
+	 * {@link InheritableScope}
+	 * 
+	 * @param inheritableItem
+	 *            a given {@link AdvancedInheritableItem}
+	 * @param currentModule
+	 *            current module
+	 * @return true if item can be inherited
+	 */
+	private boolean canInherit(AdvancedInheritableItem inheritableItem,
+			ModuleRevisionId currentModule) {
+		if (currentModule.equals(inheritableItem.getSourceModule())) {
+			return !InheritableScope.CHILD.equals(inheritableItem
+					.getInheritScope()); 
+		} else {
+			return true;
+		}
+	
+	}
+
+	/**
+	 * This method is in charge to update the main.confs property with all the
+	 * active build configuration for the current project.
+	 */
+	private void updateMainConfs() {
+		if (getProject().getProperty(
+				EasyAntMagicNames.AVAILABLE_BUILD_CONFIGURATIONS) == null
+				|| getProject().getProperty(
+						EasyAntMagicNames.ACTIVE_BUILD_CONFIGURATIONS) == null) {
+			return;
+		}
+
+		List<String> availableBuildConfigurations = Arrays.asList(getProject()
+				.getProperty(EasyAntMagicNames.AVAILABLE_BUILD_CONFIGURATIONS)
+				.split(","));
+		// remove spaces in active confs
+		String activeConfs = getProject().getProperty(
+				EasyAntMagicNames.ACTIVE_BUILD_CONFIGURATIONS);
+		List<String> activeBuildConfigurations = BuildConfigurationHelper
+				.buildList(activeConfs);
+		List<String> mainConfsList = new ArrayList<String>();
+		for (String conf : activeBuildConfigurations) {
+			if (availableBuildConfigurations.contains(conf)) {
+				mainConfsList.add(conf);
+			} else {
+				log("removing unused configuration " + conf, Project.MSG_DEBUG);
+			}
+		}
+		if (mainConfsList.size() > 0) {
+			String mainConfs = StringUtils.join(mainConfsList
+					.toArray(new String[0]), ",");
+			log("updating main.confs with active profile for current project :"
+					+ mainConfs, Project.MSG_DEBUG);
+			getProject().setProperty(EasyAntMagicNames.MAIN_CONFS, mainConfs);
+		}
+
+	}
+
+	protected EasyAntModuleDescriptorParser getEasyAntModuleDescriptorParser(
+			File file) throws BuildException {
+		ModuleDescriptorParser mdp = null;
+		EasyAntModuleDescriptorParser parser = null;
+		try {
+			mdp = ModuleDescriptorParserRegistry.getInstance().getParser(
+					new URLResource(file.toURL()));
+		} catch (MalformedURLException e) {
+			throw new BuildException("Impossible to find a parser for "
+					+ file.getName());
+		}
+		// If valid easyant parser is defined use it
+		if (mdp != null
+				&& mdp.getClass().isInstance(
+						EasyAntModuleDescriptorParser.class)) {
+			return (EasyAntModuleDescriptorParser) mdp;
+		} else {
+			// if the user has customized the loadmodule task
+			if (easyAntMDParserClassName != null) {
+
+				try {
+					Class<? extends EasyAntModuleDescriptorParser> c = Class
+							.forName(easyAntMDParserClassName).asSubclass(
+									EasyAntModuleDescriptorParser.class);
+					log("Creating instance of " + easyAntMDParserClassName,
+							Project.MSG_DEBUG);
+					parser = c.newInstance();
+					ModuleDescriptorParserRegistry.getInstance().addParser(
+							parser);
+					return parser;
+				} catch (Exception e) {
+					throw new BuildException("Unable to load "
+							+ easyAntMDParserClassName, e);
+				}
+
+			}
+			// the default one
+			log("Creating instance of "
+					+ DefaultEasyAntXmlModuleDescriptorParser.class.getName(),
+					Project.MSG_DEBUG);
+			parser = new DefaultEasyAntXmlModuleDescriptorParser();
+
+			ModuleDescriptorParserRegistry.getInstance().addParser(parser);
+			return parser;
+
+		}
+	}
+
+	/**
+	 * @return true if this module should use a build-scoped repository and
+	 *         cache to find artifacts generated by other modules in the same
+	 *         build.
+	 */
+	private boolean shouldUseBuildRepository() {
+		// if a value has been provided by task attribute, return it
+		if (useBuildRepository != null) {
+			return useBuildRepository;
+		}
+		// otherwise, look for a value in property configuration, defaulting to
+		// false if no value.
+		return Project.toBoolean(getProject().getProperty(
+				EasyAntMagicNames.USE_BUILD_REPOSITORY));
+	}
+
+	/**
+	 * Change the given Ivy settings to use a local build-scoped repository and
+	 * cache by default. This allows submodules to access each others' artifacts
+	 * before they have been published to a shared repository.
+	 */
+	private void configureBuildRepository(IvyAntSettings projectSettings)
+			throws BuildException {
+		String target = getProject().getProperty(EasyAntMagicNames.META_TARGET);
+		if (target == null) {
+			target = getProject().getProperty(EasyAntMagicNames.TARGET);
+		}
+		if (target == null) {
+			target = getProject().getBaseDir() + "/target";
+		}
+
+		// be sure that we have an absolute path
+		File targetDir = new File(target);
+		target = targetDir.getAbsolutePath();
+
+		final String DEFAULT_BUILD_SCOPED_REPOSITORY_DIR = target
+				+ "/repository";
+		final String DEFAULT_CACHE_BUILD_SCOPED_REPO = target + "/cache";
+		getProject().log(
+				"Registering build scoped repository in "
+						+ DEFAULT_BUILD_SCOPED_REPOSITORY_DIR,
+				Project.MSG_DEBUG);
+		final String CACHENAME = "build-scoped-cache";
+		// Get the project ivy instance
+		Ivy ivy = projectSettings.getConfiguredIvyInstance(this);
+		IvySettings settings = ivy.getSettings();
+
+		// Search the default resolver after the build-scoped repo
+		DependencyResolver dr = settings.getDefaultResolver();
+		if (dr == null) {
+			throw new BuildException("Unable to find a default resolver");
+		}
+		resetDefaultResolver(settings);
+
+		// Create a cache for build scoped repository
+		File cacheDir = new File(DEFAULT_CACHE_BUILD_SCOPED_REPO);
+		DefaultRepositoryCacheManager rcm = new DefaultRepositoryCacheManager(
+				CACHENAME, settings, cacheDir);
+		rcm.setUseOrigin(true); // no need to copy temporary build artifacts
+		// into temporary cache.
+		// Register the repository cache
+		settings.addConfigured(rcm);
+
+		// Create the build scoped repository
+		FileSystemResolver buildRepository = new FileSystemResolver();
+		buildRepository.setName("build." + dr.getName());
+		buildRepository
+				.addArtifactPattern(DEFAULT_BUILD_SCOPED_REPOSITORY_DIR
+						+ "/[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]");
+		buildRepository.addIvyPattern(DEFAULT_BUILD_SCOPED_REPOSITORY_DIR
+				+ "/[organisation]/[module]/[revision]/[module].ivy");
+		// bind to the repocache
+		buildRepository.setCache(CACHENAME);
+
+		getProject().setProperty(EasyAntMagicNames.EASYANT_BUILD_REPOSITORY,
+				buildRepository.getName());
+
+		// replace the default resolver with a chain resolver, which first
+		// searches
+		// in the build repository, then in the old default.
+		ChainResolver resolver = new ChainResolver();
+		resolver.setName(dr.getName()); // same name as old default
+		resolver.setReturnFirst(true);
+		resolver.add(buildRepository);
+		resolver.add(dr);
+		dr.setName("delegate." + dr.getName()); // give old default a new name
+
+		settings.addResolver(buildRepository);
+		settings.addResolver(dr);
+		settings.addResolver(resolver);
+	}
+
+	/**
+	 * Clear the default resolver on the given IvySettings. This is a workaround
+	 * for <a href="http://issues.apache.org/jira/browse/IVY-1163">Ivy issue
+	 * 1163</a>. This code should be removed when the issue is resolved.
+	 */
+	private void resetDefaultResolver(IvySettings settings)
+			throws BuildException {
+		try {
+			Field cachedResolver = IvySettings.class
+					.getDeclaredField("defaultResolver");
+			cachedResolver.setAccessible(true);
+			cachedResolver.set(settings, null);
+		} catch (Exception e) {
+			throw new BuildException(
+					"Unable to reset default resolver on IvySettings", e);
+		}
+	}
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java?rev=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,197 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant.tasks;
+
+import org.apache.easyant.core.ant.Phase;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Property;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * parameter tasks is used to :
+ * 
+ * 			document properties / paths / phases 
+ * 			check if properties /paths / phases are required 
+ * 			set default values if properties are not set
+ * 
+ * This could be usefull in precondition of each modules, to check if
+ * property/phase/path are set. And much more usefull to document our modules.
+ * 
+ */
+public class ParameterTask extends Task {
+	private String property;
+	private String path;
+	private String phase;
+
+	private String description;
+	private String defaultValue;
+	private boolean required;
+
+	/**
+	 * Get a description to the property / path / phase
+	 * @return the description
+	 */
+	public String getDescription() {
+		return description;
+	}
+
+	/**
+	 * set a description to the property / path / phase
+	 * @param description the description
+	 */
+	public void setDescription(String description) {
+		this.description = description;
+	}
+	
+	/**
+	 * Appends CDATA text inside the Ant task to description
+	 * @see #setDescription(String)
+	 */
+	public void addText(String descriptionText) {
+		if (descriptionText.trim().length() > 0) {
+			descriptionText = getProject().replaceProperties(descriptionText);
+			if (getDescription() == null) {
+				setDescription(descriptionText);
+			} else {
+				setDescription(getDescription()+descriptionText);
+			}
+		}
+	}
+
+	/**
+	 * Get the property name to check
+	 * @return a property name
+	 */
+	public String getProperty() {
+		return property;
+	}
+
+	/**
+	 * Set the property name to check
+	 * @param property a property name
+	 */
+	public void setProperty(String property) {
+		this.property = property;
+	}
+
+	/**
+	 * Get the path to check
+	 * @return a pathId 
+	 */
+	public String getPath() {
+		return path;
+	}
+
+	/**
+	 * Set the path to check
+	 * @param path
+	 */
+	public void setPath(String path) {
+		this.path = path;
+	}
+
+	/**
+	 * Get a phase to check
+	 * @return a phase name
+	 */
+	public String getPhase() {
+		return phase;
+	}
+
+	/**
+	 * Set the path to check
+	 * @param phase a phase name 
+	 */
+	public void setPhase(String phase) {
+		this.phase = phase;
+	}
+
+	/**
+	 * Get the default value (only available for property)
+	 * @return a string that represents the default value
+	 */
+	public String getDefault() {
+		return defaultValue;
+	}
+
+	/**
+	 * Set the default value (only  available for property)
+	 * @param defaultValue a string that represents the default value
+	 */
+	public void setDefault(String defaultValue) {
+		this.defaultValue = defaultValue;
+	}
+
+	/**
+	 * Is the refererenced property / path required?
+	 * @return
+	 */
+	public boolean isRequired() {
+		return required;
+	}
+
+	/**
+	 * specify if the property / path is mandatory
+	 * @param required
+	 */
+	public void setRequired(boolean required) {
+		this.required = required;
+	}
+
+	public void execute() throws BuildException {
+		if (property != null) {
+			if (required && getProject().getProperty(property) == null) {
+				throw new BuildException("expected property '" + property
+						+ "': " + description);
+			}
+			if (defaultValue != null
+					&& getProject().getProperty(property) == null) {
+				Property propTask = new Property();
+				propTask.setProject(getProject());
+				propTask.setTaskName(getTaskName());
+				propTask.setName(property);
+				propTask.setValue(defaultValue);
+				propTask.execute();
+			}
+		} else if (phase != null) {
+			Target p = (Target) getProject().getTargets().get(phase);
+			if (p == null) {
+				throw new BuildException("expected phase '" + phase + "': "
+						+ description);
+			} else if (!(p instanceof Phase)) {
+				throw new BuildException("target '" + phase
+						+ "' must be a phase rather than a target");
+			}
+		} else if (path != null) {
+			Object p = getProject().getReference(path);
+			if (required && p == null) {
+				throw new BuildException("expected path '" + path + "': "
+						+ description);
+			} else if (!(p instanceof Path)) {
+				throw new BuildException("reference '" + path
+						+ "' must be a path");
+			}
+		} else {
+			throw new BuildException(
+					"at least one of these attributes is required: property, path, phase");
+		}
+	}
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PathTask.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PathTask.java?rev=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PathTask.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PathTask.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,147 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant.tasks;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.DirSet;
+import org.apache.tools.ant.types.FileList;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Path.PathElement;
+
+/**
+ * This task defines or contributes to an existing path. 
+ * This task is similar to path task provided by ant but add 
+ * an override attribute with these values:
+ * 		true: new definition will take precedence over preceding one if any 
+ * 		false: new definition will be discarded if any definition already exists 
+ * 		append: new definition will be added to the existing one if any 
+ * 		prepend: new definition will be added at the beginning of the existing one if any
+ */
+public class PathTask extends Task {
+	public static final String OVERWRITE_TRUE = "true";
+	public static final String OVERWRITE_FALSE = "false";
+	public static final String OVERWRITE_PREPEND = "prepend";
+	public static final String OVERWRITE_APPEND = "append";
+
+	private String pathid;
+
+	private String overwrite;
+
+	private Path path;
+
+	public void setProject(Project project) {
+		super.setProject(project);
+		path = new Path(project);
+	}
+
+	public void execute() throws BuildException {
+		if (pathid == null) {
+			throw new BuildException("pathid is mandatory");
+		}
+		Object element = getProject().getReference(pathid);
+		if (element == null) {
+			if (OVERWRITE_PREPEND.equals(overwrite)
+					|| OVERWRITE_APPEND.equals(overwrite)) {
+				throw new BuildException("destination path not found: "
+						+ pathid);
+			}
+			getProject().addReference(pathid, path);
+		} else {
+			if (OVERWRITE_FALSE.equals(overwrite)) {
+				return;
+			}
+			if (!(element instanceof Path)) {
+				throw new BuildException("destination path is not a path: "
+						+ element.getClass());
+			}
+			if (OVERWRITE_TRUE.equals(overwrite)) {
+				getProject().addReference(pathid, path);
+			} else {
+				Path dest = (Path) element;
+				if (OVERWRITE_PREPEND.equals(overwrite)) {
+					// no way to add path elements at te beginning of the
+					// existing path: we do the opposite
+					// and replace the reference
+					path.append(dest);
+					getProject().addReference(pathid, path);
+				} else { // OVERWRITE_APPEND
+					dest.append(path);
+				}
+			}
+		}
+	}
+
+	public void add(Path path) throws BuildException {
+		this.path.add(path);
+	}
+
+	public void addDirset(DirSet dset) throws BuildException {
+		path.addDirset(dset);
+	}
+
+	public void addFilelist(FileList fl) throws BuildException {
+		path.addFilelist(fl);
+	}
+
+	public void addFileset(FileSet fs) throws BuildException {
+		path.addFileset(fs);
+	}
+
+	public Path createPath() throws BuildException {
+		return path.createPath();
+	}
+
+	public PathElement createPathElement() throws BuildException {
+		return path.createPathElement();
+	}
+
+	/**
+	 * Get a path id 
+	 * @return a pathId
+	 */
+	public String getPathid() {
+		return pathid;
+	}
+
+	/**
+	 * @param pathid a pathId 
+	 */
+	public void setPathid(String pathid) {
+		this.pathid = pathid;
+	}
+
+	/**
+	 * return a string which define if a path is overwritable (Possible values are true/false/append/prepend)
+	 * @return Possible values are true/false/append/prepend
+	 */
+	public String getOverwrite() {
+		return overwrite;
+	}
+
+	/**
+	 * specify if easyant should overwrite the path (Possible values are true/false/append/prepend)
+	 * @param overwrite Possible values are true/false/append/prepend
+	 */
+	public void setOverwrite(String overwrite) {
+		this.overwrite = overwrite;
+	}
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PathTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PathTask.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PathTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java?rev=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,67 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant.tasks;
+
+import org.apache.easyant.core.BuildConfigurationHelper;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Property;
+
+/**
+ * This task is similar to the Property task provided by ant except that you can
+ * specify build configurations If no build configurations are specified the
+ * property will be loaded in all cases, otherwise the property will be loaded
+ * only if the build configuration is active
+ * 
+ */
+public class PropertyTask extends Property {
+
+	private String buildConfigurations = null;
+
+	@Override
+	public void execute() throws BuildException {
+		//Build the message
+		StringBuilder message= new StringBuilder("property ");
+		if (getName() != null ) {
+			message.append(getName());
+		}
+		if (getFile()!=null) {
+			message.append("file ").append(getFile());
+		}
+		
+		if (BuildConfigurationHelper.isBuildConfigurationActive(getBuildConfigurations(), getProject(), message.toString())) {
+			super.execute();
+		} else {
+				log("this property will be skipped ", Project.MSG_DEBUG);
+		}
+	}
+
+	public String getBuildConfigurations() {
+		return buildConfigurations;
+	}
+
+	public void setBuildConfigurations(String confs) {
+		this.buildConfigurations = confs;
+	}
+	
+	public void setConf(String conf) {
+		this.buildConfigurations = conf;
+	}
+
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java?rev=1071697&view=auto
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java (added)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java Thu Feb 17 17:01:07 2011
@@ -0,0 +1,125 @@
+/* 
+ *  Copyright 2008-2010 the EasyAnt project
+ * 
+ *  See the NOTICE file distributed with this work for additional information
+ *  regarding copyright ownership. 
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software 
+ *  distributed under the License is distributed on an "AS IS" BASIS, 
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and 
+ *  limitations under the License.
+ */
+package org.apache.easyant.tasks;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ivy.ant.IvyPostResolveTask;
+import org.apache.ivy.core.cache.ResolutionCacheManager;
+import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.MDArtifact;
+import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorWriter;
+import org.apache.tools.ant.BuildException;
+
+public class RegisterArtifact extends IvyPostResolveTask {
+
+	private String name;
+	private String type;
+	private String ext;
+	private String conf="*";
+	private String classifier;
+	
+	@Override
+	public void doExecute() throws BuildException {
+		prepareAndCheck();
+		DefaultModuleDescriptor md= (DefaultModuleDescriptor) getResolvedReport().getModuleDescriptor();
+
+		 // this is a published artifact
+		String artName = getSettings().substitute(getName());
+		artName = artName == null ? md.getModuleRevisionId().getName() : artName;
+		String type = getSettings().substitute(getType());
+		type = type == null ? "jar" : type;
+		String ext = getSettings().substitute(getExt());
+		ext = ext != null ? ext : type;
+		Map<String,String>  extraAttributes = new  HashMap<String,String>();
+		if (getClassifier()!=null) {
+			md.addExtraAttributeNamespace("m", "http://ant.apache.org/ivy/maven");
+			extraAttributes.put("m:classifier", getClassifier());
+		}
+
+		MDArtifact artifact = new MDArtifact(md, artName, type, ext, null, extraAttributes);
+		if ("*".equals(getConf())) {
+			 String[] confs = md.getConfigurationsNames();
+			 for (int i = 0; i < confs.length; i++) {
+			 artifact.addConfiguration(confs[i]);
+			 md.addArtifact(confs[i], artifact);
+			 }
+		} else {
+			 artifact.addConfiguration(getConf());
+			 md.addArtifact(getConf(), artifact);
+		} 
+		
+		
+		
+		ResolutionCacheManager cacheManager= getSettings().getResolutionCacheManager();
+		File ivyFileInCache = cacheManager.getResolvedIvyFileInCache(md.getResolvedModuleRevisionId());
+		try {
+			XmlModuleDescriptorWriter.write(md, ivyFileInCache);
+		} catch (IOException e) {
+			throw new BuildException("Can't register specified artifact",e);
+		}
+		
+	}
+	
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getExt() {
+		return ext;
+	}
+
+	public void setExt(String ext) {
+		this.ext = ext;
+	}
+
+	public String getConf() {
+		return conf;
+	}
+
+	public void setConf(String conf) {
+		this.conf = conf;
+	}
+
+	public String getClassifier() {
+		return classifier;
+	}
+
+	public void setClassifier(String classifier) {
+		this.classifier = classifier;
+	}
+	
+	 
+
+}

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message