continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r377483 - in /maven/continuum/branches/continuum-1.0.x: continuum-api/src/main/java/org/apache/maven/continuum/execution/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/build...
Date Mon, 13 Feb 2006 20:53:10 GMT
Author: evenisse
Date: Mon Feb 13 12:53:09 2006
New Revision: 377483

URL: http://svn.apache.org/viewcvs?rev=377483&view=rev
Log:
[CONTINUUM-576] Check if build process is always running and builder (maven, ant...) already
stopped.

Modified:
    maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/DefaultShellCommandHelper.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/ShellCommandHelper.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml

Modified: maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java?rev=377483&r1=377482&r2=377483&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
Mon Feb 13 12:53:09 2006
@@ -34,4 +34,8 @@
 
     void updateProjectFromCheckOut( File workingDirectory, Project project, BuildDefinition
buildDefinition )
         throws ContinuumBuildExecutorException;
+
+    boolean isBuilding( Project project );
+
+    void killProcess( Project project );
 }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=377483&r1=377482&r2=377483&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Feb 13 12:53:09 2006
@@ -27,6 +27,8 @@
 import org.apache.maven.continuum.core.action.AddProjectToCheckOutQueueAction;
 import org.apache.maven.continuum.core.action.CreateProjectsFromMetadata;
 import org.apache.maven.continuum.core.action.StoreProjectAction;
+import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
+import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
 import org.apache.maven.continuum.initialization.ContinuumInitializationException;
 import org.apache.maven.continuum.initialization.ContinuumInitializer;
 import org.apache.maven.continuum.initialization.DefaultContinuumInitializer;
@@ -145,6 +147,11 @@
      */
     private WorkingDirectoryService workingDirectoryService;
 
+    /**
+     * @plexus.requirement
+     */
+    private BuildExecutorManager executorManager;
+
     // ----------------------------------------------------------------------
     // Projects
     // ----------------------------------------------------------------------
@@ -437,8 +444,21 @@
                 project.getState() != ContinuumProjectState.FAILED &&
                 project.getState() != ContinuumProjectState.ERROR )
             {
-                // project is building
-                return;
+                ContinuumBuildExecutor executor = executorManager.getBuildExecutor( project.getExecutorId()
);
+                if ( executor.isBuilding( project ) )
+                {
+                    // project is building
+                    getLogger().info( "Project '" + project.getName() + "' always running.");
+                    return;
+                }
+                else
+                {
+                    project.setState( ContinuumProjectState.ERROR );
+
+                    store.updateProject( project );
+
+                    project = store.getProject( projectId );
+                }
             }
 
             project.setOldState( project.getState() );

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=377483&r1=377482&r2=377483&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Mon Feb 13 12:53:09 2006
@@ -214,7 +214,6 @@
                     trigger != ContinuumProjectState.TRIGGER_FORCED &&
                     project.getState() != ContinuumProjectState.NEW )
                 {
-
                     getLogger().info( "The project was not built because all changes are
unknown." );
 
                     project.setState( project.getOldState() );
@@ -224,7 +223,6 @@
                     store.updateProject( project );
 
                     return;
-
                 }
 
                 actionManager.lookup( "update-project-from-working-directory" ).execute(
actionContext );

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java?rev=377483&r1=377482&r2=377483&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
Mon Feb 13 12:53:09 2006
@@ -188,7 +188,7 @@
         try
         {
             ExecutionResult result = shellCommandHelper.executeShellCommand( workingDirectory,
actualExecutable,
-                                                                             arguments, output
);
+                                                                             arguments, output,
project.getId() );
 
             getLogger().info( "Exit code: " + result.getExitCode() );
 
@@ -199,6 +199,16 @@
             throw new ContinuumBuildExecutorException( "Error while executing shell command.
" +
                 "The most common error is that '" + executable + "' " + "is not in your path.",
e );
         }
