incubator-easyant-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlboud...@apache.org
Subject svn commit: r1373376 - in /incubator/easyant/core/trunk/src/main/java/org/apache/easyant: core/EasyAntConstants.java core/EasyAntEngine.java core/EasyAntMagicNames.java tasks/LoadModule.java
Date Wed, 15 Aug 2012 12:47:34 GMT
Author: jlboudart
Date: Wed Aug 15 12:47:34 2012
New Revision: 1373376

URL: http://svn.apache.org/viewvc?rev=1373376&view=rev
Log:
Configure offline repository is done by easyant core itself

Modified:
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntConstants.java
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java

Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntConstants.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntConstants.java?rev=1373376&r1=1373375&r2=1373376&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntConstants.java
(original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntConstants.java
Wed Aug 15 12:47:34 2012
@@ -84,4 +84,15 @@ public interface EasyAntConstants {
      */
     public static final String BUILD_SCOPE_REPOSITORY = "project-build";
 
+    /**
+     * Default offline project repository name
+     */
+    public static final String DEFAULT_OFFLINE_PROJECT_RESOLVER = "project.buildscope.repository";
+
+    /**
+     * Default offline easyant repository name
+     */
+    public static final String DEFAULT_OFFLINE_EASYANT_RESOLVER = "easyant.buildscope.repository";
+
+    
 }

Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java?rev=1373376&r1=1373375&r2=1373376&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
(original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
Wed Aug 15 12:47:34 2012
@@ -37,6 +37,7 @@ import org.apache.easyant.core.factory.E
 import org.apache.easyant.core.ivy.IvyInstanceHelper;
 import org.apache.easyant.core.services.PluginService;
 import org.apache.easyant.core.services.impl.DefaultPluginServiceImpl;
+import org.apache.easyant.tasks.ConfigureBuildScopedRepository;
 import org.apache.easyant.tasks.Import;
 import org.apache.easyant.tasks.LoadModule;
 import org.apache.ivy.Ivy;
@@ -56,6 +57,7 @@ import org.apache.tools.ant.ProjectHelpe
 import org.apache.tools.ant.ProjectHelper.OnMissingExtensionPoint;
 import org.apache.tools.ant.PropertyHelper;
 import org.apache.tools.ant.Target;
+import org.apache.tools.ant.Task;
 import org.apache.tools.ant.input.DefaultInputHandler;
 import org.apache.tools.ant.input.InputHandler;
 import org.apache.tools.ant.util.ClasspathUtils;
@@ -63,8 +65,8 @@ import org.apache.tools.ant.util.FileUti
 import org.apache.tools.ant.util.ProxySetup;
 
 /**
- * This class provides everything you need to run easyant. This class should be
- * used to bootstrap easyant from IDE for example
+ * This class provides everything you need to run easyant. This class should be used to bootstrap
easyant from IDE for
+ * example
  */
 public class EasyAntEngine {
 
@@ -78,8 +80,7 @@ public class EasyAntEngine {
      * Default constructor will initialize the default configuration
      */
     public EasyAntEngine() {
-        this(EasyantConfigurationFactory.getInstance()
-                .createDefaultConfiguration());
+        this(EasyantConfigurationFactory.getInstance().createDefaultConfiguration());
     }
 
     /**
@@ -100,66 +101,49 @@ public class EasyAntEngine {
      */
     public Ivy configureEasyAntIvyInstance(Project project) {
         IvyConfigure easyantIvyConfigure = new IvyConfigure();
-        easyantIvyConfigure
-                .setSettingsId(EasyAntMagicNames.EASYANT_IVY_INSTANCE);
+        easyantIvyConfigure.setSettingsId(EasyAntMagicNames.EASYANT_IVY_INSTANCE);
 
-        project
-                .setNewProperty(
-                        EasyAntMagicNames.EASYANT_DEFAULT_IVYSETTINGS,
-                        this
-                                .getClass()
-                                .getResource(
-                                        "/org/apache/easyant/core/default-easyant-ivysettings.xml")
-                                .toExternalForm());
-        project
-                .setNewProperty(
-                        EasyAntMagicNames.EASYANT_EXTRA_IVYSETTINGS,
-                        this
-                                .getClass()
-                                .getResource(
-                                        "/org/apache/easyant/core/extra-easyant-ivysettings.xml")
-                                .toExternalForm());
+        project.setNewProperty(EasyAntMagicNames.EASYANT_DEFAULT_IVYSETTINGS,
+                this.getClass().getResource("/org/apache/easyant/core/default-easyant-ivysettings.xml")
+                        .toExternalForm());
+        project.setNewProperty(EasyAntMagicNames.EASYANT_EXTRA_IVYSETTINGS,
+                this.getClass().getResource("/org/apache/easyant/core/extra-easyant-ivysettings.xml").toExternalForm());
 
         project.setNewProperty(EasyAntMagicNames.EASYANT_CORE_JAR_URL, guessEasyantCoreJarUrl().toExternalForm());
 
         File userSettings = getUserEasyAntIvySettings(project);
         String globalSettings = getGlobalEasyAntIvySettings(project);
-        boolean isIgnoringUserIvysettings=Project.toBoolean(project.getProperty(EasyAntMagicNames.IGNORE_USER_IVYSETTINGS));
+        boolean isIgnoringUserIvysettings = Project.toBoolean(project
+                .getProperty(EasyAntMagicNames.IGNORE_USER_IVYSETTINGS));
 
         if (userSettings.exists() && !isIgnoringUserIvysettings) {
-            project.log("loading user's easyant ivysettings file from "
-                    + userSettings.getAbsolutePath(),Project.MSG_DEBUG);
+            project.log("loading user's easyant ivysettings file from " + userSettings.getAbsolutePath(),
+                    Project.MSG_DEBUG);
             easyantIvyConfigure.setFile(userSettings);
         } else if (globalSettings != null) {
-            project.log("loading global easyant ivysettings file from "
-                    + globalSettings,Project.MSG_DEBUG);
+            project.log("loading global easyant ivysettings file from " + globalSettings,
Project.MSG_DEBUG);
             try {
                 easyantIvyConfigure.setUrl(globalSettings);
             } catch (MalformedURLException malformedUrl) {
-                throw new BuildException(
-                        "Unable to parse easyant ivysettings from the following url : "
-                                + globalSettings, malformedUrl);
+                throw new BuildException("Unable to parse easyant ivysettings from the following
url : "
+                        + globalSettings, malformedUrl);
             }
 
         } else {
-            project.log("using easyant default ivy settings file",
-                    Project.MSG_VERBOSE);
-            String url = project
-                    .getProperty(EasyAntMagicNames.EASYANT_DEFAULT_IVYSETTINGS);
+            project.log("using easyant default ivy settings file", Project.MSG_VERBOSE);
+            String url = project.getProperty(EasyAntMagicNames.EASYANT_DEFAULT_IVYSETTINGS);
             try {
                 easyantIvyConfigure.setUrl(url);
             } catch (MalformedURLException malformedUrl) {
-                throw new BuildException(
-                        "Unable to parse easyant ivysettings from the following url : "
-                                + url, malformedUrl);
+                throw new BuildException("Unable to parse easyant ivysettings from the following
url : " + url,
+                        malformedUrl);
             }
         }
-        easyantIvyConfigure.setProject(project);
-        easyantIvyConfigure.setTaskName("configure-easyant");
-        easyantIvyConfigure.execute();
+        executeTask(easyantIvyConfigure, "configure-easyant", project);
 
-        IvyAntSettings ivyAntSettings = IvyInstanceHelper
-                .getEasyAntIvyAntSettings(project);
+        configureEasyAntOfflineRepository(project);
+
+        IvyAntSettings ivyAntSettings = IvyInstanceHelper.getEasyAntIvyAntSettings(project);
         return ivyAntSettings.getConfiguredIvyInstance(easyantIvyConfigure);
     }
 
@@ -208,15 +192,13 @@ public class EasyAntEngine {
      */
     private File getUserEasyAntIvySettings(Project project) {
         // path can be specified through a property
-        String path = project
-                .getProperty(EasyAntMagicNames.USER_EASYANT_IVYSETTINGS);
+        String path = project.getProperty(EasyAntMagicNames.USER_EASYANT_IVYSETTINGS);
         // if no property is set check the default location
         if (path == null) {
             path = PropertyHelper.getPropertyHelper(project).replaceProperties(
                     EasyAntConstants.DEFAULT_USER_EASYANT_IVYSETTINGS);
         }
-        project.log("user's easyant-ivysettings file : " + path,
-                Project.MSG_DEBUG);
+        project.log("user's easyant-ivysettings file : " + path, Project.MSG_DEBUG);
         return new File(path);
     }
 
@@ -228,56 +210,52 @@ public class EasyAntEngine {
      */
     private String getGlobalEasyAntIvySettings(Project project) {
         PropertyHelper helper = PropertyHelper.getPropertyHelper(project);
-        String path=null;
+        String path = null;
         if (configuration.getEasyantIvySettingsFile() != null) {
             File f = new File(helper.replaceProperties(configuration.getEasyantIvySettingsFile()));
             try {
-                path = f.toURL().toExternalForm();
+                path = f.toURI().toURL().toExternalForm();
             } catch (MalformedURLException e) {
-                throw new BuildException("Can't load easyant ivysettings file from "+ f.getAbsolutePath(),e);
+                throw new BuildException("Can't load easyant ivysettings file from " + f.getAbsolutePath(),
e);
             }
         }
         if (configuration.getEasyantIvySettingsUrl() != null) {
             path = helper.replaceProperties(configuration.getEasyantIvySettingsUrl());
         }
         // path can be specified through a property
-        if (path==null && project.getProperty(EasyAntMagicNames.GLOBAL_EASYANT_IVYSETTINGS)
!= null) {
-            path = project
-                    .getProperty(EasyAntMagicNames.GLOBAL_EASYANT_IVYSETTINGS);
+        if (path == null && project.getProperty(EasyAntMagicNames.GLOBAL_EASYANT_IVYSETTINGS)
!= null) {
+            path = project.getProperty(EasyAntMagicNames.GLOBAL_EASYANT_IVYSETTINGS);
         }
         // if no property is set check the default location
         if (path == null) {
-        	File defaultGlboalEasyAntIvySettings =  new File(helper.replaceProperties(
-                    EasyAntConstants.DEFAULT_GLOBAL_EASYANT_IVYSETTINGS));
-        	if (!defaultGlboalEasyAntIvySettings.exists()) {
-        		return null;
-        	}
-        	try {
-				path = defaultGlboalEasyAntIvySettings.toURL().toExternalForm();
-			} catch (MalformedURLException e) {
-				throw new BuildException("Can't load easyant ivysettings file from "+ defaultGlboalEasyAntIvySettings.getAbsolutePath(),e);
-			}
+            File defaultGlboalEasyAntIvySettings = new File(
+                    helper.replaceProperties(EasyAntConstants.DEFAULT_GLOBAL_EASYANT_IVYSETTINGS));
+            if (!defaultGlboalEasyAntIvySettings.exists()) {
+                return null;
+            }
+            try {
+                path = defaultGlboalEasyAntIvySettings.toURL().toExternalForm();
+            } catch (MalformedURLException e) {
+                throw new BuildException("Can't load easyant ivysettings file from "
+                        + defaultGlboalEasyAntIvySettings.getAbsolutePath(), e);
+            }
         }
-        project.log("global easyant-ivysettings file : " + path,
-                Project.MSG_DEBUG);
+        project.log("global easyant-ivysettings file : " + path, Project.MSG_DEBUG);
         return path;
     }
 
-    public void configurePluginService(Project project,
-            Ivy easyantIvyInstance) {
+    public void configurePluginService(Project project, Ivy easyantIvyInstance) {
         pluginService = new DefaultPluginServiceImpl(easyantIvyInstance);
-        project.addReference(EasyAntMagicNames.PLUGIN_SERVICE_INSTANCE,
-                pluginService);
+        project.addReference(EasyAntMagicNames.PLUGIN_SERVICE_INSTANCE, pluginService);
 
     }
 
     /**
-     * Adds the listeners specified in the command line arguments, along with
-     * the default listener, to the specified project.
+     * Adds the listeners specified in the command line arguments, along with the default
listener, to the specified
+     * project.
      * 
      * @param project
-     *            The project to add listeners to. Must not be <code>null</code>
-     *            .
+     *            The project to add listeners to. Must not be <code>null</code>
.
      */
     protected void addBuildListeners(Project project) {
 
@@ -285,11 +263,9 @@ public class EasyAntEngine {
         project.addBuildListener(createLogger());
 
         for (int i = 0; i < configuration.getListeners().size(); i++) {
-            String className = (String) configuration.getListeners().elementAt(
-                    i);
-            BuildListener listener = (BuildListener) ClasspathUtils
-                    .newInstance(className, EasyAntEngine.class
-                            .getClassLoader(), BuildListener.class);
+            String className = (String) configuration.getListeners().elementAt(i);
+            BuildListener listener = (BuildListener) ClasspathUtils.newInstance(className,
+                    EasyAntEngine.class.getClassLoader(), BuildListener.class);
             project.setProjectReference(listener);
 
             project.addBuildListener(listener);
@@ -303,8 +279,7 @@ public class EasyAntEngine {
      *            the project instance.
      * 
      * @exception BuildException
-     *                if a specified InputHandler implementation could not be
-     *                loaded.
+     *                if a specified InputHandler implementation could not be loaded.
      */
     protected void addInputHandler(Project project) {
         InputHandler handler = null;
@@ -312,9 +287,8 @@ public class EasyAntEngine {
         if (configuration.getInputHandlerClassname() == null) {
             handler = new DefaultInputHandler();
         } else {
-            handler = (InputHandler) ClasspathUtils.newInstance(configuration
-                    .getInputHandlerClassname(), Main.class.getClassLoader(),
-                    InputHandler.class);
+            handler = (InputHandler) ClasspathUtils.newInstance(configuration.getInputHandlerClassname(),
+                    Main.class.getClassLoader(), InputHandler.class);
             project.setProjectReference(handler);
         }
         project.setInputHandler(handler);
@@ -329,12 +303,10 @@ public class EasyAntEngine {
         BuildLogger logger = null;
         if (configuration.getLoggerClassname() != null) {
             try {
-                logger = (BuildLogger) ClasspathUtils.newInstance(configuration
-                        .getLoggerClassname(), EasyAntEngine.class
-                        .getClassLoader(), BuildLogger.class);
+                logger = (BuildLogger) ClasspathUtils.newInstance(configuration.getLoggerClassname(),
+                        EasyAntEngine.class.getClassLoader(), BuildLogger.class);
             } catch (BuildException e) {
-                throw new RuntimeException("The specified logger class "
-                        + configuration.getLoggerClassname()
+                throw new RuntimeException("The specified logger class " + configuration.getLoggerClassname()
                         + " could not be used because " + e.getMessage(), e);
             }
         } else {
@@ -352,23 +324,20 @@ public class EasyAntEngine {
     /**
      * Search parent directories for the build file.
      * <p>
-     * Takes the given target as a suffix to append to each parent directory in
-     * search of a build file. Once the root of the file-system has been reached
-     * an exception is thrown.
+     * Takes the given target as a suffix to append to each parent directory in search of
a build file. Once the root of
+     * the file-system has been reached an exception is thrown.
      * 
      * @param start
      *            Leaf directory of search. Must not be <code>null</code>.
      * @param suffix
-     *            Suffix filename to look for in parents. Must not be
-     *            <code>null</code>.
+     *            Suffix filename to look for in parents. Must not be <code>null</code>.
      * 
      * @return A handle to the build file if one is found
      * 
      * @exception BuildException
      *                if no build file is found
      */
-    protected File findBuildModule(String start, String suffix)
-            throws BuildException {
+    protected File findBuildModule(String start, String suffix) throws BuildException {
         if (configuration.getMsgOutputLevel() >= Project.MSG_INFO) {
             System.out.println("Searching for " + suffix + " ...");
         }
@@ -409,15 +378,12 @@ public class EasyAntEngine {
         // set the thread priorities
         if (configuration.getThreadPriority() != null) {
             try {
-                project.log("Setting Ant's thread priority to "
-                        + configuration.getThreadPriority(),
+                project.log("Setting Ant's thread priority to " + configuration.getThreadPriority(),
                         Project.MSG_VERBOSE);
-                Thread.currentThread().setPriority(
-                        configuration.getThreadPriority().intValue());
+                Thread.currentThread().setPriority(configuration.getThreadPriority().intValue());
             } catch (SecurityException swallowed) {
                 // we cannot set the priority here.
-                project
-                        .log("A security manager refused to set the -nice value");
+                project.log("A security manager refused to set the -nice value");
             }
         }
 
@@ -469,12 +435,9 @@ public class EasyAntEngine {
                 }
 
             }
-            project.log("Active build configurations : " + buildConfigurations,
-                    Project.MSG_INFO);
-            project.setProperty(EasyAntMagicNames.ACTIVE_BUILD_CONFIGURATIONS,
-                    buildConfigurations);
+            project.log("Active build configurations : " + buildConfigurations, Project.MSG_INFO);
+            project.setProperty(EasyAntMagicNames.ACTIVE_BUILD_CONFIGURATIONS, buildConfigurations);
         }
-
         // Load system plugins
         if (configuration.getSystemPlugins().size() > 0) {
             project.log("Loading System Plugins...");
@@ -489,102 +452,108 @@ public class EasyAntEngine {
             importTask.setAs(systemPlugin.getAs());
             importTask.setMode(systemPlugin.getMode());
             importTask.setMandatory(systemPlugin.isMandatory());
-            importTask.setProject(project);
-            importTask.setTaskName(EasyAntConstants.EASYANT_TASK_NAME);
-            importTask.setOwningTarget(ProjectUtils.createTopLevelTarget());
-            importTask.setLocation(mainscriptLocation);
-            importTask.execute();
+            executeTask(importTask, "configure-system-plugins", project);
         }
         File buildModule = configuration.getBuildModule();
         File buildFile = configuration.getBuildFile();
-        
-        if (project.getProperty("project.basedir")!=null) {
+
+        if (project.getProperty("project.basedir") != null) {
             project.setBaseDir(new File(project.getProperty("project.basedir")));
         }
 
         if (buildModule == null) {
-            buildModule = new File(project.getBaseDir(),EasyAntConstants.DEFAULT_BUILD_MODULE);
+            buildModule = new File(project.getBaseDir(), EasyAntConstants.DEFAULT_BUILD_MODULE);
         }
 
         if (!buildModule.exists() && configuration.isBuildModuleLookupEnabled())
{
-            buildModule = findBuildModule(System.getProperty("user.dir"),
-                    buildModule.toString());
+            buildModule = findBuildModule(System.getProperty("user.dir"), buildModule.toString());
         }
 
         // calculate buildFile location based on buildModule directory
         if (buildModule.exists() && buildFile == null) {
-            buildFile = new File(buildModule.getParentFile(),
-                    EasyAntConstants.DEFAULT_BUILD_FILE);
+            buildFile = new File(buildModule.getParentFile(), EasyAntConstants.DEFAULT_BUILD_FILE);
         }
 
         if (buildFile == null && configuration.isBuildModuleLookupEnabled()) {
-            buildFile = findBuildModule(System.getProperty("user.dir"),
-                    EasyAntConstants.DEFAULT_BUILD_FILE);
+            buildFile = findBuildModule(System.getProperty("user.dir"), EasyAntConstants.DEFAULT_BUILD_FILE);
         }
 
         // Normalize buildFile for re-import detection
         if (buildModule != null) {
-            buildModule = FileUtils.getFileUtils().normalize(
-                    buildModule.getAbsolutePath());
-            project.setNewProperty(EasyAntMagicNames.EASYANT_FILE, buildModule
-                    .getAbsolutePath());
+            buildModule = FileUtils.getFileUtils().normalize(buildModule.getAbsolutePath());
+            project.setNewProperty(EasyAntMagicNames.EASYANT_FILE, buildModule.getAbsolutePath());
 
         }
 
         if (buildFile != null) {
-            buildFile = FileUtils.getFileUtils().normalize(
-                    buildFile.getAbsolutePath());
-            project.setNewProperty(MagicNames.ANT_FILE, buildFile
-                    .getAbsolutePath());
+            buildFile = FileUtils.getFileUtils().normalize(buildFile.getAbsolutePath());
+            project.setNewProperty(MagicNames.ANT_FILE, buildFile.getAbsolutePath());
 
         }
 
         configuration.setBuildFile(buildFile);
         configuration.setBuildModule(buildModule);
 
-
-        if (configuration.getBuildModule() != null
-                || configuration.getBuildFile() != null) {
+        if (configuration.getBuildModule() != null || configuration.getBuildFile() != null)
{
             LoadModule lm = new LoadModule();
             lm.setBuildModule(configuration.getBuildModule());
             lm.setBuildFile(configuration.getBuildFile());
-            lm.setTaskName(EasyAntConstants.EASYANT_TASK_NAME);
-            lm.setProject(project);
-            lm.setOwningTarget(ProjectUtils.createTopLevelTarget());
-            lm.setLocation(mainscriptLocation);
-            lm.execute();
+            executeTask(lm, "load-module", project);
         }
-        
-        
+
         // FIXME:resolve extensionOf attributes this should be exposed by Apache Ant
         injectTargetIntoExtensionPoint(project, helper);
     }
 
+    /**
+     * Configure easyant offline repository 
+     * If offline mode is enabled, it will acts as dictator resolver
+     * @param project {@link Project} where repositories will be configured
+     */
+    private void configureEasyAntOfflineRepository(Project project) {
+        //assign default value if not already set
+        project.setProperty(EasyAntMagicNames.OFFLINE_EASYANT_RESOLVER, EasyAntConstants.DEFAULT_OFFLINE_EASYANT_RESOLVER);
+        project.setProperty(EasyAntMagicNames.OFFLINE_BASE_DIRECTORY, project.getBaseDir().getAbsolutePath()
+ "/offline/");
+      
+        ConfigureBuildScopedRepository easyantOfflineRepository = new ConfigureBuildScopedRepository();
+        easyantOfflineRepository.setGenerateWrapperResoler(false);
+        easyantOfflineRepository.setName(project.getProperty(EasyAntMagicNames.OFFLINE_EASYANT_RESOLVER));
+        easyantOfflineRepository.setDictator(Project.toBoolean(project.getProperty(EasyAntMagicNames.EASYANT_OFFLINE)));
+        easyantOfflineRepository.setSettingsRef(IvyInstanceHelper.buildEasyAntIvyReference(project));
+        easyantOfflineRepository.setTarget(project.getProperty(EasyAntMagicNames.OFFLINE_BASE_DIRECTORY));
+        executeTask(easyantOfflineRepository, "configure-offline-easyant-resolver", project);
+    }
+
+    private void executeTask(Task task, String operationName, Project project) {
+        Location location = new Location(ProjectUtils.emulateMainScript(project).getAbsolutePath());
+        task.setLocation(location);
+        task.setOwningTarget(ProjectUtils.createTopLevelTarget());
+        task.setProject(project);
+        task.setTaskName(EasyAntConstants.EASYANT_TASK_NAME + "-" + operationName);
+        task.execute();
+
+    }
+
     private void injectTargetIntoExtensionPoint(Project project, ProjectHelper helper) {
         for (Object extensionInfos : helper.getExtensionStack()) {
-            String[] extensionInfo = (String[])extensionInfos;
+            String[] extensionInfo = (String[]) extensionInfos;
             String tgName = extensionInfo[0];
             String name = extensionInfo[1];
             OnMissingExtensionPoint missingBehaviour = OnMissingExtensionPoint.FAIL;
             Hashtable projectTargets = project.getTargets();
             if (!projectTargets.containsKey(tgName)) {
-                String message = "can't add target " + name
-                    + " to extension-point " + tgName
-                    + " because the extension-point is unknown.";
+                String message = "can't add target " + name + " to extension-point " + tgName
+                        + " because the extension-point is unknown.";
                 if (missingBehaviour == OnMissingExtensionPoint.FAIL) {
                     throw new BuildException(message);
                 } else if (missingBehaviour == OnMissingExtensionPoint.WARN) {
                     Target target = (Target) projectTargets.get(name);
-                    project.log(target,
-                                             "Warning: " + message,
-                                             Project.MSG_WARN);
+                    project.log(target, "Warning: " + message, Project.MSG_WARN);
                 }
             } else {
                 Target t = (Target) projectTargets.get(tgName);
                 if (!(t instanceof ExtensionPoint)) {
-                    throw new BuildException("referenced target "
-                                             + tgName
-                                             + " is not an extension-point");
+                    throw new BuildException("referenced target " + tgName + " is not an
extension-point");
                 }
                 t.addDependency(name);
             }
@@ -601,7 +570,7 @@ public class EasyAntEngine {
         configureProject(project);
         initProject(project);
         doBuild(project);
-        
+
     }
 
     public void doBuild(final Project project) throws Error {
@@ -628,16 +597,13 @@ public class EasyAntEngine {
                     project.setDefaultInputStream(System.in);
                 }
                 System.setIn(new DemuxInputStream(project));
-                System.setOut(new PrintStream(new DemuxOutputStream(project,
-                        false)));
-                System.setErr(new PrintStream(new DemuxOutputStream(project,
-                        true)));
+                System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
+                System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
 
                 // make sure that we have a target to execute
                 if (configuration.getTargets().size() == 0) {
                     if (project.getDefaultTarget() != null) {
-                        configuration.getTargets().addElement(
-                                project.getDefaultTarget());
+                        configuration.getTargets().addElement(project.getDefaultTarget());
                     }
                 }
 
@@ -665,19 +631,16 @@ public class EasyAntEngine {
             } catch (Throwable t) {
                 // yes, I know it is bad style to catch Throwable,
                 // but if we don't, we lose valuable information
-                System.err.println("Caught an exception while logging the"
-                        + " end of the build.  Exception was:");
+                System.err.println("Caught an exception while logging the" + " end of the
build.  Exception was:");
                 t.printStackTrace();
                 if (error != null) {
-                    System.err.println("There has been an error prior to"
-                            + " that:");
+                    System.err.println("There has been an error prior to" + " that:");
                     error.printStackTrace();
                 }
                 throw new BuildException(t);
             }
         }
-        if (configuration.isShowMemoryDetails()
-                || configuration.getMsgOutputLevel() >= Project.MSG_VERBOSE) {
+        if (configuration.isShowMemoryDetails() || configuration.getMsgOutputLevel() >=
Project.MSG_VERBOSE) {
             printMemoryDetails(project);
         }
     }
@@ -689,15 +652,13 @@ public class EasyAntEngine {
      *            an easyant configuration
      * @throws BuildException
      */
-    public static void runBuild(EasyAntConfiguration eaConfig)
-            throws BuildException {
+    public static void runBuild(EasyAntConfiguration eaConfig) throws BuildException {
         EasyAntEngine eaEngine = new EasyAntEngine(eaConfig);
         eaEngine.doBuild();
     }
 
     /**
-     * This is a static method used to configure and initialize an existing
-     * project
+     * This is a static method used to configure and initialize an existing project
      * 
      * @param project
      *            a given project
@@ -706,8 +667,8 @@ public class EasyAntEngine {
      * @return configured project
      * @throws BuildException
      */
-    public static Project configureAndInitProject(Project project,
-            EasyAntConfiguration eaConfiguration) throws BuildException {
+    public static Project configureAndInitProject(Project project, EasyAntConfiguration eaConfiguration)
+            throws BuildException {
         EasyAntEngine eaEngine = new EasyAntEngine(eaConfiguration);
         eaEngine.configureProject(project);
         eaEngine.initProject(project);
@@ -723,13 +684,9 @@ public class EasyAntEngine {
     public static void printMemoryDetails(Project project) {
         project.log("---- Memory Details ----");
         project.log("  Used Memory  = "
-                + (Runtime.getRuntime().totalMemory() / MEGABYTE - Runtime
-                        .getRuntime().freeMemory()
-                        / MEGABYTE) + "MB");
-        project.log("  Free Memory  = "
-                + (Runtime.getRuntime().freeMemory() / MEGABYTE) + "MB");
-        project.log("  Total Memory = "
-                + (Runtime.getRuntime().totalMemory() / MEGABYTE) + "MB");
+                + (Runtime.getRuntime().totalMemory() / MEGABYTE - Runtime.getRuntime().freeMemory()
/ MEGABYTE) + "MB");
+        project.log("  Free Memory  = " + (Runtime.getRuntime().freeMemory() / MEGABYTE)
+ "MB");
+        project.log("  Total Memory = " + (Runtime.getRuntime().totalMemory() / MEGABYTE)
+ "MB");
         project.log("-----------------------");
     }
 
@@ -746,8 +703,7 @@ public class EasyAntEngine {
             Enumeration<?> e = configuration.getDefinedProps().keys();
             while (e.hasMoreElements()) {
                 String arg = (String) e.nextElement();
-                String value = (String) configuration.getDefinedProps()
-                        .get(arg);
+                String value = (String) configuration.getDefinedProps().get(arg);
                 project.setUserProperty(arg, value);
             }
             project.setName("EasyAnt");
@@ -765,12 +721,10 @@ public class EasyAntEngine {
     private static String easyantVersion = null;
 
     /**
-     * Returns the EasyAnt version information, if available. Once the
-     * information has been loaded once, it's cached and returned from the cache
-     * on future calls.
+     * Returns the EasyAnt version information, if available. Once the information has been
loaded once, it's cached and
+     * returned from the cache on future calls.
      * 
-     * @return the Ant version information as a String (always non-
-     *         <code>null</code>)
+     * @return the Ant version information as a String (always non- <code>null</code>)
      * 
      * @exception BuildException
      *                if the version information is unavailable
@@ -780,8 +734,7 @@ public class EasyAntEngine {
         if (easyantVersion == null) {
             try {
                 Properties props = new Properties();
-                InputStream in = Main.class
-                        .getResourceAsStream("/META-INF/version.properties");
+                InputStream in = Main.class.getResourceAsStream("/META-INF/version.properties");
                 props.load(in);
                 in.close();
 
@@ -792,12 +745,9 @@ public class EasyAntEngine {
                 msg.append(props.getProperty("DATE"));
                 easyantVersion = msg.toString();
             } catch (IOException ioe) {
-                throw new BuildException(
-                        "Could not load the version information:"
-                                + ioe.getMessage());
+                throw new BuildException("Could not load the version information:" + ioe.getMessage());
             } catch (NullPointerException npe) {
-                throw new BuildException(
-                        "Could not load the version information.");
+                throw new BuildException("Could not load the version information.");
             }
         }
         return easyantVersion;

Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java?rev=1373376&r1=1373375&r2=1373376&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java
(original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java
Wed Aug 15 12:47:34 2012
@@ -177,4 +177,21 @@ public interface EasyAntMagicNames {
      */
     public static final String IGNORE_USER_IVYSETTINGS = "ignore.user.ivysettings";
 
+    /***
+     * Property specifying offline project resolver name
+     * Value: {@value}
+     */
+    public static final String OFFLINE_PROJECT_RESOLVER = "project.buildscope.resolver";
+
+    /***
+     * Property specifying offline easyant resolver name
+     * Value: {@value}
+     */
+    public static final String OFFLINE_EASYANT_RESOLVER = "easyant.buildscope.resolver";
+
+    /**
+     * Property specifying offline base directory
+     * Value: {@value}
+     */
+    public static final String OFFLINE_BASE_DIRECTORY = "offline.base.directory";
 }

Modified: 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=1373376&r1=1373375&r2=1373376&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java Wed
Aug 15 12:47:34 2012
@@ -155,7 +155,7 @@ public class LoadModule extends Abstract
         if (!EasyAntMagicNames.EASYANT_IVY_INSTANCE
                 .equals(projectIvyInstanceProp)) {
             configureProjectIvyinstance(projectIvyInstanceProp);
-
+            configureProjectOfflineResolver();
         }
 
         if (shouldUseBuildRepository()) {
@@ -171,6 +171,22 @@ public class LoadModule extends Abstract
     }
 
     /**
+     * Configure project offline repository 
+     * If offline mode is enabled, it will acts as dictator resolver
+     * @param project {@link Project} where repository will be configured
+     */
+    private void configureProjectOfflineResolver() {
+        getProject().setProperty(EasyAntMagicNames.OFFLINE_PROJECT_RESOLVER, EasyAntConstants.DEFAULT_OFFLINE_PROJECT_RESOLVER);
+        ConfigureBuildScopedRepository projectOfflineRepository = new ConfigureBuildScopedRepository();
+        projectOfflineRepository.setGenerateWrapperResoler(false);
+        projectOfflineRepository.setName(getProject().getProperty(EasyAntMagicNames.OFFLINE_PROJECT_RESOLVER));
+        projectOfflineRepository.setDictator(Project.toBoolean(getProject().getProperty(EasyAntMagicNames.EASYANT_OFFLINE)));
+        projectOfflineRepository.setSettingsRef(IvyInstanceHelper.buildProjectIvyReference(getProject()));
+        projectOfflineRepository.setTarget(getProject().getProperty(EasyAntMagicNames.OFFLINE_BASE_DIRECTORY));
+        initTask(projectOfflineRepository).execute();
+    }
+
+    /**
      * 
      */
     private void configureProjectIvyinstance(String projectIvyInstanceName) {



Mime
View raw message