You are viewing a plain text version of this content. The canonical link for it is here.
Posted to easyant-commits@incubator.apache.org by hi...@apache.org on 2011/02/22 15:56:09 UTC
svn commit: r1073371 [17/28] - in /incubator/easyant/core/trunk: ./ bin/
example/build-configurations/
example/build-configurations/src/main/java/org/apache/easyant/example/
example/build-configurations/src/test/java/org/apache/easyant/example/
example...
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListPlugins.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListPlugins.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListPlugins.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListPlugins.java Tue Feb 22 15:55:55 2011
@@ -28,24 +28,23 @@ import org.apache.tools.ant.Project;
* build module.
*/
public class ListPlugins implements ManCommand {
- private static String TAB = "\t";
- public void addParam(String param) {
- // DO NOTHING - NOT REQUIRED, SINCE THIS IS A 'LIST-ALL' COMMAND
- }
+ public void addParam(String param) {
+ // DO NOTHING - NOT REQUIRED, SINCE THIS IS A 'LIST-ALL' COMMAND
+ }
- public void execute(EasyAntReport earep, Project project) {
- String lineSep = System.getProperty("line.separator");
- project.log(lineSep + "--- Available Plugins for current project: " + project.getName() + " ---" + lineSep);
-
- List<ImportedModuleReport> moduleReps = earep.getImportedModuleReports();
- for(int i = 0; i<moduleReps.size(); i++) {
- project.log(TAB + moduleReps.get(i).getModuleMrid() + (moduleReps.get(i).getAs() == null ?
- "" : ": Known as " + moduleReps.get(i).getAs()));
- }
-
- project.log(lineSep + lineSep + "For more information on a Plugin, run:" + lineSep + "\t easyant -describe <PLUGIN>");
- project.log(lineSep + "--- End Of (Plugins Listing) ---");
- }
+ public void execute(EasyAntReport earep, Project project) {
+ String lineSep = System.getProperty("line.separator");
+ project.log(lineSep + "--- Available Plugins for current project: " + project.getName() + " ---" + lineSep);
+
+ List<ImportedModuleReport> moduleReps = earep.getImportedModuleReports();
+ for(int i = 0; i<moduleReps.size(); i++) {
+ project.log("\t" + moduleReps.get(i).getModuleMrid() + (moduleReps.get(i).getAs() == null ?
+ "" : ": Known as " + moduleReps.get(i).getAs()));
+ }
+
+ project.log(lineSep + lineSep + "For more information on a Plugin, run:" + lineSep + "\t easyant -describe <PLUGIN>");
+ project.log(lineSep + "--- End Of (Plugins Listing) ---");
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListProps.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListProps.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListProps.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListProps.java Tue Feb 22 15:55:55 2011
@@ -31,53 +31,48 @@ import org.apache.tools.ant.Project;
* available in the specified build module.
*/
public class ListProps implements ManCommand {
- private String plugin = null;
-
- /*
- * defining some convenient string constants
- */
- private static final String TAB = "\t";
-
- public void addParam(String param) {
- this.plugin = param;
- }
-
- public void execute(EasyAntReport earep, Project project) {
- String lineSep = System.getProperty("line.separator");
-
- /*
- * the plugin specified to this class through the addParam method
- * needs to be searched for all properties, and those
- * properties will be displayed by this class.
- */
-
- if(plugin == null || plugin.trim().length() == 0) {
- throw new IllegalArgumentException("No plugin found to list properties for.");
- }
-
- project.log(lineSep + "--- Available Properties for current project: " + project.getName() +
- ":: Plugin: " + plugin + " ---" + lineSep);
-
- ImportedModuleReport moduleRep = earep.getImportedModuleReport(plugin);
- if(moduleRep == null) {
- project.log(TAB + "No Module / Plugin found by given name: " + plugin);
- } else {
- Map<String, PropertyDescriptor> allprops = moduleRep.getEasyantReport().getPropertyDescriptors();
-
- if(allprops.size() > 0) {
- for(Iterator<Entry<String, PropertyDescriptor>> it = allprops.entrySet().iterator(); it.hasNext(); ) {
- Entry<String, PropertyDescriptor> entry = it.next();
- PropertyDescriptor prop = entry.getValue();
- project.log(TAB + "Property: " + prop.getName());
- }
-
- project.log(lineSep + lineSep + "For more information on a Property, run:" + lineSep
- + "\t easyant -describe <PROPERTY>");
- } else {
- project.log(lineSep + "No property found in the plugin: " + plugin);
- }
- }
- project.log(lineSep + "--- End Of (Properties Listing) ---");
- }
+ private String plugin = null;
+
+ public void addParam(String param) {
+ this.plugin = param;
+ }
+
+ public void execute(EasyAntReport earep, Project project) {
+ String lineSep = System.getProperty("line.separator");
+
+ /*
+ * the plugin specified to this class through the addParam method
+ * needs to be searched for all properties, and those
+ * properties will be displayed by this class.
+ */
+
+ if(plugin == null || plugin.trim().length() == 0) {
+ throw new IllegalArgumentException("No plugin found to list properties for.");
+ }
+
+ project.log(lineSep + "--- Available Properties for current project: " + project.getName() +
+ ":: Plugin: " + plugin + " ---" + lineSep);
+
+ ImportedModuleReport moduleRep = earep.getImportedModuleReport(plugin);
+ if(moduleRep == null) {
+ project.log("\tNo Module / Plugin found by given name: " + plugin);
+ } else {
+ Map<String, PropertyDescriptor> allprops = moduleRep.getEasyantReport().getPropertyDescriptors();
+
+ if(allprops.size() > 0) {
+ for(Iterator<Entry<String, PropertyDescriptor>> it = allprops.entrySet().iterator(); it.hasNext(); ) {
+ Entry<String, PropertyDescriptor> entry = it.next();
+ PropertyDescriptor prop = entry.getValue();
+ project.log("\tProperty: " + prop.getName());
+ }
+
+ project.log(lineSep + lineSep + "For more information on a Property, run:" + lineSep
+ + "\t easyant -describe <PROPERTY>");
+ } else {
+ project.log(lineSep + "No property found in the plugin: " + plugin);
+ }
+ }
+ project.log(lineSep + "--- End Of (Properties Listing) ---");
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListTargets.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListTargets.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListTargets.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListTargets.java Tue Feb 22 15:55:55 2011
@@ -35,90 +35,89 @@ import org.apache.tools.ant.Project;
* lists all targets available in the project (module.ivy)
*/
public class ListTargets implements ManCommand {
- /*
- * name of the phase or plugin for which the targets
- * have been requested for.
- */
- private String container = null;
-
- /*
- * defining some convenient string constants
- */
- private static final String TAB = "\t";
- private static final String NONE = "NONE";
-
- public void addParam(String param) {
- this.container = param;
- }
+ /*
+ * name of the phase or plugin for which the targets
+ * have been requested for.
+ */
+ private String container = null;
+
+ /*
+ * defining some convenient string constants
+ */
+ private static final String NONE = "NONE";
+
+ public void addParam(String param) {
+ this.container = param;
+ }
- /*
- * simply look up for all targets belonging to a phase named <container>, is such
- * a phase exists. then list all targets listed in a module named <container>, is
- * such a module exists.
- *
- * however, if the this.container variable has not been initialized then simply list
- * down all targets in the current module and all imported sub-modules.
- */
- public void execute(EasyAntReport earep, Project project) {
- String lineSep = System.getProperty("line.separator");
-
- project.log(lineSep + "--- Available Targets for current project: " + project.getName() + " ---" + lineSep);
-
- if(this.container == null || this.container.trim().length() == 0) {
- project.log(lineSep + "No Phase / Plugin specified. Listing all targets available in the project.");
-
- List<TargetReport> targets = earep.getAvailableTargets();
- printTargets(targets, project);
- } else {
- PhaseReport phase = earep.getPhaseReport(this.container, true);
-
- if(phase != null) {
- project.log("Targets for Phase: " + this.container);
- List<TargetReport> targets = phase.getTargetReports();
- printTargets(targets, project);
- } else {
- project.log(TAB + "No Phase found by name: " + this.container);
- }
-
- List<ImportedModuleReport> modules = earep.getImportedModuleReports();
- ImportedModuleReport selected = null;
- for(int i = 0; i<modules.size(); i++) {
- selected = modules.get(i);
- if(container.equals(selected.getModuleMrid())) {
- break;
- }
- }
- if(selected != null) {
- project.log(lineSep + "Targets for Module: " + this.container);
- List<TargetReport> targets = selected.getEasyantReport().getTargetReports();
- printTargets(targets, project);
- } else {
- project.log(lineSep + TAB + "No Module / Plugin found by name: " + this.container);
- }
-
- project.log(lineSep + lineSep + "For more information on a Phase, run:" + lineSep + "\t easyant -describe <PHASE>");
- }
- project.log(lineSep + "--- End Of (Phases Listing) ---");
- }
+ /*
+ * simply look up for all targets belonging to a phase named <container>, is such
+ * a phase exists. then list all targets listed in a module named <container>, is
+ * such a module exists.
+ *
+ * however, if the this.container variable has not been initialized then simply list
+ * down all targets in the current module and all imported sub-modules.
+ */
+ public void execute(EasyAntReport earep, Project project) {
+ String lineSep = System.getProperty("line.separator");
+
+ project.log(lineSep + "--- Available Targets for current project: " + project.getName() + " ---" + lineSep);
+
+ if(this.container == null || this.container.trim().length() == 0) {
+ project.log(lineSep + "No Phase / Plugin specified. Listing all targets available in the project.");
+
+ List<TargetReport> targets = earep.getAvailableTargets();
+ printTargets(targets, project);
+ } else {
+ PhaseReport phase = earep.getPhaseReport(this.container, true);
+
+ if(phase != null) {
+ project.log("Targets for Phase: " + this.container);
+ List<TargetReport> targets = phase.getTargetReports();
+ printTargets(targets, project);
+ } else {
+ project.log("\tNo Phase found by name: " + this.container);
+ }
+
+ List<ImportedModuleReport> modules = earep.getImportedModuleReports();
+ ImportedModuleReport selected = null;
+ for(int i = 0; i<modules.size(); i++) {
+ selected = modules.get(i);
+ if(container.equals(selected.getModuleMrid())) {
+ break;
+ }
+ }
+ if(selected != null) {
+ project.log(lineSep + "Targets for Module: " + this.container);
+ List<TargetReport> targets = selected.getEasyantReport().getTargetReports();
+ printTargets(targets, project);
+ } else {
+ project.log(lineSep + "\tNo Module / Plugin found by name: " + this.container);
+ }
+
+ project.log(lineSep + lineSep + "For more information on a Phase, run:" + lineSep + "\t easyant -describe <PHASE>");
+ }
+ project.log(lineSep + "--- End Of (Phases Listing) ---");
+ }
- /*
- * common method to output a list of targets.
- *
- * re-used multiple times in this class.
- */
- private void printTargets(List<TargetReport> targets, Project project) {
- if(targets.size() == 0) {
- project.log(TAB + "No targets found.");
- return;
- }
- for(int i = 0; i<targets.size(); i++) {
- TargetReport targetRep = targets.get(i);
- project.log(TAB + "Target: " + targetRep.getName());
- project.log(TAB + TAB + "Phase: " + (targetRep.getPhase() == null ? NONE : targetRep.getPhase()));
- project.log(TAB + TAB + "Description: " + (targetRep.getDescription() == null ? NONE : targetRep.getDescription()));
- project.log(TAB + TAB + "Depends: " + (targetRep.getDepends() == null ? NONE : targetRep.getDepends()));
- project.log(TAB + TAB + "IF: " + (targetRep.getIfCase() == null ? NONE : targetRep.getIfCase()));
- project.log(TAB + TAB + "UNLESS: " + (targetRep.getUnlessCase() == null ? NONE : targetRep.getUnlessCase()));
- }
- }
+ /*
+ * common method to output a list of targets.
+ *
+ * re-used multiple times in this class.
+ */
+ private void printTargets(List<TargetReport> targets, Project project) {
+ if(targets.size() == 0) {
+ project.log("\tNo targets found.");
+ return;
+ }
+ for(int i = 0; i<targets.size(); i++) {
+ TargetReport targetRep = targets.get(i);
+ project.log("\tTarget: " + targetRep.getName());
+ project.log("\t\tPhase: " + (targetRep.getPhase() == null ? NONE : targetRep.getPhase()));
+ project.log("\t\tDescription: " + (targetRep.getDescription() == null ? NONE : targetRep.getDescription()));
+ project.log("\t\tDepends: " + (targetRep.getDepends() == null ? NONE : targetRep.getDepends()));
+ project.log("\t\tIF: " + (targetRep.getIfCase() == null ? NONE : targetRep.getIfCase()));
+ project.log("\t\tUNLESS: " + (targetRep.getUnlessCase() == null ? NONE : targetRep.getUnlessCase()));
+ }
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ManCommand.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ManCommand.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ManCommand.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ManCommand.java Tue Feb 22 15:55:55 2011
@@ -27,7 +27,7 @@ import org.apache.tools.ant.Project;
*
* For example,
* <br>
- * easyant -listTargets
+ * easyant -listTargets
*
* <p />
* The -listTargets and similar switches (like -describe etc.) are
@@ -41,23 +41,23 @@ import org.apache.tools.ant.Project;
* to be modified to add the new switch for the new manual functionality.
*/
public interface ManCommand {
- /**
- * Add a parameter to the ManCommand instance. The implementing
- * class may choose to process or ignore the parameter as need
- * may be.
- * @param param
- */
- public void addParam(String param);
-
- /**
- * Provides the ManCommand instance with a context to execute the
- * command in.
- *
- * The command is provided with an instance of generated EasyAntReport
- * with which relevant manual information may be retrieved for implementing
- * the switch functionality.
- * @param earep
- * @param project
- */
- public void execute(EasyAntReport earep, Project project);
+ /**
+ * Add a parameter to the ManCommand instance. The implementing
+ * class may choose to process or ignore the parameter as need
+ * may be.
+ * @param param
+ */
+ public void addParam(String param);
+
+ /**
+ * Provides the ManCommand instance with a context to execute the
+ * command in.
+ *
+ * The command is provided with an instance of generated EasyAntReport
+ * with which relevant manual information may be retrieved for implementing
+ * the switch functionality.
+ * @param earep
+ * @param project
+ */
+ public void execute(EasyAntReport earep, Project project);
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ProjectMan.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ProjectMan.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ProjectMan.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ProjectMan.java Tue Feb 22 15:55:55 2011
@@ -36,107 +36,107 @@ import org.apache.tools.ant.Project;
* is expected to implement the ManCommand interface.
*/
public class ProjectMan {
- private boolean inited = false;
- private Throwable initErr = null;
-
- private Project project = null;
- private EasyAntReport earep = null;
- private ManCommand command = null;
-
- /**
- * Factory method that returns an appropriate ManCommand implementation
- * depending on the parameter passed to it.
- *
- * @param cmd
- * Switch name for which ManCommand implementation is required.
- * Example, -describe etc.
- * @return
- */
- private ManCommand getCommand(String cmd) {
- if("-listPhases".equals(cmd)) {
- return new ListPhases();
- } else if("-describe".equals(cmd)) {
- return new Describe();
- } else if("-listTargets".equals(cmd)) {
- return new ListTargets();
- } else if("-listProps".equals(cmd)) {
- return new ListProps();
- } else if("-listPlugins".equals(cmd)) {
- return new ListPlugins();
- }
- throw new IllegalArgumentException("Unknown Manual Command.");
- }
-
- /**
- * Sets the context for this ProjectMan instance. Once a coxtext is provided
- * this object is in a state to support manual commands / switches.
- *
- * The context essentially comprises of:
- * <ol>
- * <li>Configured Project instance</li>
- * <li>The build module itself.</li>
- * Assumes the passed project object to be a
- * configured project.
- *
- * @param p
- * Configured project instance.
- * @param moduleDescriptor
- * The build module file. This MUST not be left unspecified.
- * This value does not default to module.ivy in current directory.
- */
- public boolean setContext(Project p, File moduleDescriptor) {
- project = p;
- try {
- PluginService pluginService = (PluginService)project.getReference(EasyAntMagicNames.PLUGIN_SERVICE_INSTANCE);
- earep = pluginService.generateEasyAntReport(moduleDescriptor);
- inited = true;
- } catch (Throwable t) {
- project.log("EasyAntMan could not be initialized. Details: " + t.getMessage());
- initErr = t;
- }
- return inited;
- }
+ private boolean inited = false;
+ private Throwable initErr = null;
+
+ private Project project = null;
+ private EasyAntReport earep = null;
+ private ManCommand command = null;
+
+ /**
+ * Factory method that returns an appropriate ManCommand implementation
+ * depending on the parameter passed to it.
+ *
+ * @param cmd
+ * Switch name for which ManCommand implementation is required.
+ * Example, -describe etc.
+ * @return
+ */
+ private ManCommand getCommand(String cmd) {
+ if("-listPhases".equals(cmd)) {
+ return new ListPhases();
+ } else if("-describe".equals(cmd)) {
+ return new Describe();
+ } else if("-listTargets".equals(cmd)) {
+ return new ListTargets();
+ } else if("-listProps".equals(cmd)) {
+ return new ListProps();
+ } else if("-listPlugins".equals(cmd)) {
+ return new ListPlugins();
+ }
+ throw new IllegalArgumentException("Unknown Manual Command.");
+ }
+
+ /**
+ * Sets the context for this ProjectMan instance. Once a coxtext is provided
+ * this object is in a state to support manual commands / switches.
+ *
+ * The context essentially comprises of:
+ * <ol>
+ * <li>Configured Project instance</li>
+ * <li>The build module itself.</li>
+ * Assumes the passed project object to be a
+ * configured project.
+ *
+ * @param p
+ * Configured project instance.
+ * @param moduleDescriptor
+ * The build module file. This MUST not be left unspecified.
+ * This value does not default to module.ivy in current directory.
+ */
+ public boolean setContext(Project p, File moduleDescriptor) {
+ project = p;
+ try {
+ PluginService pluginService = (PluginService)project.getReference(EasyAntMagicNames.PLUGIN_SERVICE_INSTANCE);
+ earep = pluginService.generateEasyAntReport(moduleDescriptor);
+ inited = true;
+ } catch (Throwable t) {
+ project.log("EasyAntMan could not be initialized. Details: " + t.getMessage());
+ initErr = t;
+ }
+ return inited;
+ }
- /**
- * Sets the command to be executed by ProjectMan. ProjectMan only keeps
- * track of the last command supplied to it through this method.
- *
- * @param command
- * The switch (e.g. -listTargets) with which easyant was invoked.
- */
- public void setCommand(String command) {
- // if there are multiple commands specified the last one overrides all the previous ones
- this.command = getCommand(command);
- }
-
- /**
- * Used to add a parameter to ManCommand instance. The ManCommand instance
- * will decide how to handle the object.
- *
- * @param param
- * Additional input to the ManCommand. This may be specify the plugin
- * name if the the command is -listProps, or the phase name if the
- * command is -describe.
- */
- public void addParam(String param) {
- command.addParam(param);
- }
-
- /**
- * Executes the Project Manual with the given command name, and supplied
- * parameters.
- */
- public void execute() {
- if(!inited)
- throw new RuntimeException(initErr);
-
- if(command == null)
- throw new RuntimeException("Available options: -listAll, -describe, -listTargets, -listProps. " +
- "ProjectHelp can not be run without one of these.");
- String lineSep = System.getProperty("line.separator");
-
- project.log(lineSep + "Project Manual");
- project.log("--------------");
- command.execute(earep, project);
- }
+ /**
+ * Sets the command to be executed by ProjectMan. ProjectMan only keeps
+ * track of the last command supplied to it through this method.
+ *
+ * @param command
+ * The switch (e.g. -listTargets) with which easyant was invoked.
+ */
+ public void setCommand(String command) {
+ // if there are multiple commands specified the last one overrides all the previous ones
+ this.command = getCommand(command);
+ }
+
+ /**
+ * Used to add a parameter to ManCommand instance. The ManCommand instance
+ * will decide how to handle the object.
+ *
+ * @param param
+ * Additional input to the ManCommand. This may be specify the plugin
+ * name if the the command is -listProps, or the phase name if the
+ * command is -describe.
+ */
+ public void addParam(String param) {
+ command.addParam(param);
+ }
+
+ /**
+ * Executes the Project Manual with the given command name, and supplied
+ * parameters.
+ */
+ public void execute() {
+ if(!inited)
+ throw new RuntimeException(initErr);
+
+ if(command == null)
+ throw new RuntimeException("Available options: -listAll, -describe, -listTargets, -listProps. " +
+ "ProjectHelp can not be run without one of these.");
+ String lineSep = System.getProperty("line.separator");
+
+ project.log(lineSep + "Project Manual");
+ project.log("--------------");
+ command.execute(earep, project);
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/AbstractEasyAntTask.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/AbstractEasyAntTask.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/AbstractEasyAntTask.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/AbstractEasyAntTask.java Tue Feb 22 15:55:55 2011
@@ -29,42 +29,42 @@ import org.apache.tools.ant.types.Refere
*/
public class AbstractEasyAntTask extends Task {
- /**
- * Get the easyant ivy ant settings.
- * Usefull if you want to bind a subtask to easyant ivy instance
- * @return an ivyAntSettings
- */
- protected IvyAntSettings getEasyAntIvyAntSettings() {
- return IvyInstanceHelper.getEasyAntIvyAntSettings(getProject());
- }
-
- /**
- * Get the configured ivy instance
- * @return a configured ivy instance
- */
- protected Ivy getEasyAntIvyInstance() {
- return getEasyAntIvyAntSettings().getConfiguredIvyInstance(this);
- }
-
- /**
- * Utilitary method to configure a task with the current one
- * @param task task to configure
- * @return the configured task
- */
- protected Task initTask(Task task) {
- task.setLocation(getLocation());
- task.setProject(getProject());
- task.setTaskName(getTaskName());
- task.setOwningTarget(getOwningTarget());
- return task;
- }
+ /**
+ * Get the easyant ivy ant settings.
+ * Usefull if you want to bind a subtask to easyant ivy instance
+ * @return an ivyAntSettings
+ */
+ protected IvyAntSettings getEasyAntIvyAntSettings() {
+ return IvyInstanceHelper.getEasyAntIvyAntSettings(getProject());
+ }
+
+ /**
+ * Get the configured ivy instance
+ * @return a configured ivy instance
+ */
+ protected Ivy getEasyAntIvyInstance() {
+ return getEasyAntIvyAntSettings().getConfiguredIvyInstance(this);
+ }
+
+ /**
+ * Utilitary method to configure a task with the current one
+ * @param task task to configure
+ * @return the configured task
+ */
+ protected Task initTask(Task task) {
+ task.setLocation(getLocation());
+ task.setProject(getProject());
+ task.setTaskName(getTaskName());
+ task.setOwningTarget(getOwningTarget());
+ return task;
+ }
- /**
- * Get a reference of the project ivy instance
- * @return a reference of the project ivy instance
- */
- protected Reference getProjectIvyReference() {
- return IvyInstanceHelper.buildProjectIvyReference(getProject());
- }
+ /**
+ * Get a reference of the project ivy instance
+ * @return a reference of the project ivy instance
+ */
+ protected Reference getProjectIvyReference() {
+ return IvyInstanceHelper.buildProjectIvyReference(getProject());
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/BindTarget.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/BindTarget.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/BindTarget.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/BindTarget.java Tue Feb 22 15:55:55 2011
@@ -29,111 +29,111 @@ import org.apache.tools.ant.Task;
public class BindTarget extends Task {
- private String target;
- private String toPhase;
+ private String target;
+ private String toPhase;
- private String buildConfigurations;
+ private String buildConfigurations;
- public void execute() throws BuildException {
- StringBuilder message = new StringBuilder();
- message.append("Phase mapping for target ").append(getTarget()).append(
- " ");
- if (!BuildConfigurationHelper.isBuildConfigurationActive(
- getBuildConfigurations(), getProject(), message.toString())) {
- log(
- "no matching build configuration for this phase mapping, this mapping will be ignored",
- Project.MSG_DEBUG);
- return;
- }
- Target t = (Target) getProject().getTargets().get(getTarget());
- if (t == null) {
- throw new BuildException("unable to find target " + getTarget());
- }
-
- // unbind current mapping
- for (Iterator iterator = getProject().getTargets().values().iterator(); iterator
- .hasNext();) {
- Target current = (Target) iterator.next();
- if (current instanceof Phase) {
- Enumeration dependencies = current.getDependencies();
- StringBuilder dependsOn = new StringBuilder();
- boolean requiresUpdates = false;
- while (dependencies.hasMoreElements()) {
- String dep = (String) dependencies.nextElement();
- if (dep.equals(getTarget())) {
- log("target" + getTarget() + " is registred in phase"
- + current.getName(), Project.MSG_VERBOSE);
- requiresUpdates = true;
- } else {
- dependsOn.append(dep);
- dependsOn.append(",");
- }
- }
- if (requiresUpdates) {
- log("removing target" + getTarget() + " from phase"
- + current.getName(), Project.MSG_VERBOSE);
-
- Phase p = new Phase();
- p.setDescription(current.getDescription());
- p.setIf(current.getIf());
- p.setLocation(current.getLocation());
- p.setName(current.getName());
- p.setProject(current.getProject());
- p.setUnless(current.getUnless());
- String depends = dependsOn.toString();
- if (depends.endsWith(",")) {
- depends = depends.substring(0, depends.length() - 1);
- }
- p.setDepends(depends);
- getProject().addOrReplaceTarget(p);
- }
-
- }
- }
-
- if (getToPhase() != null && !getToPhase().equals("")) {
- if (!getProject().getTargets().containsKey(getToPhase())) {
- throw new BuildException("can't add target " + getTarget()
- + " to phase " + getToPhase() + " because the phase"
- + " is unknown.");
- }
- Target p = (Target) getProject().getTargets().get(getToPhase());
-
- if (!(p instanceof Phase)) {
- throw new BuildException("referenced target " + getToPhase()
- + " is not a phase");
- }
- p.addDependency(getTarget());
- }
-
- }
-
- public String getToPhase() {
- return toPhase;
- }
-
- public void setToPhase(String toPhase) {
- this.toPhase = toPhase;
- }
-
- public String getTarget() {
- return target;
- }
-
- public void setTarget(String target) {
- this.target = target;
- }
-
- public String getBuildConfigurations() {
- return buildConfigurations;
- }
-
- public void setBuildConfigurations(String buildConfigurations) {
- this.buildConfigurations = buildConfigurations;
- }
-
- public void setConf(String conf) {
- this.buildConfigurations = conf;
- }
+ public void execute() throws BuildException {
+ StringBuilder message = new StringBuilder();
+ message.append("Phase mapping for target ").append(getTarget()).append(
+ " ");
+ if (!BuildConfigurationHelper.isBuildConfigurationActive(
+ getBuildConfigurations(), getProject(), message.toString())) {
+ log(
+ "no matching build configuration for this phase mapping, this mapping will be ignored",
+ Project.MSG_DEBUG);
+ return;
+ }
+ Target t = (Target) getProject().getTargets().get(getTarget());
+ if (t == null) {
+ throw new BuildException("unable to find target " + getTarget());
+ }
+
+ // unbind current mapping
+ for (Iterator iterator = getProject().getTargets().values().iterator(); iterator
+ .hasNext();) {
+ Target current = (Target) iterator.next();
+ if (current instanceof Phase) {
+ Enumeration dependencies = current.getDependencies();
+ StringBuilder dependsOn = new StringBuilder();
+ boolean requiresUpdates = false;
+ while (dependencies.hasMoreElements()) {
+ String dep = (String) dependencies.nextElement();
+ if (dep.equals(getTarget())) {
+ log("target" + getTarget() + " is registred in phase"
+ + current.getName(), Project.MSG_VERBOSE);
+ requiresUpdates = true;
+ } else {
+ dependsOn.append(dep);
+ dependsOn.append(",");
+ }
+ }
+ if (requiresUpdates) {
+ log("removing target" + getTarget() + " from phase"
+ + current.getName(), Project.MSG_VERBOSE);
+
+ Phase p = new Phase();
+ p.setDescription(current.getDescription());
+ p.setIf(current.getIf());
+ p.setLocation(current.getLocation());
+ p.setName(current.getName());
+ p.setProject(current.getProject());
+ p.setUnless(current.getUnless());
+ String depends = dependsOn.toString();
+ if (depends.endsWith(",")) {
+ depends = depends.substring(0, depends.length() - 1);
+ }
+ p.setDepends(depends);
+ getProject().addOrReplaceTarget(p);
+ }
+
+ }
+ }
+
+ if (getToPhase() != null && !getToPhase().equals("")) {
+ if (!getProject().getTargets().containsKey(getToPhase())) {
+ throw new BuildException("can't add target " + getTarget()
+ + " to phase " + getToPhase() + " because the phase"
+ + " is unknown.");
+ }
+ Target p = (Target) getProject().getTargets().get(getToPhase());
+
+ if (!(p instanceof Phase)) {
+ throw new BuildException("referenced target " + getToPhase()
+ + " is not a phase");
+ }
+ p.addDependency(getTarget());
+ }
+
+ }
+
+ public String getToPhase() {
+ return toPhase;
+ }
+
+ public void setToPhase(String toPhase) {
+ this.toPhase = toPhase;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getBuildConfigurations() {
+ return buildConfigurations;
+ }
+
+ public void setBuildConfigurations(String buildConfigurations) {
+ this.buildConfigurations = buildConfigurations;
+ }
+
+ public void setConf(String conf) {
+ this.buildConfigurations = conf;
+ }
}
Modified: 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=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CheckResolver.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CheckResolver.java Tue Feb 22 15:55:55 2011
@@ -25,86 +25,88 @@ import org.apache.tools.ant.BuildExcepti
*
*/
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);
- }
- }
- }
+
+ 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("
+");
+ if (getDescription() != null) {
+ sb.append(resolver);
+ sb.append(" : ");
+ sb.append(getDescription());
+ sb.append("
+");
+ }
+ 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);
+ }
+ }
+ }
-
-
+
+
}
Modified: 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=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ConfigureBuildScopedRepository.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/ConfigureBuildScopedRepository.java Tue Feb 22 15:55:55 2011
@@ -37,133 +37,133 @@ import org.apache.tools.ant.Project;
*/
public class ConfigureBuildScopedRepository extends IvyTask {
- private String buildScopedRepositoryName = "build";
- private boolean dictator=false;
+ private String buildScopedRepositoryName = "build";
+ private boolean dictator=false;
- private String target;
+ 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);
+ /**
+ * 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);
- }
+ }
}
Modified: 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=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CoreRevisionCheckerTask.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/CoreRevisionCheckerTask.java Tue Feb 22 15:55:55 2011
@@ -45,113 +45,113 @@ import org.apache.tools.ant.Project;
*/
public class CoreRevisionCheckerTask extends AbstractEasyAntTask {
- private String requiredRevision;
- private String message;
+ 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;
- }
- }
-
+ /**
+ * 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;
+ }
+ }
+
}
Modified: 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=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/EasyAntRunner.java Tue Feb 22 15:55:55 2011
@@ -30,90 +30,90 @@ import org.apache.tools.ant.Task;
public class EasyAntRunner extends Task {
- private boolean fork = true;
+ private boolean fork = true;
- private EasyAntConfiguration easyantConfiguration = new EasyAntConfiguration();
+ 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;
- }
+ @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;
+ }
}