+    }
+
+    public boolean isBuilding( Project project )
+    {
+        return shellCommandHelper.isRunning( project.getId() );
+    }
+
+    public void killProcess( Project project )
+    {
+        shellCommandHelper.killProcess( project.getId() );
     }
 
     public File getWorkingDirectory( Project project )

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?rev=377483&r1=377482&r2=377483&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
Mon Feb 13 12:53:09 2006
@@ -114,8 +114,16 @@
     public void mapMavenProjectToContinuumProject( MavenProject mavenProject, Project continuumProject
)
         throws MavenBuilderHelperException
     {
+        // ----------------------------------------------------------------------
+        // Name
+        // ----------------------------------------------------------------------
+
         continuumProject.setName( getProjectName( mavenProject ) );
 
+        // ----------------------------------------------------------------------
+        // SCM Url
+        // ----------------------------------------------------------------------
+
         continuumProject.setScmUrl( getScmUrl( mavenProject ) );
 
         if ( !"HEAD".equals( mavenProject.getScm().getTag() ) )
@@ -232,7 +240,7 @@
         }
 
         // ----------------------------------------------------------------------
-        //
+        // Notifiers
         // ----------------------------------------------------------------------
 
         List userNotifiers = new ArrayList();

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/DefaultShellCommandHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/DefaultShellCommandHelper.java?rev=377483&r1=377482&r2=377483&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/DefaultShellCommandHelper.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/DefaultShellCommandHelper.java
Mon Feb 13 12:53:09 2006
@@ -38,10 +38,8 @@
     // ShellCommandHelper Implementation
     // ----------------------------------------------------------------------
 
-    public ExecutionResult executeShellCommand( File workingDirectory,
-                                                String executable,
-                                                String arguments,
-                                                File output )
+    public ExecutionResult executeShellCommand( File workingDirectory, String executable,
String arguments, File output,
+                                                long idCommand )
         throws Exception
     {
         Commandline cl = new Commandline();
@@ -50,16 +48,11 @@
 
         argument.setLine( arguments );
 
-        return executeShellCommand( workingDirectory,
-                                    executable,
-                                    argument.getParts(),
-                                    output );
+        return executeShellCommand( workingDirectory, executable, argument.getParts(), output,
idCommand );
     }
 
-    public ExecutionResult executeShellCommand( File workingDirectory,
-                                                String executable,
-                                                String[] arguments,
-                                                File output )
+    public ExecutionResult executeShellCommand( File workingDirectory, String executable,
String[] arguments,
+                                                File output, long idCommand )
         throws Exception
     {
         // ----------------------------------------------------------------------
@@ -68,6 +61,8 @@
 
         Commandline cl = new Commandline();
 
+        cl.setPid( idCommand );
+
         cl.addSystemEnvironment();
 
         cl.addEnvironment( "MAVEN_TERMINATE_CMD", "on" );
@@ -78,7 +73,7 @@
 
         for ( int i = 0; i < arguments.length; i++ )
         {
-            String argument = arguments[ i ];
+            String argument = arguments[i];
 
             cl.createArgument().setValue( argument );
         }
@@ -104,5 +99,15 @@
         // ----------------------------------------------------------------------
 
         return new ExecutionResult( exitCode );
+    }
+
+    public boolean isRunning( long idCommand )
+    {
+        return CommandLineUtils.isAlive( idCommand );
+    }
+
+    public void killProcess( long idCommand )
+    {
+        CommandLineUtils.killProcess( idCommand );
     }
 }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/ShellCommandHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/ShellCommandHelper.java?rev=377483&r1=377482&r2=377483&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/ShellCommandHelper.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/utils/shell/ShellCommandHelper.java
Mon Feb 13 12:53:09 2006
@@ -26,15 +26,15 @@
 {
     String ROLE = ShellCommandHelper.class.getName();
 
-    ExecutionResult executeShellCommand( File workingDirectory,
-                                         String executable,
-                                         String arguments,
-                                         File output )
+    ExecutionResult executeShellCommand( File workingDirectory, String executable, String
arguments, File output,
+                                         long idCommand )
         throws Exception;
 
-    ExecutionResult executeShellCommand( File workingDirectory,
-                                         String executable,
-                                         String[] arguments,
-                                         File output)
+    ExecutionResult executeShellCommand( File workingDirectory, String executable, String[]
arguments, File output,
+                                         long idCommand )
         throws Exception;
+
+    boolean isRunning( long idCommand );
+
+    void killProcess( long idCommand );
 }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=377483&r1=377482&r2=377483&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
Mon Feb 13 12:53:09 2006
@@ -36,6 +36,9 @@
         <requirement>
           <role>org.apache.maven.continuum.utils.WorkingDirectoryService</role>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.execution.manager.BuildExecutorManager</role>
+        </requirement>
       </requirements>
       <configuration>
         <working-directory>${plexus.home}/temp</working-directory>



Mime
View raw message