You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by tr...@apache.org on 2005/05/31 23:16:52 UTC
svn commit: r179276 - in /maven/continuum/trunk/continuum-core/src/main:
java/org/apache/maven/continuum/buildcontroller/
java/org/apache/maven/continuum/core/
java/org/apache/maven/continuum/core/action/
java/org/apache/maven/continuum/execution/maven/m2/
java/org/apache/maven/continuum/project/builder/maven/
java/org/apache/maven/continuum/store/ resources/META-INF/plexus/
Author: trygvis
Date: Tue May 31 14:16:51 2005
New Revision: 179276
URL: http://svn.apache.org/viewcvs?rev=179276&view=rev
Log: (empty)
Added:
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java (with props)
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromScmContinuumAction.java (with props)
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectMetadataContinuumAction.java (with props)
Modified:
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/ContinuumCore.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=179276&r1=179275&r2=179276&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java Tue May 31 14:16:51 2005
@@ -136,15 +136,24 @@
// build status to error.
// ----------------------------------------------------------------------
+/////////////////////// This section should delegate to UpdateProjectFromScmContinuumAction
+/////////////////////// START SECTION
if ( !update( context ) )
{
return;
}
+/////////////////////// END SECTION
+/////////////////////// This section should delegate to UpdateProjectMetadataContinuumAction
+/////////////////////// START SECTION
if ( !updateProjectMetadata( context ) )
{
return;
}
+/////////////////////// END SECTION
+
+/////////////////////// This section should delegate to ExecuteBuilderContinuumAction
+/////////////////////// START SECTION
// ----------------------------------------------------------------------
// Figure out if the project needs to be built
@@ -164,6 +173,8 @@
makeBuild( context );
buildProject( context );
+
+/////////////////////// END SECTION
}
catch ( ContinuumStoreException ex )
{
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/ContinuumCore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/ContinuumCore.java?rev=179276&r1=179275&r2=179276&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/ContinuumCore.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/ContinuumCore.java Tue May 31 14:16:51 2005
@@ -19,9 +19,9 @@
import java.net.URL;
import java.util.Collection;
import java.util.Properties;
-import java.util.List;
import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
import org.apache.maven.continuum.project.ContinuumBuild;
import org.apache.maven.continuum.project.ContinuumBuildResult;
import org.apache.maven.continuum.project.ContinuumProject;
@@ -93,7 +93,7 @@
throws ContinuumException;
// ----------------------------------------------------------------------
- // Build information
+ // ContinuumBuild
// ----------------------------------------------------------------------
ContinuumBuild getBuild( String buildId )
@@ -106,5 +106,12 @@
throws ContinuumException;
Collection getChangedFilesForBuild( String buildId )
+ throws ContinuumException;
+
+ // ----------------------------------------------------------------------
+ // ContinuumBuildExecutor
+ // ----------------------------------------------------------------------
+
+ ContinuumBuildExecutor getBuildExecutor( String id )
throws ContinuumException;
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java?rev=179276&r1=179275&r2=179276&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/DefaultContinuumCore.java Tue May 31 14:16:51 2005
@@ -30,19 +30,11 @@
import org.apache.maven.continuum.buildqueue.BuildProjectTask;
import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
import org.apache.maven.continuum.execution.ContinuumBuildExecutorException;
-import org.apache.maven.continuum.execution.ant.AntBuildExecutor;
import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
-import org.apache.maven.continuum.execution.maven.m1.MavenOneBuildExecutor;
-import org.apache.maven.continuum.execution.maven.m2.MavenTwoBuildExecutor;
-import org.apache.maven.continuum.execution.shell.ShellBuildExecutor;
-import org.apache.maven.continuum.project.AntProject;
import org.apache.maven.continuum.project.ContinuumBuild;
import org.apache.maven.continuum.project.ContinuumBuildResult;
import org.apache.maven.continuum.project.ContinuumProject;
import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.project.MavenOneProject;
-import org.apache.maven.continuum.project.MavenTwoProject;
-import org.apache.maven.continuum.project.ShellProject;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuilderException;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
@@ -477,224 +469,13 @@
}
// ----------------------------------------------------------------------
- // Ant Projects
+ // ContinuumBuildExecutor
// ----------------------------------------------------------------------
- public void addAntProject( AntProject project )
+ public ContinuumBuildExecutor getBuildExecutor( String id )
throws ContinuumException
{
- Properties configuration = new Properties();
-
- configuration.setProperty( AntBuildExecutor.CONFIGURATION_EXECUTABLE, project.getExecutable() );
-
- configuration.setProperty( AntBuildExecutor.CONFIGURATION_TARGETS, project.getTargets() );
-
- addProjectFromScm( project.getScmUrl(),
- AntBuildExecutor.ID,
- project.getName(),
- project.getNagEmailAddress(),
- project.getVersion(),
- project.getCommandLineArguments(),
- configuration );
- }
-
- public AntProject getAntProject( String id )
- throws ContinuumException
- {
- ContinuumProject p = getProject( id );
-
- AntProject ap = new AntProject();
-
- copyProject( p, ap );
-
- ap.setTargets( p.getConfiguration().getProperty( AntBuildExecutor.CONFIGURATION_TARGETS ) );
-
- ap.setExecutable( p.getConfiguration().getProperty( AntBuildExecutor.CONFIGURATION_EXECUTABLE ) );
-
- return ap;
- }
-
- public void updateAntProject( AntProject project )
- throws ContinuumException
- {
- updateProject( project );
-
- // ----------------------------------------------------------------------
- // The configuration will be null here because the "executable" and
- // "targets" fields in the AntProject are used to create the
- // configuration. We probably don't even need the configuration.
- // ----------------------------------------------------------------------
-
- Properties configuration = new Properties();
-
- configuration.setProperty( AntBuildExecutor.CONFIGURATION_EXECUTABLE, project.getExecutable() );
-
- configuration.setProperty( AntBuildExecutor.CONFIGURATION_TARGETS, project.getTargets() );
-
- updateProjectConfiguration( project.getId(), configuration );
- }
-
- public void addMavenOneProject( MavenOneProject project )
- throws ContinuumException
- {
- Properties configuration = new Properties();
-
- configuration.setProperty( MavenOneBuildExecutor.CONFIGURATION_GOALS, project.getGoals() );
-
- addProjectFromScm( project.getScmUrl(),
- MavenOneBuildExecutor.ID,
- project.getName(),
- project.getNagEmailAddress(),
- project.getVersion(),
- project.getCommandLineArguments(),
- configuration );
- }
-
- public MavenOneProject getMavenOneProject( String id )
- throws ContinuumException
- {
- ContinuumProject p = getProject( id );
-
- MavenOneProject mp = new MavenOneProject();
-
- copyProject( p, mp );
-
- mp.setGoals( p.getConfiguration().getProperty( MavenOneBuildExecutor.CONFIGURATION_GOALS ) );
-
- return mp;
- }
-
- public void updateMavenOneProject( MavenOneProject project )
- throws ContinuumException
- {
- updateProject( project );
-
- Properties configuration = new Properties();
-
- configuration.setProperty( MavenOneBuildExecutor.CONFIGURATION_GOALS, project.getGoals() );
-
- updateProjectConfiguration( project.getId(), configuration );
- }
-
- public void addMavenTwoProject( MavenTwoProject project )
- throws ContinuumException
- {
- Properties configuration = new Properties();
-
- configuration.setProperty( MavenTwoBuildExecutor.CONFIGURATION_GOALS, project.getGoals() );
-
- addProjectFromScm( project.getScmUrl(),
- MavenTwoBuildExecutor.ID,
- project.getName(),
- project.getNagEmailAddress(),
- project.getVersion(),
- project.getCommandLineArguments(),
- configuration );
- }
-
- public MavenTwoProject getMavenTwoProject( String id )
- throws ContinuumException
- {
- ContinuumProject p = getProject( id );
-
- MavenTwoProject mp = new MavenTwoProject();
-
- copyProject( p, mp );
-
- mp.setGoals( p.getConfiguration().getProperty( MavenTwoBuildExecutor.CONFIGURATION_GOALS ) );
-
- return mp;
- }
-
- public void updateMavenTwoProject( MavenTwoProject project )
- throws ContinuumException
- {
- updateProject( project );
-
- Properties configuration = new Properties();
-
- configuration.setProperty( MavenTwoBuildExecutor.CONFIGURATION_GOALS, project.getGoals() );
-
- updateProjectConfiguration( project.getId(), configuration );
- }
-
- public void addShellProject( ShellProject project )
- throws ContinuumException
- {
- Properties configuration = new Properties();
-
- configuration.setProperty( ShellBuildExecutor.CONFIGURATION_EXECUTABLE, project.getExecutable() );
-
- addProjectFromScm( project.getScmUrl(),
- ShellBuildExecutor.ID,
- project.getName(),
- project.getNagEmailAddress(),
- project.getVersion(),
- project.getCommandLineArguments(),
- configuration );
- }
-
- public ShellProject getShellProject( String id )
- throws ContinuumException
- {
- ContinuumProject p = getProject( id );
-
- ShellProject sp = new ShellProject();
-
- copyProject( p, sp );
-
- sp.setExecutable( p.getConfiguration().getProperty( ShellBuildExecutor.CONFIGURATION_EXECUTABLE ) );
-
- return sp;
- }
-
- public void updateShellProject( ShellProject project )
- throws ContinuumException
- {
- updateProject( project );
-
- Properties configuration = new Properties();
-
- configuration.setProperty( ShellBuildExecutor.CONFIGURATION_EXECUTABLE, project.getExecutable() );
-
- updateProjectConfiguration( project.getId(), configuration );
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- private void updateProject( ContinuumProject project )
- throws ContinuumException
- {
- try
- {
- store.updateProject( project.getId(),
- project.getName(),
- project.getScmUrl(),
- project.getNagEmailAddress(),
- project.getVersion(),
- project.getCommandLineArguments() );
- }
- catch ( ContinuumStoreException e )
- {
- throw logAndCreateException( "Error while updating the project.", e );
- }
- }
-
- private void copyProject( ContinuumProject p1, ContinuumProject p2 )
- {
- p2.setId( p1.getId() );
-
- p2.setName( p1.getName() );
-
- p2.setScmUrl( p1.getScmUrl() );
-
- p2.setNagEmailAddress( p1.getNagEmailAddress() );
-
- p2.setVersion( p1.getVersion() );
-
- p2.setExecutorId( p1.getExecutorId() );
+ return buildExecutorManager.getBuildExecutor( id );
}
// ----------------------------------------------------------------------
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?rev=179276&r1=179275&r2=179276&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java Tue May 31 14:16:51 2005
@@ -16,13 +16,18 @@
* limitations under the License.
*/
-import java.util.Map;
import java.io.File;
+import java.util.Map;
+import org.apache.maven.continuum.core.ContinuumCore;
+import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.project.ContinuumBuild;
+import org.apache.maven.continuum.scm.CheckOutScmResult;
+import org.apache.maven.continuum.scm.ContinuumScm;
+import org.apache.maven.continuum.scm.UpdateScmResult;
import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.apache.maven.continuum.scm.ContinuumScm;
-import org.apache.maven.continuum.scm.CheckOutScmResult;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -34,19 +39,34 @@
extends AbstractLogEnabled
implements ContinuumAction
{
+ // ----------------------------------------------------------------------
+ // Keys for the values that can be in the context
+ // ----------------------------------------------------------------------
+
public final static String KEY_PROJECT_ID = "projectId";
+ public final static String KEY_BUILD_ID = "buildId";
+
public static final String KEY_WORKING_DIRECTORY = "workingDirectory";
- public static final String KEY_CHECKOUT_RESULT = "checkOutResult";
+ public static final String KEY_CHECKOUT_SCM_RESULT = "checkOutResult";
+
+ protected static final String KEY_UPDATE_SCM_RESULT = "updateResult";
+
+ private static final String KEY_FORCED = "forced";
// ----------------------------------------------------------------------
- //
+ // Requirements
// ----------------------------------------------------------------------
/**
* @plexus.requirement
*/
+ private ContinuumCore core;
+
+ /**
+ * @plexus.requirement
+ */
private ContinuumStore store;
/**
@@ -54,14 +74,25 @@
*/
private ContinuumScm scm;
+ /**
+ * @plexus.requirement
+ */
+ private ContinuumNotificationDispatcher notifier;
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
- protected abstract void doExecute( Map context )
+ private static ThreadLocal threadContext = new ThreadLocal();
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ protected abstract void doExecute()
throws Exception;
- protected abstract void handleException( Map context, Throwable throwable )
+ protected abstract void handleException( Throwable throwable )
throws ContinuumStoreException;
protected void handleContinuumStoreException( ContinuumStoreException exception )
@@ -69,34 +100,127 @@
getLogger().fatalError( "Error using the store.", exception );
}
+ protected void doFinally()
+ throws ContinuumStoreException
+ {
+ }
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
+ protected ContinuumCore getCore()
+ {
+ return core;
+ }
+
protected ContinuumStore getStore()
{
return store;
}
- protected ContinuumScm getContinuumScm()
+ protected ContinuumScm getScm()
{
return scm;
}
- protected String getProjectId( Map context )
+ protected ContinuumNotificationDispatcher getNotifier()
+ {
+ return notifier;
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ protected void putContext( String key, Object value )
+ {
+ getContext().put( key, value );
+ }
+
+ protected String getProjectId()
+ throws ContinuumStoreException
+ {
+ return getString( KEY_PROJECT_ID );
+ }
+
+ protected String getBuildId()
throws ContinuumStoreException
{
- return getString( context, KEY_PROJECT_ID );
+ return getString( KEY_BUILD_ID );
}
- protected File getWorkingDirectory( Map context )
+ protected boolean isForced()
+ throws ContinuumStoreException
+ {
+ return ((Boolean) getObject( KEY_FORCED )).booleanValue();
+ }
+
+ protected ContinuumProject getProject()
+ throws ContinuumStoreException
+ {
+ return getStore().getProject( getProjectId() );
+ }
+
+ protected ContinuumBuild getBuild()
+ throws ContinuumStoreException
+ {
+ return getStore().getBuild( getBuildId() );
+ }
+
+ protected File getWorkingDirectory()
{
- return new File( getString( context, KEY_WORKING_DIRECTORY ) );
+ return new File( getString( KEY_WORKING_DIRECTORY ) );
}
- protected CheckOutScmResult getCheckOutResult( Map context )
+ protected CheckOutScmResult getCheckOutResult()
{
- return (CheckOutScmResult) getObject( context, KEY_CHECKOUT_RESULT );
+ return (CheckOutScmResult) getObject( KEY_CHECKOUT_SCM_RESULT );
+ }
+
+ protected UpdateScmResult getUpdateScmResult()
+ {
+ return (UpdateScmResult) getObject( KEY_UPDATE_SCM_RESULT );
+ }
+
+ protected UpdateScmResult getUpdateScmResult( UpdateScmResult defaultValue )
+ {
+ return (UpdateScmResult) getObject( KEY_UPDATE_SCM_RESULT, defaultValue );
+ }
+
+// protected void buildCompleted()
+// {
+// }
+//
+// protected void buildError( Throwable throwable )
+// throws ContinuumStoreException
+// {
+// UpdateScmResult updateScmResult = getUpdateScmResult( null );
+//
+// String buildId = getString( KEY_BUILD_ID, null );
+//
+// if ( buildId == null )
+// {
+// createBuild().getId();
+// }
+//
+// getStore().setBuildResult( getProjectId(),
+// ContinuumProjectState.ERROR,
+// null,
+// updateScmResult,
+// throwable );
+// }
+
+ private String getString( String key, String defaultValue )
+ {
+ String value = (String) getContext().get( key );
+
+ if ( value == null )
+ {
+ return defaultValue;
+ }
+
+ return value;
}
// ----------------------------------------------------------------------
@@ -105,9 +229,11 @@
public void execute( Map context )
{
+ threadContext.set( context );
+
try
{
- doExecute( context );
+ doExecute();
}
catch ( ContinuumStoreException e )
{
@@ -117,31 +243,61 @@
{
try
{
- handleException( context, e );
+ handleException( e );
}
catch ( ContinuumStoreException e2 )
{
handleContinuumStoreException( e2 );
}
}
+ finally
+ {
+ try
+ {
+ doFinally();
+ }
+ catch ( ContinuumStoreException e )
+ {
+ handleContinuumStoreException( e );
+ }
+
+ threadContext.set( null );
+ }
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
- private String getString( Map context, String key )
+ private Map getContext()
{
- return (String) getObject( context, key );
+ return (Map) threadContext.get();
}
- private Object getObject( Map context, String key )
+ private String getString( String key )
{
- Object value = context.get( key );
+ return (String) getObject( key );
+ }
+
+ private Object getObject( String key )
+ {
+ Object value = getContext().get( key );
if ( value == null )
{
throw new RuntimeException( "Missing value for key '" + key + "'." );
+ }
+
+ return value;
+ }
+
+ private Object getObject( String key, Object defaultValue )
+ {
+ Object value = getContext().get( key );
+
+ if ( value == null )
+ {
+ return defaultValue;
}
return value;
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java?rev=179276&r1=179275&r2=179276&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckOutProjectContinuumAction.java Tue May 31 14:16:51 2005
@@ -17,7 +17,6 @@
*/
import java.io.File;
-import java.util.Map;
import org.apache.maven.continuum.project.ContinuumProject;
import org.apache.maven.continuum.scm.CheckOutScmResult;
@@ -31,25 +30,25 @@
public class CheckOutProjectContinuumAction
extends AbstractContinuumAction
{
- protected void doExecute( Map context )
+ protected void doExecute()
throws Exception
{
- String projectId = getProjectId( context );
+ String projectId = getProjectId();
ContinuumProject project = getStore().getProject( projectId );
- File workingDirectory = getWorkingDirectory( context );
+ File workingDirectory = getWorkingDirectory();
CheckOutScmResult result;
- result = getContinuumScm().checkOut( project, workingDirectory );
+ result = getScm().checkOut( project, workingDirectory );
getStore().setCheckoutDone( projectId, result, null, null );
- context.put( KEY_CHECKOUT_RESULT, result );
+ putContext( KEY_CHECKOUT_SCM_RESULT, result );
}
- protected void handleException( Map context, Throwable throwable )
+ protected void handleException( Throwable throwable )
throws ContinuumStoreException
{
String errorMessage = null;
@@ -64,8 +63,8 @@
throwable = null;
}
- getStore().setCheckoutDone( getProjectId( context ),
- getCheckOutResult( context ),
+ getStore().setCheckoutDone( getProjectId(),
+ getCheckOutResult(),
errorMessage,
throwable );
}
Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java?rev=179276&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java (added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java Tue May 31 14:16:51 2005
@@ -0,0 +1,112 @@
+package org.apache.maven.continuum.core.action;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Collection;
+
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
+import org.apache.maven.continuum.project.ContinuumBuild;
+import org.apache.maven.continuum.project.ContinuumBuildResult;
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.scm.UpdateScmResult;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
+ * @version $Id$
+ */
+public class ExecuteBuilderContinuumAction
+ extends AbstractContinuumAction
+{
+ protected void doExecute()
+ throws Exception
+ {
+ // ----------------------------------------------------------------------
+ // Get parameters from the context
+ // ----------------------------------------------------------------------
+
+ ContinuumProject project = getProject();
+
+ boolean forced = isForced();
+
+ UpdateScmResult updateScmResult = getUpdateScmResult();
+
+ ContinuumBuildExecutor buildExecutor = getCore().getBuildExecutor( project.getExecutorId() );
+
+ // ----------------------------------------------------------------------
+ // This is really a precondition for this action to execute
+ // ----------------------------------------------------------------------
+
+ if ( updateScmResult.getUpdatedFiles().size() == 0 &&
+ !forced &&
+ !isNew( project ) )
+ {
+ getLogger().info( "No files updated, not building. Project id '" + project.getId() + "'." );
+
+ getStore().setBuildNotExecuted( getProjectId() );
+
+ return;
+ }
+
+ // ----------------------------------------------------------------------
+ // Make the build result
+ // ----------------------------------------------------------------------
+
+ String buildId = getStore().buildingProject( getProjectId(), forced, updateScmResult );
+
+ putContext( KEY_BUILD_ID, buildId );
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ getNotifier().runningGoals( project, getBuild() );
+
+ ContinuumBuildResult result = buildExecutor.build( project );
+
+ int state = result.isSuccess() ?
+ ContinuumProjectState.OK : ContinuumProjectState.FAILED;
+
+ getStore().setBuildResult( buildId,
+ state,
+ result,
+ updateScmResult,
+ null );
+ }
+
+ protected void handleException( Throwable throwable )
+ throws ContinuumStoreException
+ {
+ getStore().setBuildError( getBuildId(),
+ getUpdateScmResult( null ),
+ throwable );
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ private boolean isNew( ContinuumProject project )
+ throws ContinuumException
+ {
+ Collection builds = getCore().getBuildsForProject( project.getId() );
+
+ return builds.size() == 0;
+ }
+}
Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromScmContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromScmContinuumAction.java?rev=179276&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromScmContinuumAction.java (added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromScmContinuumAction.java Tue May 31 14:16:51 2005
@@ -0,0 +1,68 @@
+package org.apache.maven.continuum.core.action;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.scm.UpdateScmResult;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
+ * @version $Id$
+ */
+public class UpdateProjectFromScmContinuumAction
+ extends AbstractContinuumAction
+{
+ protected void doExecute()
+ throws Exception
+ {
+ ContinuumProject project = getProject();
+
+ String projectId = project.getId();
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ getStore().setIsUpdating( projectId );
+
+ getNotifier().checkoutStarted( project );
+
+ UpdateScmResult updateScmResult = getScm().updateProject( project );
+
+ putContext( KEY_UPDATE_SCM_RESULT, updateScmResult );
+
+ getStore().setUpdateDone( projectId );
+ }
+
+ protected void handleException( Throwable throwable )
+ throws ContinuumStoreException
+ {
+ getLogger().fatalError( "Error while updating from SCM. Project id '" + getProjectId() + "'." );
+
+ getStore().setBuildError( getBuildId(),
+ getUpdateScmResult( null ),
+ throwable );
+ }
+
+ protected void doFinally()
+ throws ContinuumStoreException
+ {
+ getNotifier().checkoutComplete( getProject(), getUpdateScmResult() );
+ }
+}
Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromScmContinuumAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromScmContinuumAction.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectMetadataContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectMetadataContinuumAction.java?rev=179276&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectMetadataContinuumAction.java (added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectMetadataContinuumAction.java Tue May 31 14:16:51 2005
@@ -0,0 +1,42 @@
+package org.apache.maven.continuum.core.action;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
+ * @version $Id$
+ */
+public class UpdateProjectMetadataContinuumAction
+ extends AbstractContinuumAction
+{
+ protected void doExecute()
+ throws Exception
+ {
+ getCore().updateProjectFromScm( getProjectId() );
+ }
+
+ protected void handleException( Throwable throwable )
+ throws ContinuumStoreException
+ {
+ getStore().setBuildError( getBuildId(),
+ getUpdateScmResult( null ),
+ throwable );
+ }
+}
Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectMetadataContinuumAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectMetadataContinuumAction.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?rev=179276&r1=179275&r2=179276&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java Tue May 31 14:16:51 2005
@@ -30,7 +30,7 @@
import org.apache.maven.model.Scm;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.settings.MavenSettingsBuilder;
+import org.apache.maven.model.settings.MavenSettingsBuilder;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
@@ -94,7 +94,7 @@
public MavenProject getMavenProject( File file )
throws MavenBuilderHelperException
{
- MavenProject project = null;
+ MavenProject project;
try
{
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?rev=179276&r1=179275&r2=179276&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java Tue May 31 14:16:51 2005
@@ -81,7 +81,7 @@
private void readModules( URL url, ContinuumProjectBuildingResult result )
throws MalformedURLException, ContinuumProjectBuilderException
{
- MavenProject mavenProject = null;
+ MavenProject mavenProject;
try
{
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java?rev=179276&r1=179275&r2=179276&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java Tue May 31 14:16:51 2005
@@ -456,7 +456,8 @@
}
}
- public void setBuildResult( String buildId, int state, ContinuumBuildResult result, UpdateScmResult scmResult, Throwable error )
+ public void setBuildResult( String buildId, int state, ContinuumBuildResult result, UpdateScmResult scmResult,
+ Throwable error )
throws ContinuumStoreException
{
try
@@ -758,6 +759,113 @@
rollback( store );
throw new ContinuumStoreException( "Error while setting update scm result.", e );
+ }
+ }
+
+ public String buildingProject( String projectId,
+ boolean forced,
+ UpdateScmResult scmResult )
+ throws ContinuumStoreException
+ {
+ try
+ {
+ store.begin();
+
+ ContinuumProject project = store.getContinuumProject( projectId, false );
+
+ projectStateGuard.assertInState( project, ContinuumProjectState.BUILDING );
+
+ ContinuumBuild build = new ContinuumBuild();
+
+ build.setStartTime( new Date().getTime() );
+
+ build.setState( ContinuumProjectState.BUILDING );
+
+ project.setState( ContinuumProjectState.BUILDING );
+
+ build.setProject( project );
+
+ build.setForced( forced );
+
+ build.setUpdateScmResult( scmResult );
+
+ Object id = store.addContinuumBuild( build );
+
+ build = store.getContinuumBuildByJdoId( id, false );
+
+ store.commit();
+
+ return build.getId();
+ }
+ catch ( Exception e )
+ {
+ rollback( store );
+
+ throw new ContinuumStoreException( "Error while creating continuum build for project: '" + projectId + "'.", e );
+ }
+
+ }
+
+ public void setBuildComplete( String buildId,
+ UpdateScmResult scmResult,
+ ContinuumBuildResult result )
+ throws ContinuumStoreException
+ {
+ try
+ {
+ store.begin();
+
+ int state = result.isSuccess() ?
+ ContinuumProjectState.OK : ContinuumProjectState.FAILED;
+
+ ContinuumBuild build = store.getContinuumBuild( buildId, false );
+
+ build.setState( state );
+
+ ContinuumProject project = build.getProject();
+
+ project.setState( state );
+
+ build.setBuildResult( result );
+
+ store.commit();
+ }
+ catch ( Exception e )
+ {
+ rollback( store );
+
+ throw new ContinuumStoreException( "Error while setting build result for build: '" + buildId + "'.", e );
+ }
+ }
+
+ public void setBuildError( String buildId,
+ UpdateScmResult scmResult,
+ Throwable throwable )
+ throws ContinuumStoreException
+ {
+ try
+ {
+ store.begin();
+
+ int state = ContinuumProjectState.ERROR;
+
+ ContinuumBuild build = store.getContinuumBuild( buildId, false );
+
+ build.setState( state );
+
+ ContinuumProject project = build.getProject();
+
+ project.setState( state );
+
+ build.setError( throwableToString( throwable ) );
+
+ store.commit();
+ }
+ catch ( Exception e )
+ {
+ rollback( store );
+
+ throw new ContinuumStoreException( "Error while setting build result for build: '" + buildId + "'.", e );
}
}
Modified: maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=179276&r1=179275&r2=179276&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml Tue May 31 14:16:51 2005
@@ -212,7 +212,7 @@
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
<requirement>
- <role>org.apache.maven.settings.MavenSettingsBuilder</role>
+ <role>org.apache.maven.model.settings.MavenSettingsBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
@@ -225,8 +225,8 @@
</component>
<component>
- <role>org.apache.maven.settings.MavenSettingsBuilder</role>
- <implementation>org.apache.maven.settings.DefaultMavenSettingsBuilder</implementation>
+ <role>org.apache.maven.model.settings.MavenSettingsBuilder</role>
+ <implementation>org.apache.maven.model.settings.DefaultMavenSettingsBuilder</implementation>
<configuration>
<settings-path>${plexus.home}/conf/maven-settings.xml</settings-path>
</configuration>