From easyant-commits-return-634-apmail-incubator-easyant-commits-archive=incubator.apache.org@incubator.apache.org Fri Oct 19 22:33:16 2012 Return-Path: X-Original-To: apmail-incubator-easyant-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-easyant-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 92B82D6D2 for ; Fri, 19 Oct 2012 22:33:16 +0000 (UTC) Received: (qmail 30383 invoked by uid 500); 19 Oct 2012 22:33:16 -0000 Delivered-To: apmail-incubator-easyant-commits-archive@incubator.apache.org Received: (qmail 30357 invoked by uid 500); 19 Oct 2012 22:33:16 -0000 Mailing-List: contact easyant-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: easyant-dev@incubator.apache.org Delivered-To: mailing list easyant-commits@incubator.apache.org Received: (qmail 30348 invoked by uid 99); 19 Oct 2012 22:33:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Oct 2012 22:33:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Oct 2012 22:33:14 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 583A523888E3; Fri, 19 Oct 2012 22:32:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Fri, 19 Oct 2012 22:32:31 -0000 To: easyant-commits@incubator.apache.org From: jlboudart@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121019223231.583A523888E3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 results = (List) arg0 - .getProject().getReference(referenceName); + protected void stopTimer(BuildEvent event, String referenceName, long startTime) { + List results = (List) event.getProject().getReference(referenceName); if (results == null) { results = new ArrayList(); - 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 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 allresults = (List) 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 filterTargets(Project subProject) { + private String filterTargets(Project subProject) { Set filteredTargets = new HashSet(); 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 targets) { - for (String target : targets) { - add(target); - } - } } }