You are viewing a plain text version of this content. The canonical link for it is here.
Posted to easyant-commits@incubator.apache.org by jl...@apache.org on 2012/10/19 22:32:31 UTC
svn commit: r1400320 - in
/incubator/easyant/core/trunk/src/main/java/org/apache/easyant:
core/EasyAntMagicNames.java core/ant/listerners/BuildExecutionTimer.java
tasks/SubModule.java
Author: jlboudart
Date: Fri Oct 19 22:32:30 2012
New Revision: 1400320
URL: http://svn.apache.org/viewvc?rev=1400320&view=rev
Log:
Handle skipped modules in multimodule projects (when no targets are executed)
Modified:
incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntMagicNames.java
incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/BuildExecutionTimer.java
incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SubModule.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=1400320&r1=1400319&r2=1400320&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 Fri Oct 19 22:32:30 2012
@@ -92,14 +92,14 @@ 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 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";
@@ -175,4 +175,9 @@ public interface EasyAntMagicNames {
* Specify if easyant is running in audit mode (plugin service for instance) Value: {@value}
*/
public static final String AUDIT_MODE = "audit.mode";
+
+ /**
+ * Property specifying executed targets in current project
+ */
+ public static final String PROJECT_EXECUTED_TARGETS = "project.executed.targets";
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/BuildExecutionTimer.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/BuildExecutionTimer.java?rev=1400320&r1=1400319&r2=1400320&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/BuildExecutionTimer.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/BuildExecutionTimer.java Fri Oct 19 22:32:30 2012
@@ -20,6 +20,8 @@ package org.apache.easyant.core.ant.list
import java.util.ArrayList;
import java.util.List;
+import org.apache.easyant.core.EasyAntMagicNames;
+import org.apache.easyant.core.ant.ExecutionStatus;
import org.apache.ivy.util.StringUtils;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildListener;
@@ -54,28 +56,13 @@ public class BuildExecutionTimer impleme
*/
private String formattedElapsedTime;
- /**
- * Execution result
- */
- private int execResult;
-
- /**
- * Value to be assigned to execResult if failure
- */
- public static int FAILURE_RESULT = 0;
+ private ExecutionStatus buildStatus;
- /**
- * Value to be assigned to execResult if success
- */
- public static int SUCCESS_RESULT = 1;
-
- public ExecutionResult(String unitName, long elapsedTime,
- int buildResult) {
+ public ExecutionResult(String unitName, long elapsedTime, ExecutionStatus buildStatus) {
this.unitName = unitName;
this.elapsedTime = elapsedTime;
- this.formattedElapsedTime = DateUtils
- .formatElapsedTime(elapsedTime);
- this.execResult = buildResult;
+ this.formattedElapsedTime = DateUtils.formatElapsedTime(elapsedTime);
+ this.buildStatus = buildStatus;
}
public String getUnitName() {
@@ -90,28 +77,29 @@ public class BuildExecutionTimer impleme
return this.formattedElapsedTime;
}
- public int getResult() {
- return this.execResult;
+ public ExecutionStatus getStatus() {
+ return this.buildStatus;
}
}
/**
- * stops the timer and stores the result as a project reference by the key
- * 'referenceName'
+ * stops the timer and stores the result as a project reference by the key 'referenceName'
*/
- protected void stopTimer(BuildEvent arg0, String referenceName,
- long startTime) {
- List<ExecutionResult> results = (List<ExecutionResult>) arg0
- .getProject().getReference(referenceName);
+ protected void stopTimer(BuildEvent event, String referenceName, long startTime) {
+ List<ExecutionResult> results = (List<ExecutionResult>) event.getProject().getReference(referenceName);
if (results == null) {
results = new ArrayList<ExecutionResult>();
- arg0.getProject().addReference(referenceName, results);
+ event.getProject().addReference(referenceName, results);
+ }
+ ExecutionStatus status = ExecutionStatus.SUCCESS;
+ if (event.getException() != null) {
+ status = ExecutionStatus.FAILED;
+ } else if (event.getProject().getProperty(EasyAntMagicNames.PROJECT_EXECUTED_TARGETS) == null) {
+ status = ExecutionStatus.SKIPPED;
}
- ExecutionResult execResult = new ExecutionResult(arg0.getProject()
- .getName(), System.currentTimeMillis() - startTime, arg0
- .getException() == null ? ExecutionResult.SUCCESS_RESULT
- : ExecutionResult.FAILURE_RESULT);
+ ExecutionResult execResult = new ExecutionResult(event.getProject().getName(), System.currentTimeMillis()
+ - startTime, status);
results.add(execResult);
@@ -147,8 +135,7 @@ public class BuildExecutionTimer impleme
}
/**
- * Returns a string containing results of execution timing for display on
- * console in a tabular fashion
+ * Returns a string containing results of execution timing for display on console in a tabular fashion
*
* @param results
* @return
@@ -160,35 +147,31 @@ public class BuildExecutionTimer impleme
int maxExecTimeLength = 0;
for (int i = 0; i < results.size(); i++) {
ExecutionResult result = results.get(i);
- maxUnitNameLength = result.getUnitName().length() > maxUnitNameLength ? result
- .getUnitName().length()
+ maxUnitNameLength = result.getUnitName().length() > maxUnitNameLength ? result.getUnitName().length()
: maxUnitNameLength;
maxExecTimeLength = result.getFormattedElapsedTime().length() > maxExecTimeLength ? result
- .getFormattedElapsedTime().length()
- : maxExecTimeLength;
+ .getFormattedElapsedTime().length() : maxExecTimeLength;
}
- StringBuffer sb = new StringBuffer(
- org.apache.tools.ant.util.StringUtils.LINE_SEP);
+ StringBuffer sb = new StringBuffer(org.apache.tools.ant.util.StringUtils.LINE_SEP);
for (int i = 0; i < results.size(); i++) {
ExecutionResult result = results.get(i);
String moduleName = result.getUnitName();
- int variableSpaces = maxUnitNameLength - moduleName.length()
- + constantSpaces;
- sb.append(" * ").append(result.getUnitName()).append(
- StringUtils.repeat(" ", variableSpaces));
+ int variableSpaces = maxUnitNameLength - moduleName.length() + constantSpaces;
+ sb.append(" * ").append(result.getUnitName()).append(StringUtils.repeat(" ", variableSpaces));
// keeping both success and failed strings of equal length
- String execResult = result.getResult() == ExecutionResult.SUCCESS_RESULT ? "SUCCESS "
- : "FAILED ";
- sb.append(execResult).append("[took ").append(
- result.getFormattedElapsedTime()).append("]").append(
- org.apache.tools.ant.util.StringUtils.LINE_SEP);
+ String execResult = result.getStatus().toString();
+ if (execResult.length() < 7) {
+ execResult += StringUtils.repeat(" ", 7 - execResult.length());
+ }
+ sb.append(execResult).append(" [took ").append(result.getFormattedElapsedTime()).append("]")
+ .append(org.apache.tools.ant.util.StringUtils.LINE_SEP);
}
formattedResults = sb.toString();
return formattedResults;
}
- /**
+ /**
* Reference key against which build execution results will be stored
*/
public static final String EXECUTION_TIMER_BUILD_RESULTS = "execution.timer.build.results";
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SubModule.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SubModule.java?rev=1400320&r1=1400319&r2=1400320&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SubModule.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SubModule.java Fri Oct 19 22:32:30 2012
@@ -51,6 +51,7 @@ import org.apache.tools.ant.taskdefs.Pro
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.PropertySet;
import org.apache.tools.ant.types.Reference;
+import org.apache.tools.ant.util.CollectionUtils;
import org.apache.tools.ant.util.StringUtils;
/**
@@ -195,10 +196,11 @@ public class SubModule extends Task {
ProjectUtils.injectTargetIntoExtensionPoint(subModule, helper);
- Set<String> targetsToRun = filterTargets(subModule);
+ String targetsToRun = filterTargets(subModule);
printExecutingTargetMsg(subModule);
if (targetsToRun != null && !targetsToRun.isEmpty()) {
+ subModule.setNewProperty(EasyAntMagicNames.PROJECT_EXECUTED_TARGETS, targetsToRun);
subModule.executeTargets(new TargetList(targetsToRun));
if (useBuildRepository) {
File artifactsDir = subModule.resolveFile(subModule.getProperty("target.artifacts"));
@@ -297,6 +299,7 @@ public class SubModule extends Task {
return subModule;
}
+ @SuppressWarnings("unchecked")
private void storeExecutionTimes(Project parent, Project child) {
List<ExecutionResult> allresults = (List<ExecutionResult>) parent
.getReference(SubBuildExecutionTimer.EXECUTION_TIMER_SUBBUILD_RESULTS);
@@ -313,7 +316,7 @@ public class SubModule extends Task {
/**
* Filter the active set of targets to only those defined in the given project.
*/
- private Set<String> filterTargets(Project subProject) {
+ private String filterTargets(Project subProject) {
Set<String> filteredTargets = new HashSet<String>();
Set<?> keys = subProject.getTargets().keySet();
@@ -325,7 +328,7 @@ public class SubModule extends Task {
subProject.log("Skipping undefined target '" + target + "'", Project.MSG_VERBOSE);
}
}
- return filteredTargets;
+ return CollectionUtils.flattenToString(filteredTargets);
}
/**
@@ -669,11 +672,5 @@ public class SubModule extends Task {
for (String target : targets)
add(target);
}
-
- public TargetList(Set<String> targets) {
- for (String target : targets) {
- add(target);
- }
- }
}
}