You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2006/05/16 12:27:16 UTC
svn commit: r406895 [2/7] - in /maven/continuum/trunk: ./
continuum-api/src/main/java/org/apache/maven/continuum/
continuum-api/src/main/java/org/apache/maven/continuum/configuration/
continuum-api/src/main/java/org/apache/maven/continuum/execution/ co...
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=406895&r1=406894&r2=406895&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 16 03:26:59 2006
@@ -17,6 +17,7 @@
*/
import org.apache.maven.continuum.core.action.AbstractContinuumAction;
+import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.scm.ChangeFile;
@@ -86,19 +87,49 @@
Project project;
+ BuildDefinition buildDefinition;
+
+ BuildResult oldBuildResult = null;
+
BuildResult build = null;
try
{
project = store.getProject( projectId );
+
+ project.setOldState( project.getState() );
+
+ project.setState( ContinuumProjectState.BUILDING );
+
+ store.updateProject( project );
+
+ buildDefinition = store.getBuildDefinition( buildDefinitionId );
+
+ notifierDispatcher.buildStarted( project );
}
catch ( ContinuumStoreException ex )
{
- getLogger().error( "Internal error while building the project.", ex );
+ getLogger().error( "Internal error while getting the project.", ex );
return;
}
+ try
+ {
+ oldBuildResult = store.getBuildResult( buildDefinition.getLatestBuildId() );
+ }
+ catch ( ContinuumStoreException ex )
+ {
+ // Nothing to do
+ }
+
+ ScmResult oldScmResult = null;
+
+ if ( oldBuildResult != null )
+ {
+ oldScmResult = getOldScmResult( project, oldBuildResult.getEndTime() );
+ }
+
// ----------------------------------------------------------------------
// TODO: Centralize the error handling from the SCM related actions.
// ContinuumScmResult should return a ContinuumScmResult from all
@@ -107,16 +138,20 @@
try
{
- notifierDispatcher.buildStarted( project );
-
Map actionContext = new HashMap();
actionContext.put( AbstractContinuumAction.KEY_PROJECT_ID, new Integer( projectId ) );
+ actionContext.put( AbstractContinuumAction.KEY_PROJECT, project );
+
actionContext.put( AbstractContinuumAction.KEY_BUILD_DEFINITION_ID, new Integer( buildDefinitionId ) );
+ actionContext.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
+
actionContext.put( AbstractContinuumAction.KEY_TRIGGER, new Integer( trigger ) );
+ actionContext.put( AbstractContinuumAction.KEY_FIRST_RUN, Boolean.valueOf( oldBuildResult == null ) );
+
ScmResult scmResult = null;
try
@@ -146,6 +181,9 @@
// Check to see if there was a error while checking out/updating the project
// ----------------------------------------------------------------------
+ // Merge scm results so we'll have all changes since last execution of current build definition
+ scmResult = mergeScmResults( oldScmResult, scmResult );
+
if ( scmResult == null || !scmResult.isSuccess() )
{
// scmResult must be converted before sotring it because jpox modify value of all fields to null
@@ -168,8 +206,6 @@
actionContext.put( AbstractContinuumAction.KEY_UPDATE_SCM_RESULT, scmResult );
- scmResult = (ScmResult) actionContext.get( AbstractContinuumAction.KEY_UPDATE_SCM_RESULT );
-
List changes = scmResult.getChanges();
Iterator iterChanges = changes.iterator();
@@ -186,7 +222,6 @@
while ( iterChanges.hasNext() )
{
-
changeSet = (ChangeSet) iterChanges.next();
changeFiles = changeSet.getFiles();
@@ -210,12 +245,21 @@
}
}
- if ( allChangesUnknown && project.getOldState() != ContinuumProjectState.NEW &&
+ if ( oldBuildResult != null && allChangesUnknown &&
+ project.getOldState() != ContinuumProjectState.NEW &&
+ project.getOldState() != ContinuumProjectState.CHECKEDOUT &&
trigger != ContinuumProjectState.TRIGGER_FORCED &&
- project.getState() != ContinuumProjectState.NEW )
+ project.getState() != ContinuumProjectState.NEW &&
+ project.getState() != ContinuumProjectState.CHECKEDOUT )
{
-
- getLogger().info( "The project was not built because all changes are unknown." );
+ if ( changes.size() > 0 )
+ {
+ getLogger().info( "The project was not built because all changes are unknown." );
+ }
+ else
+ {
+ getLogger().info( "The project was not built because there are no changes." );
+ }
project.setState( project.getOldState() );
@@ -224,13 +268,14 @@
store.updateProject( project );
return;
-
}
actionManager.lookup( "update-project-from-working-directory" ).execute( actionContext );
actionManager.lookup( "execute-builder" ).execute( actionContext );
+ actionManager.lookup( "deploy-artifact" ).execute( actionContext );
+
String s = (String) actionContext.get( AbstractContinuumAction.KEY_BUILD_ID );
if ( s != null )
@@ -313,17 +358,9 @@
}
finally
{
- try
- {
- project = store.getProject( projectId );
- }
- catch ( ContinuumStoreException ex )
- {
- getLogger().error( "Internal error while building the project.", ex );
- }
-
- if ( project.getState() != ContinuumProjectState.NEW && project.getState() != ContinuumProjectState.OK &&
- project.getState() != ContinuumProjectState.FAILED &&
+ if ( project.getState() != ContinuumProjectState.NEW &&
+ project.getState() != ContinuumProjectState.CHECKEDOUT &&
+ project.getState() != ContinuumProjectState.OK && project.getState() != ContinuumProjectState.FAILED &&
project.getState() != ContinuumProjectState.ERROR )
{
try
@@ -406,5 +443,76 @@
store.addBuildResult( project, build );
return store.getBuildResult( build.getId() );
+ }
+
+ private ScmResult getOldScmResult( Project project, long fromDate )
+ {
+ List results = store.getBuildResultsForProject( project.getId(), fromDate );
+
+ ScmResult res = new ScmResult();
+
+ if ( results != null )
+ {
+ for ( Iterator i = results.iterator(); i.hasNext(); )
+ {
+ BuildResult result = (BuildResult) i.next();
+
+ ScmResult scmResult = result.getScmResult();
+
+ if ( scmResult != null )
+ {
+ List changes = scmResult.getChanges();
+
+ if ( changes != null )
+ {
+ for ( Iterator j = changes.iterator(); j.hasNext(); )
+ {
+ ChangeSet changeSet = (ChangeSet) j.next();
+
+ if ( changeSet.getDate() < fromDate )
+ {
+ continue;
+ }
+
+ if ( !res.getChanges().contains( changeSet ) )
+ {
+ res.addChange( changeSet );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return res;
+ }
+
+ private ScmResult mergeScmResults( ScmResult oldScmResult, ScmResult newScmResult )
+ {
+ if ( oldScmResult != null )
+ {
+ if ( newScmResult == null )
+ {
+ return oldScmResult;
+ }
+
+ List oldChanges = oldScmResult.getChanges();
+
+ List newChanges = newScmResult.getChanges();
+
+ for ( Iterator i = newChanges.iterator(); i.hasNext(); )
+ {
+ ChangeSet change = (ChangeSet) i.next();
+
+ if ( !oldChanges.contains( change ) )
+ {
+ oldChanges.add( change );
+ }
+ }
+
+ newScmResult.setChanges( oldChanges );
+ }
+
+ return newScmResult;
}
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildqueue/evaluator/BuildProjectTaskViabilityEvaluator.java Tue May 16 03:26:59 2006
@@ -62,6 +62,7 @@
BuildProjectTask task = (BuildProjectTask) it.next();
Integer key = new Integer( task.getProjectId() );
+
List projectTasks = (List) projects.get( key );
if ( projectTasks == null )
@@ -90,39 +91,42 @@
private List checkTasks( List list )
{
- BuildProjectTask okTask = null;
-
List toBeRemoved = new ArrayList();
for ( Iterator it = list.iterator(); it.hasNext(); )
{
BuildProjectTask buildProjectTask = (BuildProjectTask) it.next();
- if ( okTask == null )
+ for ( Iterator it2 = list.iterator(); it2.hasNext(); )
{
- okTask = buildProjectTask;
-
- continue;
- }
-
- // ----------------------------------------------------------------------
- // If this build is forces, don't remove it
- // ----------------------------------------------------------------------
+ BuildProjectTask task = (BuildProjectTask) it2.next();
- if ( buildProjectTask.getTrigger() == ContinuumProjectState.TRIGGER_FORCED )
- {
- continue;
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- long interval = buildProjectTask.getTimestamp() - okTask.getTimestamp();
-
- if ( interval < requiredBuildInterval )
- {
- toBeRemoved.add( buildProjectTask );
+ // check if it's the same task
+ if ( buildProjectTask == task ||
+ buildProjectTask.getBuildDefinitionId() != task.getBuildDefinitionId() )
+ {
+ continue;
+ }
+
+ // ----------------------------------------------------------------------
+ // If this build is forces, don't remove it
+ // ----------------------------------------------------------------------
+
+ if ( task.getTrigger() == ContinuumProjectState.TRIGGER_FORCED )
+ {
+ continue;
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ long interval = task.getTimestamp() - buildProjectTask.getTimestamp();
+
+ if ( interval < requiredBuildInterval )
+ {
+ toBeRemoved.add( buildProjectTask );
+ }
}
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java Tue May 16 03:26:59 2006
@@ -50,14 +50,14 @@
private SystemConfiguration systemConf;
+ private boolean loaded = false;
+
// ----------------------------------------------------------------------
// Continuum specifics we'll refactor out later
// ----------------------------------------------------------------------
private Map jdks;
- private static final String LS = System.getProperty( "line.separator" );
-
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -114,6 +114,17 @@
systemConf.setWorkingDirectory( workingDirectory.getAbsolutePath() );
}
+ public File getDeploymentRepositoryDirectory()
+ {
+ return getFile( systemConf.getDeploymentRepositoryDirectory() );
+ }
+
+ public void setDeploymentRepositoryDirectory( File deploymentRepositoryDirectory )
+ {
+ systemConf.setDeploymentRepositoryDirectory(
+ deploymentRepositoryDirectory != null ? deploymentRepositoryDirectory.getAbsolutePath() : null );
+ }
+
public void setJdks( Map jdks )
{
this.jdks = jdks;
@@ -136,7 +147,7 @@
public void setCompanyName( String companyName )
{
- systemConf.setCompanyName( companyName );
+ systemConf.setCompanyName( companyName );
}
public String getCompanyUrl()
@@ -207,11 +218,16 @@
public File getFile( String filename )
{
- File f = new File( filename );
+ File f = null;
- if ( !f.isAbsolute() )
+ if ( filename != null && filename.length() != 0 )
{
- f = new File( applicationHome, filename );
+ f = new File( filename );
+
+ if ( !f.isAbsolute() )
+ {
+ f = new File( applicationHome, filename );
+ }
}
return f;
@@ -221,6 +237,11 @@
// Load and Store
// ----------------------------------------------------------------------
+ public boolean isLoaded()
+ {
+ return loaded;
+ }
+
public void load()
throws ConfigurationLoadingException
{
@@ -234,6 +255,8 @@
systemConf = store.addSystemConfiguration( systemConf );
}
+
+ loaded = true;
}
catch ( ContinuumStoreException e )
{
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=406895&r1=406894&r2=406895&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 16 03:26:59 2006
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectGroup;
import org.apache.maven.continuum.model.scm.ScmResult;
@@ -38,8 +39,12 @@
public static final String KEY_PROJECT_ID = "project-id";
+ public static final String KEY_PROJECT = "project";
+
public static final String KEY_BUILD_DEFINITION_ID = "build-definition-id";
+ public static final String KEY_BUILD_DEFINITION = "build-definition";
+
public static final String KEY_UNVALIDATED_PROJECT = "unvalidated-project";
public static final String KEY_PROJECT_GROUP_ID = "project-group-id";
@@ -58,6 +63,8 @@
public static final String KEY_TRIGGER = "trigger";
+ public static final String KEY_FIRST_RUN = "first-run";
+
// ----------------------------------------------------------------------
// Utils
// ----------------------------------------------------------------------
@@ -81,6 +88,11 @@
return getInteger( context, KEY_PROJECT_ID );
}
+ public static Project getProject( Map context )
+ {
+ return (Project) getObject( context, KEY_PROJECT );
+ }
+
public static int getProjectGroupId( Map context )
{
return Integer.valueOf( getString( context, KEY_PROJECT_GROUP_ID ) ).intValue();
@@ -89,6 +101,11 @@
public static int getBuildDefinitionId( Map context )
{
return getInteger( context, KEY_BUILD_DEFINITION_ID );
+ }
+
+ public static BuildDefinition getBuildDefinition( Map context )
+ {
+ return (BuildDefinition) getObject( context, KEY_BUILD_DEFINITION );
}
public static String getBuildId( Map context )
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=406895&r1=406894&r2=406895&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 16 03:26:59 2006
@@ -42,9 +42,7 @@
public void execute( Map context )
throws Exception
{
- Project project = store.getProject( getProjectId( context ) );
-
- int state = project.getState();
+ Project project = getProject( context );
project.setState( ContinuumProjectState.CHECKING_OUT );
@@ -57,6 +55,7 @@
// ----------------------------------------------------------------------
ScmResult result;
+
try
{
result = scm.checkOut( project, workingDirectory );
@@ -69,7 +68,9 @@
if ( cause instanceof NoSuchScmProviderException )
{
result = new ScmResult();
+
result.setSuccess( false );
+
result.setProviderMessage( cause.getMessage() );
}
else if ( e.getResult() != null )
@@ -79,7 +80,9 @@
else
{
result = new ScmResult();
+
result.setSuccess( false );
+
result.setException( ContinuumUtils.throwableMessagesToString( e ) );
}
}
@@ -87,15 +90,18 @@
{
// TODO: do we want this here, or should it be to the logs?
result = new ScmResult();
+
result.setSuccess( false );
+
result.setException( ContinuumUtils.throwableMessagesToString( t ) );
}
finally
{
- project.setState( state );
+ project.setState( ContinuumProjectState.CHECKEDOUT );
store.updateProject( project );
}
+
context.put( KEY_CHECKOUT_SCM_RESULT, result );
}
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadata.java Tue May 16 03:26:59 2006
@@ -1,21 +1,32 @@
-/*
- * Copyright (c) 2005 Your Corporation. All Rights Reserved.
- */
package org.apache.maven.continuum.core.action;
+/*
+ * Copyright 2004-2006 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.ContinuumException;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuilderException;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
import org.apache.maven.continuum.project.builder.manager.ContinuumProjectBuilderManager;
import org.apache.maven.continuum.project.builder.manager.ContinuumProjectBuilderManagerException;
+import org.codehaus.plexus.formica.util.MungedHttpsURL;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
-import org.codehaus.plexus.formica.util.MungedHttpsURL;
-
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
@@ -42,7 +53,7 @@
ContinuumProjectBuilder projectBuilder = projectBuilderManager.getProjectBuilder( projectBuilderId );
- ContinuumProjectBuildingResult result = null;
+ ContinuumProjectBuildingResult result;
try
{
Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java?rev=406895&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java (added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java Tue May 16 03:26:59 2006
@@ -0,0 +1,126 @@
+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.artifact.Artifact;
+import org.apache.maven.artifact.deployer.ArtifactDeployer;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
+import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
+import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.utils.WorkingDirectoryService;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class DeployArtifactContinuumAction
+ extends AbstractContinuumAction
+{
+ /**
+ * @plexus.requirement
+ */
+ private ConfigurationService configurationService;
+
+ /**
+ * @plexus.requirement
+ */
+ private BuildExecutorManager buildExecutorManager;
+
+ /**
+ * @plexus.requirement
+ */
+ private WorkingDirectoryService workingDirectoryService;
+
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactDeployer artifactDeployer;
+
+ /**
+ * @plexus.requirement
+ */
+ private MavenBuilderHelper builderHelper;
+
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+ public void execute( Map context )
+ throws Exception
+ {
+ // ----------------------------------------------------------------------
+ // Get parameters from the context
+ // ----------------------------------------------------------------------
+
+ File deploymentRepositoryDirectory = configurationService.getDeploymentRepositoryDirectory();
+
+ if ( deploymentRepositoryDirectory != null )
+ {
+ Project project = getProject( context );
+
+ ContinuumBuildExecutor buildExecutor = buildExecutorManager.getBuildExecutor( project.getExecutorId() );
+
+ // ----------------------------------------------------------------------
+ // This is really a precondition for this action to execute
+ // ----------------------------------------------------------------------
+
+ if ( project.getState() == ContinuumProjectState.OK )
+ {
+ BuildDefinition buildDefinition = getBuildDefinition( context );
+
+ List artifacts = buildExecutor.getDeployableArtifacts(
+ workingDirectoryService.getWorkingDirectory( project ), buildDefinition );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact artifact = (Artifact) i.next();
+
+ ArtifactRepository localRepository = builderHelper.getLocalRepository();
+
+ ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout();
+
+ if ( !deploymentRepositoryDirectory.exists() )
+ {
+ deploymentRepositoryDirectory.mkdirs();
+ }
+
+ String location = deploymentRepositoryDirectory.toURL().toExternalForm();
+
+ ArtifactRepository deploymentRepository =
+ artifactRepositoryFactory.createDeploymentArtifactRepository( "deployment-repository", location,
+ repositoryLayout, true );
+
+ artifactDeployer.deploy( artifact.getFile(), artifact, deploymentRepository, localRepository );
+ }
+ }
+ }
+ }
+}
Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: 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=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java Tue May 16 03:26:59 2006
@@ -67,20 +67,25 @@
// Get parameters from the context
// ----------------------------------------------------------------------
- Project project = store.getProjectWithBuildDetails( getProjectId( context ) );
+ Project project = getProject( context );
+
+ BuildDefinition buildDefinition = getBuildDefinition( context );
int trigger = getTrigger( context );
ScmResult scmResult = getUpdateScmResult( context );
+ boolean isFirstRun = ( (Boolean) context.get( AbstractContinuumAction.KEY_FIRST_RUN ) ).booleanValue();
+
ContinuumBuildExecutor buildExecutor = buildExecutorManager.getBuildExecutor( project.getExecutorId() );
// ----------------------------------------------------------------------
// This is really a precondition for this action to execute
// ----------------------------------------------------------------------
- if ( project.getOldState() != ContinuumProjectState.NEW && scmResult.getChanges().size() == 0
- && trigger != ContinuumProjectState.TRIGGER_FORCED && !isNew( project ) )
+ if ( !isFirstRun && project.getOldState() != ContinuumProjectState.NEW &&
+ project.getOldState() != ContinuumProjectState.CHECKEDOUT && scmResult.getChanges().size() == 0 &&
+ trigger != ContinuumProjectState.TRIGGER_FORCED && !isNew( project ) )
{
getLogger().info( "No files updated, not building. Project id '" + project.getId() + "'." );
@@ -105,8 +110,6 @@
build.setTrigger( trigger );
- BuildDefinition buildDefinition = store.getBuildDefinition( getBuildDefinitionId( context ) );
-
build.setScmResult( scmResult );
store.addBuildResult( project, build );
@@ -146,14 +149,18 @@
project.setLatestBuildId( build.getId() );
+ buildDefinition.setLatestBuildId( build.getId() );
+
build.setBuildNumber( project.getBuildNumber() );
- if ( build.getState() != ContinuumProjectState.OK && build.getState() != ContinuumProjectState.FAILED
- && build.getState() != ContinuumProjectState.ERROR )
+ if ( build.getState() != ContinuumProjectState.OK && build.getState() != ContinuumProjectState.FAILED &&
+ build.getState() != ContinuumProjectState.ERROR )
{
build.setState( ContinuumProjectState.ERROR );
}
+ project.setState( build.getState() );
+
// ----------------------------------------------------------------------
// Copy over the build result
// ----------------------------------------------------------------------
@@ -162,6 +169,8 @@
build = store.getBuildResult( build.getId() );
+ store.storeBuildDefinition( buildDefinition );
+
store.updateProject( project );
notifier.goalsCompleted( project, build );
@@ -174,6 +183,7 @@
private boolean isNew( Project project )
{
- return project.getState() == ContinuumProjectState.NEW;
+ return project.getState() == ContinuumProjectState.NEW ||
+ project.getState() == ContinuumProjectState.CHECKEDOUT;
}
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java Tue May 16 03:26:59 2006
@@ -47,7 +47,9 @@
public void execute( Map context )
throws ContinuumStoreException, ContinuumException, ContinuumBuildExecutorException
{
- Project project = store.getProjectWithBuildDetails( getProjectId( context ) );
+ Project project = getProject( context );
+
+ project = store.getProjectWithAllDetails( project.getId() );
getLogger().info( "Updating project '" + project.getName() + "' from checkout." );
@@ -59,7 +61,8 @@
ContinuumBuildExecutor builder = buildExecutorManager.getBuildExecutor( project.getExecutorId() );
- builder.updateProjectFromCheckOut( workingDirectoryService.getWorkingDirectory( project ), project, buildDefinition );
+ builder.updateProjectFromCheckOut( workingDirectoryService.getWorkingDirectory( project ), project,
+ buildDefinition );
// ----------------------------------------------------------------------
// Store the new descriptor
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java Tue May 16 03:26:59 2006
@@ -41,7 +41,7 @@
public void execute( Map context )
throws Exception
{
- Project project = store.getProject( getProjectId( context ) );
+ Project project = getProject( context );
int state = project.getState();
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- 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 Tue May 16 03:26:59 2006
@@ -17,6 +17,7 @@
*/
import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.utils.WorkingDirectoryService;
import org.apache.maven.continuum.utils.shell.ExecutionResult;
import org.apache.maven.continuum.utils.shell.ShellCommandHelper;
@@ -29,6 +30,7 @@
import java.io.File;
import java.util.Iterator;
import java.util.List;
+import java.util.Collections;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
@@ -179,16 +181,10 @@
// Execute the build
// ----------------------------------------------------------------------
- getLogger().warn( "Executable '" + actualExecutable + "'." );
-
- getLogger().info( "Arguments: " + arguments );
-
- getLogger().info( "Working directory: " + workingDirectory.getAbsolutePath() );
-
try
{
ExecutionResult result = shellCommandHelper.executeShellCommand( workingDirectory, actualExecutable,
- arguments, output );
+ arguments, output, project.getId() );
getLogger().info( "Exit code: " + result.getExitCode() );
@@ -199,6 +195,23 @@
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 List getDeployableArtifacts( File workingDirectory, BuildDefinition buildDefinition )
+ throws ContinuumBuildExecutorException
+ {
+ // Not supported by this builder
+ return Collections.EMPTY_LIST;
}
public File getWorkingDirectory( Project project )
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java Tue May 16 03:26:59 2006
@@ -162,7 +162,8 @@
if ( StringUtils.isEmpty( scmConnection ) )
{
- throw new MavenOneMetadataHelperException( "Missing both anonymous and developer SCM connection URLs." );
+ throw new MavenOneMetadataHelperException(
+ "Missing both anonymous and developer SCM connection URLs." );
}
}
@@ -241,18 +242,10 @@
Xpp3Dom build = mavenProject.getChild( "build" );
- List notifiers = null;
+ List notifiers = new ArrayList();
- ProjectNotifier notifier = new ProjectNotifier();
-
- if ( build == null )
- {
- if ( project.getNotifiers() != null && !project.getNotifiers().isEmpty() )
- {
- notifiers = project.getNotifiers();
- }
- }
- else
+ // Add project Notifier
+ if ( build != null )
{
String nagEmailAddress = getValue( build, "nagEmailAddress", null );
@@ -262,42 +255,28 @@
props.put( ContinuumRecipientSource.ADDRESS_FIELD, nagEmailAddress );
+ ProjectNotifier notifier = new ProjectNotifier();
+
notifier.setConfiguration( props );
notifier.setFrom( ProjectNotifier.FROM_PROJECT );
+
+ notifiers.add( notifier );
}
}
- if ( notifier == null && ( notifiers == null || notifiers.isEmpty() ) )
- {
- }
- else
+ // Add all user notifiers
+ if ( project.getNotifiers() != null && !project.getNotifiers().isEmpty() )
{
- if ( notifiers == null )
- {
- notifiers = new ArrayList();
- }
- notifiers.add( notifier );
-
- // Add notifier defined by user
for ( Iterator i = project.getNotifiers().iterator(); i.hasNext(); )
{
ProjectNotifier notif = (ProjectNotifier) i.next();
if ( notif.isFromUser() )
{
- ProjectNotifier userNotifier = new ProjectNotifier();
-
- userNotifier.setType( notif.getType() );
-
- userNotifier.setConfiguration( notif.getConfiguration() );
-
- userNotifier.setFrom( notif.getFrom() );
-
- notifiers.add( userNotifier );
+ notifiers.add( notif );
}
}
-
}
// ----------------------------------------------------------------------
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=406895&r1=406894&r2=406895&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 16 03:26:59 2006
@@ -33,14 +33,15 @@
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.profiles.DefaultProfileManager;
import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.project.InvalidProjectModelException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.settings.MavenSettingsBuilder;
import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.SettingsUtils;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
@@ -114,8 +115,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() ) )
@@ -209,30 +218,27 @@
// Dependencies
// ----------------------------------------------------------------------
- if ( mavenProject.getDependencies() != null )
- {
- List dependencies = new ArrayList();
-
- for ( Iterator i = mavenProject.getDependencies().iterator(); i.hasNext(); )
- {
- Dependency dependency = (Dependency) i.next();
+ List dependencies = new ArrayList();
- ProjectDependency cd = new ProjectDependency();
+ for ( Iterator i = mavenProject.getDependencies().iterator(); i.hasNext(); )
+ {
+ Dependency dependency = (Dependency) i.next();
- cd.setGroupId( dependency.getGroupId() );
+ ProjectDependency cd = new ProjectDependency();
- cd.setArtifactId( dependency.getArtifactId() );
+ cd.setGroupId( dependency.getGroupId() );
- cd.setVersion( dependency.getVersion() );
+ cd.setArtifactId( dependency.getArtifactId() );
- dependencies.add( cd );
- }
+ cd.setVersion( dependency.getVersion() );
- continuumProject.setDependencies( dependencies );
+ dependencies.add( cd );
}
+ continuumProject.setDependencies( dependencies );
+
// ----------------------------------------------------------------------
- //
+ // Notifiers
// ----------------------------------------------------------------------
List userNotifiers = new ArrayList();
@@ -249,10 +255,22 @@
userNotifier.setType( notifier.getType() );
+ userNotifier.setEnabled( notifier.isEnabled() );
+
userNotifier.setConfiguration( notifier.getConfiguration() );
userNotifier.setFrom( notifier.getFrom() );
+ userNotifier.setRecipientType( notifier.getRecipientType() );
+
+ userNotifier.setSendOnError( notifier.isSendOnError() );
+
+ userNotifier.setSendOnFailure( notifier.isSendOnFailure() );
+
+ userNotifier.setSendOnSuccess( notifier.isSendOnSuccess() );
+
+ userNotifier.setSendOnWarning( notifier.isSendOnWarning() );
+
userNotifiers.add( userNotifier );
}
}
@@ -283,11 +301,9 @@
writeSettings( settings );
}
- ProfileManager profileManager = new DefaultProfileManager( container );
-
- loadSettingsProfiles( profileManager, settings );
+ ProfileManager profileManager = new DefaultProfileManager( container, settings );
- project = projectBuilder.build( file, getRepository( settings ), profileManager, false );
+ project = projectBuilder.build( file, getLocalRepository(), profileManager, false );
if ( getLogger().isDebugEnabled() )
{
@@ -298,7 +314,25 @@
}
catch ( Exception e )
{
- String msg = "Cannot build maven project from " + file + " (" + e.getMessage() + ").";
+ StringBuffer messages = new StringBuffer();
+
+ if ( e instanceof InvalidProjectModelException )
+ {
+ InvalidProjectModelException ex = (InvalidProjectModelException) e;
+
+ ModelValidationResult validationResult = ex.getValidationResult();
+
+ if ( validationResult != null && validationResult.getMessageCount() > 0 )
+ {
+ for ( Iterator i = validationResult.getMessages().iterator(); i.hasNext(); )
+ {
+ messages.append( (String) i.next() );
+ messages.append( "\n" );
+ }
+ }
+ }
+
+ String msg = "Cannot build maven project from " + file + " (" + e.getMessage() + ").\n" + messages;
getLogger().error( msg, e );
@@ -329,6 +363,11 @@
return project;
}
+ public ArtifactRepository getLocalRepository()
+ {
+ return getRepository( settings );
+ }
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -437,27 +476,6 @@
return artifactRepositoryFactory.createArtifactRepository( "local", "file://" + localRepo, repositoryLayout,
null, null );
- }
-
- private void loadSettingsProfiles( ProfileManager profileManager, Settings settings )
- {
- List settingsProfiles = settings.getProfiles();
-
- if ( settingsProfiles != null && !settingsProfiles.isEmpty() )
- {
- List settingsActiveProfileIds = settings.getActiveProfiles();
-
- profileManager.explicitlyActivate( settingsActiveProfileIds );
-
- for ( Iterator it = settings.getProfiles().iterator(); it.hasNext(); )
- {
- org.apache.maven.settings.Profile rawProfile = (org.apache.maven.settings.Profile) it.next();
-
- Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile );
-
- profileManager.addProfile( profile );
- }
- }
}
private void writeSettings( Settings settings )
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java Tue May 16 03:26:59 2006
@@ -18,6 +18,7 @@
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.artifact.repository.ArtifactRepository;
import java.io.File;
@@ -37,4 +38,6 @@
void mapMavenProjectToContinuumProject( MavenProject mavenProject, Project continuumProject )
throws MavenBuilderHelperException;
+
+ ArtifactRepository getLocalRepository();
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- 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 Tue May 16 03:26:59 2006
@@ -16,15 +16,22 @@
* limitations under the License.
*/
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.continuum.execution.AbstractBuildExecutor;
import org.apache.maven.continuum.execution.ContinuumBuildExecutionResult;
import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
import org.apache.maven.continuum.execution.ContinuumBuildExecutorException;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
@@ -51,6 +58,11 @@
*/
private MavenBuilderHelper builderHelper;
+ /**
+ * @plexus.requirement
+ */
+ private MavenProjectHelper projectHelper;
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -80,8 +92,8 @@
arguments = "-f " + buildFile + " ";
}
- arguments += StringUtils.clean( buildDefinition.getArguments() ) + " " +
- StringUtils.clean( buildDefinition.getGoals() );
+ arguments +=
+ StringUtils.clean( buildDefinition.getArguments() ) + " " + StringUtils.clean( buildDefinition.getGoals() );
return executeShellCommand( project, executable, arguments, buildOutput );
}
@@ -89,6 +101,25 @@
public void updateProjectFromCheckOut( File workingDirectory, Project project, BuildDefinition buildDefinition )
throws ContinuumBuildExecutorException
{
+ File f = getPomFile( buildDefinition, workingDirectory );
+
+ if ( !f.exists() )
+ {
+ throw new ContinuumBuildExecutorException( "Could not find Maven project descriptor." );
+ }
+
+ try
+ {
+ builderHelper.mapMetadataToProject( f, project );
+ }
+ catch ( MavenBuilderHelperException e )
+ {
+ throw new ContinuumBuildExecutorException( "Error while mapping metadata.", e );
+ }
+ }
+
+ private static File getPomFile( BuildDefinition buildDefinition, File workingDirectory )
+ {
File f = null;
if ( buildDefinition != null )
@@ -106,18 +137,109 @@
f = new File( workingDirectory, "pom.xml" );
}
+ return f;
+ }
+
+ public List getDeployableArtifacts( File workingDirectory, BuildDefinition buildDefinition )
+ throws ContinuumBuildExecutorException
+ {
+ File f = getPomFile( buildDefinition, workingDirectory );
+
if ( !f.exists() )
{
- throw new ContinuumBuildExecutorException( "Could not find Maven project descriptor." );
+ throw new ContinuumBuildExecutorException( "Could not find Maven project descriptor '" + f + "'." );
}
+ MavenProject project;
+
try
{
- builderHelper.mapMetadataToProject( f, project );
+ project = builderHelper.getMavenProject( f );
}
catch ( MavenBuilderHelperException e )
{
- throw new ContinuumBuildExecutorException( "Error while mapping metadata.", e );
+ throw new ContinuumBuildExecutorException(
+ "Unable to read the Maven project descriptor '" + f + "': " + e.getMessage(), e );
+ }
+
+ List artifacts = new ArrayList( 1 );
+
+ // Maven could help us out a lot more here by knowing how to get the deployment artifacts from a project.
+ // TODO: this is currently quite lame
+
+ Artifact artifact = project.getArtifact();
+
+ String projectPackaging = project.getPackaging();
+
+ boolean isPomArtifact = "pom".equals( projectPackaging );
+
+ if ( isPomArtifact )
+ {
+ artifact.setFile( project.getFile() );
}
+ else
+ {
+ // Attach pom
+ ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, project.getFile() );
+
+ artifact.addMetadata( metadata );
+
+ String finalName = project.getBuild().getFinalName();
+
+ String filename = finalName + "." + artifact.getArtifactHandler().getExtension();
+
+ String buildDirectory = project.getBuild().getDirectory();
+
+ File artifactFile = new File( buildDirectory, filename );
+
+ artifact.setFile( artifactFile );
+
+ // sources jar
+ File sourcesFile = new File( buildDirectory, finalName + "-sources.jar" );
+
+ if ( sourcesFile.exists() )
+ {
+ projectHelper.attachArtifact( project, "java-source", "sources", sourcesFile );
+ }
+
+ // tests sources jar
+ File testsSourcesFile = new File( buildDirectory, finalName + "-test-sources.jar" );
+
+ if ( testsSourcesFile.exists() )
+ {
+ projectHelper.attachArtifact( project, "java-source", "test-sources", testsSourcesFile );
+ }
+
+ // javadoc jar
+ File javadocFile = new File( buildDirectory, finalName + "-javadoc.jar" );
+
+ if ( javadocFile.exists() )
+ {
+ projectHelper.attachArtifact( project, "javadoc", "javadoc", javadocFile );
+ }
+
+ // client jar
+ File clientFile = new File( buildDirectory, finalName + "-client.jar" );
+
+ if ( clientFile.exists() )
+ {
+ projectHelper.attachArtifact( project, projectPackaging + "-client", "client", clientFile );
+ }
+
+ // Tests jar
+ File testsFile = new File( buildDirectory, finalName + "-tests.jar" );
+
+ if ( testsFile.exists() )
+ {
+ projectHelper.attachArtifact( project, "jar", "tests", testsFile );
+ }
+ }
+
+ if ( artifact.getFile().exists() )
+ {
+ artifacts.add( artifact );
+ }
+
+ return artifacts;
}
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java Tue May 16 03:26:59 2006
@@ -19,8 +19,8 @@
import org.apache.maven.continuum.model.project.Schedule;
import org.apache.maven.continuum.model.system.ContinuumUser;
import org.apache.maven.continuum.model.system.Permission;
-import org.apache.maven.continuum.model.system.UserGroup;
import org.apache.maven.continuum.model.system.SystemConfiguration;
+import org.apache.maven.continuum.model.system.UserGroup;
import org.apache.maven.continuum.security.ContinuumSecurity;
import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.store.ContinuumStoreException;
@@ -55,8 +55,6 @@
//TODO: move this to an other place
public static final String DEFAULT_SCHEDULE_NAME = "DEFAULT_SCHEDULE";
- private Schedule defaultSchedule;
-
private SystemConfiguration systemConf;
// ----------------------------------------------------------------------
@@ -94,9 +92,9 @@
if ( s == null )
{
- defaultSchedule = createDefaultSchedule();
+ Schedule defaultSchedule = createDefaultSchedule();
- defaultSchedule = store.addSchedule( defaultSchedule );
+ store.addSchedule( defaultSchedule );
}
// Permission
@@ -164,7 +162,7 @@
createPermission( "manageUsers", "Manage Users/Groups" );
}
- private Permission createPermission( String name, String description)
+ private Permission createPermission( String name, String description )
throws ContinuumStoreException
{
Permission perm = store.getPermission( name );
@@ -199,7 +197,7 @@
adminGroup.setPermissions( adminPermissions );
- adminGroup = store.addUserGroup( adminGroup );
+ store.addUserGroup( adminGroup );
}
// Continuum Guest
@@ -219,7 +217,7 @@
guestGroup.setPermissions( guestPermissions );
- guestGroup = store.addUserGroup( guestGroup );
+ store.addUserGroup( guestGroup );
}
}
@@ -238,7 +236,7 @@
guest.setGuest( true );
- guest = store.addUser( guest );
+ store.addUser( guest );
}
}
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumRecipientSource.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumRecipientSource.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumRecipientSource.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/ContinuumRecipientSource.java Tue May 16 03:26:59 2006
@@ -74,6 +74,9 @@
{
Project project = (Project) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT );
+ ProjectNotifier projectNotifier =
+ (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER );
+
if ( project == null )
{
throw new NotificationException( "Missing project from the notification context." );
@@ -85,6 +88,10 @@
{
recipients.add( toOverride );
}
+ else if ( projectNotifier != null )
+ {
+ addNotifierAdresses( projectNotifier, recipients );
+ }
else if ( project.getNotifiers() != null && !project.getNotifiers().isEmpty() )
{
for ( Iterator notifierIterator = project.getNotifiers().iterator(); notifierIterator.hasNext(); )
@@ -94,14 +101,7 @@
if ( notifier.getId() == new Integer( notifierId ).intValue() &&
notifier.getConfiguration().containsKey( ADDRESS_FIELD ) )
{
- String addressField = (String) notifier.getConfiguration().get( ADDRESS_FIELD );
-
- String[] addresses = StringUtils.split( addressField, "," );
-
- for ( int i = 0; i < addresses.length; i++ )
- {
- recipients.add( addresses[i].trim() );
- }
+ addNotifierAdresses( notifier, recipients );
}
}
}
@@ -113,6 +113,24 @@
else
{
return recipients;
+ }
+ }
+
+ private void addNotifierAdresses( ProjectNotifier notifier, Set recipients )
+ {
+ if ( notifier.getConfiguration() != null )
+ {
+ String addressField = (String) notifier.getConfiguration().get( ADDRESS_FIELD );
+
+ if ( StringUtils.isNotEmpty( addressField ) )
+ {
+ String[] addresses = StringUtils.split( addressField, "," );
+
+ for ( int i = 0; i < addresses.length; i++ )
+ {
+ recipients.add( addresses[i].trim() );
+ }
+ }
}
}
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java Tue May 16 03:26:59 2006
@@ -16,8 +16,8 @@
* limitations under the License.
*/
-import org.apache.maven.continuum.configuration.ConfigurationService;
import org.apache.maven.continuum.configuration.ConfigurationException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectNotifier;
@@ -126,7 +126,8 @@
if ( build.getEndTime() != 0 )
{
- context.put( CONTEXT_BUILD_OUTPUT, configurationService.getBuildOutput( build.getId(), project.getId() ) );
+ context.put( CONTEXT_BUILD_OUTPUT,
+ configurationService.getBuildOutput( build.getId(), project.getId() ) );
}
context.put( CONTEXT_UPDATE_SCM_RESULT, build.getScmResult() );
@@ -162,12 +163,14 @@
try
{
+ context.put( CONTEXT_PROJECT_NOTIFIER, projectNotifier );
+
Notifier notifier = notifierManager.getNotifier( notifierType );
- Set recipients = recipientSource.getRecipients( String.valueOf( projectNotifier.getId() ),
- messageId, configuration, context );
+ Set recipients = recipientSource.getRecipients( String.valueOf( projectNotifier.getId() ), messageId,
+ configuration, context );
- notifier.sendNotification( messageId, recipients, projectNotifier.getConfiguration(), context );
+ notifier.sendNotification( messageId, recipients, configuration, context );
}
catch ( NotificationException e )
{
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/FormatterTool.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/FormatterTool.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/FormatterTool.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/FormatterTool.java Tue May 16 03:26:59 2006
@@ -39,7 +39,7 @@
// TODO: Add i18n
public String formatProjectState( int state )
{
- if ( state == ContinuumProjectState.NEW )
+ if ( state == ContinuumProjectState.NEW || state == ContinuumProjectState.CHECKEDOUT )
{
return "New";
}
@@ -67,7 +67,7 @@
public String formatTrigger( int trigger )
{
- if ( trigger == ContinuumProjectState.TRIGGER_UNKNOWN )
+ if ( trigger == ContinuumProjectState.TRIGGER_SCHEDULED )
{
// TODO: fix this
return "Schedule";
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java Tue May 16 03:26:59 2006
@@ -19,6 +19,7 @@
import org.apache.maven.continuum.configuration.ConfigurationService;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
import org.apache.maven.continuum.notification.ContinuumRecipientSource;
@@ -176,6 +177,9 @@
{
Project project = (Project) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT );
+ ProjectNotifier projectNotifier =
+ (ProjectNotifier) context.get( ContinuumNotificationDispatcher.CONTEXT_PROJECT_NOTIFIER );
+
BuildResult build = (BuildResult) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD );
String buildOutput = (String) context.get( ContinuumNotificationDispatcher.CONTEXT_BUILD_OUTPUT );
@@ -195,12 +199,12 @@
if ( source.equals( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE ) )
{
- buildComplete( project, build, buildOutput, source, recipients, configuration );
+ buildComplete( project, projectNotifier, build, buildOutput, source, recipients, configuration );
}
}
- private void buildComplete( Project project, BuildResult build, String buildOutput, String source, Set recipients,
- Map configuration )
+ private void buildComplete( Project project, ProjectNotifier projectNotifier, BuildResult build, String buildOutput,
+ String source, Set recipients, Map configuration )
throws NotificationException
{
// ----------------------------------------------------------------------
@@ -209,7 +213,7 @@
BuildResult previousBuild = getPreviousBuild( project, build );
- if ( !shouldNotify( build, previousBuild ) )
+ if ( !shouldNotify( build, previousBuild, projectNotifier ) )
{
return;
}
@@ -267,8 +271,8 @@
context.put( "osName", osName );
- context.put( "javaVersion", System.getProperty( "java.version" ) + "("
- + System.getProperty( "java.vendor" ) + ")" );
+ context.put( "javaVersion",
+ System.getProperty( "java.version" ) + "(" + System.getProperty( "java.vendor" ) + ")" );
// ----------------------------------------------------------------------
// Generate
@@ -354,9 +358,8 @@
if ( fromMailbox == null )
{
getLogger()
- .warn(
- project.getName()
- + ": Project is missing nag email and global from mailbox is missing, not sending mail." );
+ .warn( project.getName() +
+ ": Project is missing nag email and global from mailbox is missing, not sending mail." );
return;
}
@@ -449,8 +452,8 @@
if ( currentBuild != null && build.getId() != currentBuild.getId() )
{
- throw new NotificationException( "INTERNAL ERROR: The current build wasn't the first in the build list. "
- + "Current build: '" + currentBuild.getId() + "', " + "first build: '" + build.getId() + "'." );
+ throw new NotificationException( "INTERNAL ERROR: The current build wasn't the first in the build list. " +
+ "Current build: '" + currentBuild.getId() + "', " + "first build: '" + build.getId() + "'." );
}
return (BuildResult) builds.get( builds.size() - 2 );
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=406895&r1=406894&r2=406895&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 16 03:26:59 2006
@@ -19,8 +19,8 @@
import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper;
import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelperException;
import org.apache.maven.continuum.execution.maven.m2.MavenTwoBuildExecutor;
-import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.initialization.DefaultContinuumInitializer;
+import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectGroup;
import org.apache.maven.continuum.model.project.Schedule;
@@ -89,14 +89,13 @@
//
// ----------------------------------------------------------------------
- private void readModules( URL url, ContinuumProjectBuildingResult result, boolean groupPom, String username, String password )
+ private void readModules( URL url, ContinuumProjectBuildingResult result, boolean groupPom, String username,
+ String password )
{
MavenProject mavenProject;
try
{
- // TODO: this isn't finding parents due to relocating to the URL
- // TODO: the whole modules resolution is funky
mavenProject = builderHelper.getMavenProject( createMetadataFile( url, username, password ) );
}
catch ( MavenBuilderHelperException e )
@@ -126,7 +125,7 @@
{
String defaultGoal = "clean install";
- if (mavenProject.getBuild() != null && mavenProject.getBuild().getDefaultGoal() != null )
+ if ( mavenProject.getBuild() != null && mavenProject.getBuild().getDefaultGoal() != null )
{
defaultGoal = mavenProject.getBuild().getDefaultGoal();
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumBuildJob.java Tue May 16 03:26:59 2006
@@ -20,6 +20,7 @@
import org.apache.maven.continuum.ContinuumException;
import org.apache.maven.continuum.model.project.Schedule;
import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.scheduler.AbstractJob;
import org.quartz.InterruptableJob;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
@@ -30,13 +31,11 @@
* @version $Id$
*/
public class ContinuumBuildJob
- implements InterruptableJob
+ extends AbstractJob
{
- private boolean interrupted;
-
public void execute( JobExecutionContext context )
{
- if ( interrupted )
+ if ( isInterrupted() )
{
return;
}
@@ -51,7 +50,7 @@
// Get data map out of the job detail
// ----------------------------------------------------------------------
- Logger logger = (Logger) jobDetail.getJobDataMap().get( ContinuumSchedulerConstants.LOGGER );
+ Logger logger = (Logger) jobDetail.getJobDataMap().get( AbstractJob.LOGGER );
String jobName = jobDetail.getName();
@@ -80,11 +79,5 @@
catch( InterruptedException e )
{
}
- }
-
- public void interrupt()
- throws UnableToInterruptJobException
- {
- interrupted = true;
}
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumSchedulerConstants.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumSchedulerConstants.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumSchedulerConstants.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scheduler/ContinuumSchedulerConstants.java Tue May 16 03:26:59 2006
@@ -48,8 +48,6 @@
// Keys for JobDataMap
// ----------------------------------------------------------------------
- public static final String LOGGER = "logger";
-
public static final String CONTINUUM = "continuum";
public static final String SCHEDULE = "schedule";
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java Tue May 16 03:26:59 2006
@@ -39,8 +39,10 @@
import java.io.File;
import java.io.IOException;
import java.util.Date;
+import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
@@ -65,6 +67,11 @@
*/
private ContinuumStore store;
+ /**
+ * @plexus.configuration
+ */
+ private Properties updateProperties;
+
// ----------------------------------------------------------------------
// ContinuumScm implementation
// ----------------------------------------------------------------------
@@ -144,7 +151,9 @@
}
catch ( ScmRepositoryException e )
{
- throw new ContinuumScmException( "Cannot checkout sources.", e );
+ String message = getValidationMessages( e );
+
+ throw new ContinuumScmException( "Cannot checkout sources." + message, e );
}
catch ( ScmException e )
{
@@ -207,16 +216,32 @@
workingDirectory.getAbsolutePath() + ")." );
}
+ //Some SCM provider requires additional system properties during update
+ if ( updateProperties != null )
+ {
+ Enumeration propertyKeys = updateProperties.propertyNames();
+
+ while ( propertyKeys.hasMoreElements() )
+ {
+ String key = (String) propertyKeys.nextElement();
+
+ System.setProperty( key, updateProperties.getProperty( key ) );
+ }
+ }
+
ScmRepository repository = getScmRepositorty( project );
ScmResult result;
+ UpdateScmResult scmResult;
+
ScmFileSet fileSet = new ScmFileSet( workingDirectory );
synchronized ( this )
{
- result = convertScmResult(
- scmManager.getProviderByRepository( repository ).update( repository, fileSet, tag, getLatestUpdateDate( project ) ) );
+ scmResult = scmManager.getProviderByRepository( repository )
+ .update( repository, fileSet, tag, getLatestUpdateDate( project ) );
+ result = convertScmResult( scmResult );
}
if ( !result.isSuccess() )
@@ -229,18 +254,22 @@
getLogger().warn( "Provider message: " + result.getProviderMessage() );
}
- // TODO: total the number of files in the changesets
-// getLogger().info( "Updated " + result.getFiles().size() + " files." );
+ if ( scmResult.getUpdatedFiles() != null && scmResult.getUpdatedFiles().size() > 0 )
+ {
+ getLogger().info( "Updated " + scmResult.getUpdatedFiles().size() + " files." );
+ }
return result;
}
- catch ( ScmRepositoryException ex )
+ catch ( ScmRepositoryException e )
{
- throw new ContinuumScmException( "Error while update sources.", ex );
+ String message = getValidationMessages( e );
+
+ throw new ContinuumScmException( "Error while update sources." + message, e );
}
- catch ( ScmException ex )
+ catch ( ScmException e )
{
- throw new ContinuumScmException( "Error while update sources.", ex );
+ throw new ContinuumScmException( "Error while update sources.", e );
}
catch ( Exception e )
{
@@ -248,6 +277,27 @@
}
}
+ private String getValidationMessages( ScmRepositoryException ex )
+ {
+ List messages = ex.getValidationMessages();
+
+ StringBuffer message = new StringBuffer();
+
+ if ( !messages.isEmpty() )
+ {
+ for ( Iterator i = messages.iterator(); i.hasNext(); )
+ {
+ message.append( (String) i.next() );
+
+ if ( i.hasNext() )
+ {
+ message.append( System.getProperty( "line.separator" ) );
+ }
+ }
+ }
+ return message.toString();
+ }
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -270,15 +320,15 @@
private ScmRepository getScmRepositorty( Project project )
throws ScmRepositoryException, NoSuchScmProviderException
{
- ScmRepository repository = scmManager.makeScmRepository( project.getScmUrl() );
+ ScmRepository repository = scmManager.makeScmRepository( project.getScmUrl().trim() );
- if ( project.getScmUsername() != null )
+ repository.getProviderRepository().setPersistCheckout( true );
+
+ if ( !StringUtils.isEmpty( project.getScmUsername() ) )
{
repository.getProviderRepository().setUser( project.getScmUsername() );
- repository.getProviderRepository().setPersistCheckout( true );
-
- if ( project.getScmPassword() != null )
+ if ( !StringUtils.isEmpty( project.getScmPassword() ) )
{
repository.getProviderRepository().setPassword( project.getScmPassword() );
}
@@ -329,7 +379,7 @@
// TODO: revision?
- file.setStatus(scmFile.getStatus().toString());
+ file.setStatus( scmFile.getStatus().toString() );
changeSet.addFile( file );
}
@@ -349,14 +399,7 @@
result.setProviderMessage( scmResult.getProviderMessage() );
- // TODO: is this valid?
- ChangeSet changeSet = convertScmFileSetToChangeSet( scmResult.getUpdatedFiles() );
- if ( changeSet != null )
- {
- result.addChange( changeSet );
- }
-
- if ( scmResult.getChanges() != null )
+ if ( scmResult.getChanges() != null && !scmResult.getChanges().isEmpty() )
{
for ( Iterator it = scmResult.getChanges().iterator(); it.hasNext(); )
{
@@ -389,6 +432,18 @@
result.addChange( change );
}
}
+ else
+ {
+ //We don't have a changes information probably because provider doesn't have a changelog command
+ //so we use the updated list that contains only the updated files list
+ ChangeSet changeSet = convertScmFileSetToChangeSet( scmResult.getUpdatedFiles() );
+
+ if ( changeSet != null )
+ {
+ result.addChange( changeSet );
+ }
+
+ }
return result;
}
@@ -399,7 +454,7 @@
private String writeCommandLine( String commandLine )
{
String cmd = commandLine;
-
+
if ( cmd != null && cmd.startsWith( "svn" ) )
{
String pwdString = "--password";
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java?rev=406895&r1=406894&r2=406895&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java Tue May 16 03:26:59 2006
@@ -16,7 +16,11 @@
* limitations under the License.
*/
+import org.apache.maven.continuum.core.action.AbstractContinuumAction;
import org.apache.maven.continuum.core.action.CheckoutProjectContinuumAction;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.action.ActionManager;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.taskqueue.Task;
@@ -39,6 +43,11 @@
*/
private ActionManager actionManager;
+ /**
+ * @plexus.requirement
+ */
+ private ContinuumStore store;
+
// ----------------------------------------------------------------------
// TaskExecutor Implementation
// ----------------------------------------------------------------------
@@ -50,11 +59,26 @@
int projectId = task.getProjectId();
+ Project project;
+
+ try
+ {
+ project = store.getProjectWithBuildDetails( projectId );
+ }
+ catch ( ContinuumStoreException ex )
+ {
+ getLogger().error( "Internal error while getting the project.", ex );
+
+ return;
+ }
+
String workingDirectory = task.getWorkingDirectory().getAbsolutePath();
Map context = new HashMap();
context.put( CheckoutProjectContinuumAction.KEY_PROJECT_ID, new Integer( projectId ) );
+
+ context.put( CheckoutProjectContinuumAction.KEY_PROJECT, project );
context.put( CheckoutProjectContinuumAction.KEY_WORKING_DIRECTORY, workingDirectory );