continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r564614 - in /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution: AbstractBuildExecutor.java ant/AntBuildExecutor.java maven/m1/MavenOneBuildExecutor.java maven/m2/MavenTwoBuildExecutor.java
Date Fri, 10 Aug 2007 14:58:58 GMT
Author: evenisse
Date: Fri Aug 10 07:58:57 2007
New Revision: 564614

URL: http://svn.apache.org/viewvc?view=rev&rev=564614
Log:
[CONTINUUM-990] Pass some continuum information to build tools (m1, m2, ant) when executing
a build

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant/AntBuildExecutor.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java?view=diff&rev=564614&r1=564613&r2=564614
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
Fri Aug 10 07:58:57 2007
@@ -42,6 +42,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -263,6 +264,16 @@
             envVars.put( installation.getVarName(), installation.getVarValue() );
         }
         return envVars;
+    }
+
+    protected Properties getContinuumSystemProperties( Project project )
+    {
+        Properties properties = new Properties();
+        properties.setProperty( "continuum.project.group.name", project.getProjectGroup().getName()
);
+        properties.setProperty( "continuum.project.lastBuild.state", String.valueOf( project.getOldState()
) );
+        properties.setProperty( "continuum.project.lastBuild.number", String.valueOf( project.getBuildNumber()
) );
+        properties.setProperty( "continuum.project.nextBuild.number", String.valueOf( project.getBuildNumber()
+ 1 ) );
+        return properties;
     }
 
     public boolean isBuilding( Project project )

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant/AntBuildExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant/AntBuildExecutor.java?view=diff&rev=564614&r1=564613&r2=564614
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant/AntBuildExecutor.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/ant/AntBuildExecutor.java
Fri Aug 10 07:58:57 2007
@@ -32,8 +32,10 @@
 
 import java.io.File;
 import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -72,17 +74,26 @@
         String executable = getInstallationService().getExecutorConfigurator( InstallationService.ANT_TYPE
)
             .getExecutable();
 
-        String arguments = "";
+        StringBuffer arguments = new StringBuffer();
 
         String buildFile = buildDefinition.getBuildFile();
 
         if ( !StringUtils.isEmpty( buildFile ) )
         {
-            arguments = "-f " + buildFile + " ";
+            arguments.append( "-f " ).append( buildFile ).append( " " );
         }
 
-        arguments +=
-            StringUtils.clean( buildDefinition.getArguments() ) + " " + StringUtils.clean(
buildDefinition.getGoals() );
+        arguments.append( StringUtils.clean( buildDefinition.getArguments() ) ).append( "
" );
+
+        Properties props = getContinuumSystemProperties( project );
+        for ( Enumeration itr = props.propertyNames(); itr.hasMoreElements(); )
+        {
+            String name = (String) itr.nextElement();
+            String value = props.getProperty( name );
+            arguments.append( "\"-D" ).append( name ).append( "=" ).append( value ).append(
"\" " );
+        }
+
+        arguments.append( StringUtils.clean( buildDefinition.getGoals() ) );
 
         Map<String, String> environments = getEnvironments( buildDefinition );
         String antHome = environments.get( getInstallationService().getEnvVar( InstallationService.ANT_TYPE
) );
@@ -92,7 +103,7 @@
             setResolveExecutable( false );
         }
 
-        return executeShellCommand( project, executable, arguments, buildOutput, environments
);
+        return executeShellCommand( project, executable, arguments.toString(), buildOutput,
environments );
     }
 
     protected Map<String, String> getEnvironments( BuildDefinition buildDefinition
)

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java?view=diff&rev=564614&r1=564613&r2=564614
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java
Fri Aug 10 07:58:57 2007
@@ -32,8 +32,10 @@
 
 import java.io.File;
 import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -71,17 +73,26 @@
         String executable = getInstallationService().getExecutorConfigurator( InstallationService.MAVEN1_TYPE
)
             .getExecutable();
 
-        String arguments = "";
+        StringBuffer arguments = new StringBuffer();
 
         String buildFile = StringUtils.clean( buildDefinition.getBuildFile() );
 
         if ( !StringUtils.isEmpty( buildFile ) && !"project.xml".equals( buildFile
) )
         {
-            arguments = "-p " + buildFile + " ";
+            arguments.append( "-p " ).append( buildFile ).append( " " );
         }
 
-        arguments +=
-            StringUtils.clean( buildDefinition.getArguments() ) + " " + StringUtils.clean(
buildDefinition.getGoals() );
+        arguments.append( StringUtils.clean( buildDefinition.getArguments() ) ).append( "
" );
+
+        Properties props = getContinuumSystemProperties( project );
+        for ( Enumeration itr = props.propertyNames(); itr.hasMoreElements(); )
+        {
+            String name = (String) itr.nextElement();
+            String value = props.getProperty( name );
+            arguments.append( "\"-D" ).append( name ).append( "=" ).append( value ).append(
"\" " );
+        }
+
+        arguments.append( StringUtils.clean( buildDefinition.getGoals() ) );
 
         Map<String, String> environments = getEnvironments( buildDefinition );
         String m1Home = environments.get( getInstallationService().getEnvVar( InstallationService.MAVEN1_TYPE
) );
@@ -91,7 +102,7 @@
             setResolveExecutable( false );
         }
 
-        return executeShellCommand( project, executable, arguments, buildOutput, environments
);
+        return executeShellCommand( project, executable, arguments.toString(), buildOutput,
environments );
     }
 
     protected Map<String, String> getEnvironments( BuildDefinition buildDefinition
)

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java?view=diff&rev=564614&r1=564613&r2=564614
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
Fri Aug 10 07:58:57 2007
@@ -51,11 +51,13 @@
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Properties;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -106,17 +108,27 @@
         String executable = getInstallationService().getExecutorConfigurator( InstallationService.MAVEN2_TYPE
)
             .getExecutable();
 
-        String arguments = "";
+        StringBuffer arguments = new StringBuffer();
 
         String buildFile = StringUtils.clean( buildDefinition.getBuildFile() );
 
         if ( !StringUtils.isEmpty( buildFile ) && !"pom.xml".equals( buildFile )
)
         {
-            arguments = "-f " + buildFile + " ";
+            arguments.append( "-f " ).append( buildFile ).append( " " );
         }
 
-        arguments +=
-            StringUtils.clean( buildDefinition.getArguments() ) + " " + StringUtils.clean(
buildDefinition.getGoals() );
+        arguments.append( StringUtils.clean( buildDefinition.getArguments() ) ).append( "
" );
+
+        Properties props = getContinuumSystemProperties( project );
+        for ( Enumeration itr = props.propertyNames(); itr.hasMoreElements(); )
+        {
+            String name = (String) itr.nextElement();
+            String value = props.getProperty( name );
+            arguments.append( "\"-D" ).append( name ).append( "=" ).append( value ).append(
"\" " );
+        }
+
+        arguments.append( StringUtils.clean( buildDefinition.getGoals() ) );
+
         Map<String, String> environments = getEnvironments( buildDefinition );
         String m2Home = environments.get( getInstallationService().getEnvVar( InstallationService.MAVEN2_TYPE
) );
         if ( StringUtils.isNotEmpty( m2Home ) )
@@ -125,7 +137,7 @@
             setResolveExecutable( false );
         }
 
-        return executeShellCommand( project, executable, arguments, buildOutput, environments
);
+        return executeShellCommand( project, executable, arguments.toString(), buildOutput,
environments );
     }
 
     public void updateProjectFromCheckOut( File workingDirectory, Project project, BuildDefinition
buildDefinition )



Mime
View raw message