incubator-easyant-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlboud...@apache.org
Subject svn commit: r1375125 - in /incubator/easyant/core/trunk/src/main/java/org/apache/easyant: core/EasyAntMagicNames.java tasks/ParameterTask.java
Date Mon, 20 Aug 2012 17:33:29 GMT
Author: jlboudart
Date: Mon Aug 20 17:33:28 2012
New Revision: 1375125

URL: http://svn.apache.org/viewvc?rev=1375125&view=rev
Log:
Add audit.mode property, if set required attribute will not be evaluated by ParameterTask
this would be useful for pluginService

Modified:
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java
    incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java

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=1375125&r1=1375124&r2=1375125&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
Mon Aug 20 17:33:28 2012
@@ -49,39 +49,33 @@ public interface EasyAntMagicNames {
     public static final String PROJECT_IVY_INSTANCE = "project.ivy.instance";
 
     /**
-     * Name of the property that contains the project ivy setting file Value: *
-     * {@value}
+     * Name of the property that contains the project ivy setting file Value: * * {@value}
      */
     public static final String PROJECT_IVY_SETTING_FILE = "project.ivy.settings.file";
 
     /**
-     * Name of the property that contains the project ivy setting url Value: *
-     * {@value}
+     * Name of the property that contains the project ivy setting url Value: * * {@value}
      */
     public static final String PROJECT_IVY_SETTING_URL = "project.ivy.settings.url";
 
     /**
-     * Name of the property that contains active build configuration Value: *
-     * {@value}
+     * Name of the property that contains active build configuration Value: * * {@value}
      */
     public static final String ACTIVE_BUILD_CONFIGURATIONS = "active.build.configurations";
 
     /**
-     * Name of the property that contains all active build configuration for the
-     * current project Value: {@value}
+     * Name of the property that contains all active build configuration for the current
project Value: {@value}
      */
     public static final String MAIN_CONFS = "main.confs";
 
     /**
-     * Name of the property that contains build configuration available in
-     * current project Value: {@value}
+     * Name of the property that contains build configuration available in current project
Value: {@value}
      */
     public static final String AVAILABLE_BUILD_CONFIGURATIONS = "available.build.configurations";
 
     /**
-     * Property name used to disable core revision check if this property is set
-     * to true it means that corerevision checker feature will be disabled.
-     * Value: {@value}
+     * Property name used to disable core revision check if this property is set to true
it means that corerevision
+     * checker feature will be disabled. Value: {@value}
      * 
      * @see CoreRevisionCheckerTask
      */
@@ -98,71 +92,63 @@ public interface EasyAntMagicNames {
     public static final String PLUGIN_SERVICE_INSTANCE = "plugin.service.instance";
 
     /**
-     * Name of the property containing the default location of ivysettings file
-     * used by easyant ivy instance Value: {@value}
+     * Name of the property containing the default location of ivysettings file used by easyant
ivy instance Value:
+     * {@value}
      */
     public static final String EASYANT_DEFAULT_IVYSETTINGS = "easyant.default.ivysettings.url";
 
     /**
-     * Name of the property containing the default location of ivysettings file
-     * used by easyant ivy instance with extra modules Value: {@value}
+     * Name of the property containing the default location of ivysettings file used by easyant
ivy instance with extra
+     * modules Value: {@value}
      */
     public static final String EASYANT_EXTRA_IVYSETTINGS = "easyant.extra.ivysettings.url";
 
     /**
-     * Name of the property containing the default location of ivysettings file
-     * used by project ivy instance Value: {@value}
+     * Name of the property containing the default location of ivysettings file used by project
ivy instance Value:
+     * {@value}
      */
     public static final String PROJECT_DEFAULT_IVYSETTINGS = "project.default.ivysettings.url";
 
     /**
-     * Name of the property containing the url of the easyant core jar:
-     * {@value}
+     * Name of the property containing the url of the easyant core jar: * {@value}
      */
     public static final String EASYANT_CORE_JAR_URL = "easyant.core.jar.url";
 
     /**
-     * Name of the property containing the log stategy for easyant modules
-     * Value: {@value}
+     * Name of the property containing the log stategy for easyant modules Value: {@value}
      */
     public static final String MODULE_DOWNLOAD_LOG = "easyant.modules.download.log";
 
     /**
-     * Name of the property containing the build-scoped repository name, if
-     * configured Value: {@value}
+     * Name of the property containing the build-scoped repository name, if configured Value:
{@value}
      */
     public static final String EASYANT_BUILD_REPOSITORY = "easyant.build.repository";
 
     public static final String META_TARGET = "meta.target";
 
     /**
-     * Name of the property containing the appended to menu generator registry
-     * references Value: {@value}
+     * Name of the property containing the appended to menu generator registry references
Value: {@value}
      */
     public static final String MENU_GENERATOR_REGISTRY_REF = "menugen.ref";
 
     /**
-     * Name of the property containing pre module targets. In a multi project
-     * context, those targets will be executed before delagating to subprojects.
-     * Value : {@value}
+     * Name of the property containing pre module targets. In a multi project context, those
targets will be executed
+     * before delagating to subprojects. Value : {@value}
      */
     public static final String PRE_MODULE_TARGETS = "pre.module.targets";
 
     /**
-     * Name of the property containing path to user easyant ivysettings file
-     * Value: {@value}
+     * Name of the property containing path to user easyant ivysettings file Value: {@value}
      */
     public static final String USER_EASYANT_IVYSETTINGS = "user.easyant.ivysettings.file";
 
     /**
-     * Name of the property containing path to global easyant ivysettings file
-     * Value: {@value}
+     * Name of the property containing path to global easyant ivysettings file Value: {@value}
      */
     public static final String GLOBAL_EASYANT_IVYSETTINGS = "global.easyant.ivysettings.file";
-    
+
     /**
-     * Name of the property specifyinf if build repository should be used
-     * Value: {@value}
+     * Name of the property specifyinf if build repository should be used Value: {@value}
      */
     public static final String USE_BUILD_REPOSITORY = "use.build.repository";
 
@@ -172,26 +158,27 @@ public interface EasyAntMagicNames {
     public static final String EASYANT_OFFLINE = "easyant.offline";
 
     /**
-     * Property specifying if user ivysettings should be ignored
-     * Value: {@value}
+     * Property specifying if user ivysettings should be ignored Value: {@value}
      */
     public static final String IGNORE_USER_IVYSETTINGS = "ignore.user.ivysettings";
 
     /***
-     * Property specifying offline project resolver name
-     * Value: {@value}
+     * 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}
+     * 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}
+     * Property specifying offline base directory Value: {@value}
      */
     public static final String OFFLINE_BASE_DIRECTORY = "offline.base.directory";
+
+    /**
+     * Specify if easyant is running in audit mode (plugin service for instance) Value: {@value}
+     */
+    public static final String AUDIT_MODE = "audit.mode";
 }

Modified: 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=1375125&r1=1375124&r2=1375125&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java
(original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ParameterTask.java
Mon Aug 20 17:33:28 2012
@@ -17,8 +17,10 @@
  */
 package org.apache.easyant.tasks;
 
+import org.apache.easyant.core.EasyAntMagicNames;
 import org.apache.easyant.core.ant.Phase;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Target;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.taskdefs.Property;
@@ -27,12 +29,11 @@ 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
+ * 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.
+ * 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 {
@@ -46,6 +47,7 @@ public class ParameterTask extends Task 
 
     /**
      * Get a description to the property / path / phase
+     * 
      * @return the description
      */
     public String getDescription() {
@@ -54,14 +56,17 @@ public class ParameterTask extends Task 
 
     /**
      * set a description to the property / path / phase
-     * @param description the description
+     * 
+     * @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) {
@@ -70,13 +75,14 @@ public class ParameterTask extends Task 
             if (getDescription() == null) {
                 setDescription(descriptionText);
             } else {
-                setDescription(getDescription()+descriptionText);
+                setDescription(getDescription() + descriptionText);
             }
         }
     }
 
     /**
      * Get the property name to check
+     * 
      * @return a property name
      */
     public String getProperty() {
@@ -85,7 +91,9 @@ public class ParameterTask extends Task 
 
     /**
      * Set the property name to check
-     * @param property a property name
+     * 
+     * @param property
+     *            a property name
      */
     public void setProperty(String property) {
         this.property = property;
@@ -93,7 +101,8 @@ public class ParameterTask extends Task 
 
     /**
      * Get the path to check
-     * @return a pathId 
+     * 
+     * @return a pathId
      */
     public String getPath() {
         return path;
@@ -101,6 +110,7 @@ public class ParameterTask extends Task 
 
     /**
      * Set the path to check
+     * 
      * @param path
      */
     public void setPath(String path) {
@@ -109,6 +119,7 @@ public class ParameterTask extends Task 
 
     /**
      * Get a phase to check
+     * 
      * @return a phase name
      */
     public String getPhase() {
@@ -117,7 +128,9 @@ public class ParameterTask extends Task 
 
     /**
      * Set the path to check
-     * @param phase a phase name 
+     * 
+     * @param phase
+     *            a phase name
      */
     public void setPhase(String phase) {
         this.phase = phase;
@@ -125,6 +138,7 @@ public class ParameterTask extends Task 
 
     /**
      * Get the default value (only available for property)
+     * 
      * @return a string that represents the default value
      */
     public String getDefault() {
@@ -132,8 +146,10 @@ public class ParameterTask extends Task 
     }
 
     /**
-     * Set the default value (only  available for property)
-     * @param defaultValue a string that represents the default value
+     * 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;
@@ -141,14 +157,21 @@ public class ParameterTask extends Task 
 
     /**
      * Is the refererenced property / path required?
+     * 
      * @return
      */
     public boolean isRequired() {
-        return required;
+        // don't break the build in audit mode
+        if (Project.toBoolean(getProject().getProperty(EasyAntMagicNames.AUDIT_MODE))) {
+            return false;
+        } else {
+            return required;
+        }
     }
 
     /**
      * specify if the property / path is mandatory
+     * 
      * @param required
      */
     public void setRequired(boolean required) {
@@ -157,12 +180,10 @@ public class ParameterTask extends Task 
 
     public void execute() throws BuildException {
         if (property != null) {
-            if (required && getProject().getProperty(property) == null) {
-                throw new BuildException("expected property '" + property
-                        + "': " + description);
+            if (isRequired() && getProject().getProperty(property) == null) {
+                throw new BuildException("expected property '" + property + "': " + description);
             }
-            if (defaultValue != null
-                    && getProject().getProperty(property) == null) {
+            if (defaultValue != null && getProject().getProperty(property) == null)
{
                 Property propTask = new Property();
                 propTask.setProject(getProject());
                 propTask.setTaskName(getTaskName());
@@ -173,24 +194,19 @@ public class ParameterTask extends Task 
         } else if (phase != null) {
             Target p = (Target) getProject().getTargets().get(phase);
             if (p == null) {
-                throw new BuildException("expected phase '" + phase + "': "
-                        + description);
+                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");
+                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);
+            if (isRequired() && p == null) {
+                throw new BuildException("expected path '" + path + "': " + description);
             } else if (!(p instanceof Path)) {
-                throw new BuildException("reference '" + path
-                        + "' must be a 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");
+            throw new BuildException("at least one of these attributes is required: property,
path, phase");
         }
     }
 }



Mime
View raw message