You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by oc...@apache.org on 2010/05/06 11:23:34 UTC
svn commit: r941625 [16/24] - in
/continuum/branches/continuum-flat-multi-module: ./ continuum-api/
continuum-api/src/main/java/org/apache/continuum/builder/distributed/
continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/
cont...
Modified: continuum/branches/continuum-flat-multi-module/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java Thu May 6 09:23:13 2010
@@ -27,8 +27,6 @@ import java.util.List;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.continuum.release.ContinuumReleaseException;
import org.apache.maven.profiles.DefaultProfileManager;
import org.apache.maven.profiles.ProfileManager;
@@ -119,7 +117,7 @@ public class GenerateReactorProjectsPhas
{
ArtifactRepository repository = getLocalRepository( descriptor.getAdditionalArguments() );
- project = projectBuilder.buildWithDependencies( getProjectDescriptorFile( descriptor ), repository,
+ project = projectBuilder.build( getProjectDescriptorFile( descriptor ), repository,
getProfileManager( getSettings() ) );
reactorProjects.add( project );
@@ -130,14 +128,6 @@ public class GenerateReactorProjectsPhas
{
throw new ContinuumReleaseException( "Failed to build project.", e );
}
- catch ( ArtifactNotFoundException e )
- {
- throw new ContinuumReleaseException( "Failed to build project.", e );
- }
- catch ( ArtifactResolutionException e )
- {
- throw new ContinuumReleaseException( "Failed to build project.", e );
- }
try
{
@@ -167,7 +157,7 @@ public class GenerateReactorProjectsPhas
try
{
MavenProject reactorProject =
- projectBuilder.buildWithDependencies( pomFile, repository, getProfileManager( getSettings() ) );
+ projectBuilder.build( pomFile, repository, getProfileManager( getSettings() ) );
reactorProjects.add( reactorProject );
@@ -177,14 +167,6 @@ public class GenerateReactorProjectsPhas
{
throw new ContinuumReleaseException( "Failed to build project.", e );
}
- catch ( ArtifactNotFoundException e )
- {
- throw new ContinuumReleaseException( "Failed to build project.", e );
- }
- catch ( ArtifactResolutionException e )
- {
- throw new ContinuumReleaseException( "Failed to build project.", e );
- }
}
}
@@ -205,49 +187,45 @@ public class GenerateReactorProjectsPhas
throws ContinuumReleaseException
{
String localRepository = null;
+ boolean found = false;
if ( arguments != null )
{
String[] args = arguments.split( " " );
-
- boolean shouldContinue = false;
-
+
for ( String arg : args )
{
if ( arg.contains( "-Dmaven.repo.local=" ) )
{
localRepository = arg.substring( arg.indexOf( "=" ) + 1 );
- if ( !localRepository.endsWith( "\"" ) )
- {
- shouldContinue = true;
- continue;
- }
- else
+ if ( localRepository.endsWith( "\"" ) )
{
+ localRepository = localRepository.substring( 0, localRepository.indexOf( "\"" ) );
break;
}
+
+ found = true;
+ continue;
}
- else if ( shouldContinue )
+
+ if ( found )
{
localRepository += " " + arg;
- if ( arg.endsWith( "\"" ) )
+ if ( localRepository.endsWith( "\"" ) )
{
+ localRepository = localRepository.substring( 0, localRepository.indexOf( "\"" ) );
break;
}
}
}
}
-
+
if ( localRepository == null )
{
localRepository = getSettings().getLocalRepository();
}
- else if ( localRepository.endsWith( "\"" ) )
- {
- localRepository = localRepository.substring( 0, localRepository.indexOf( "\"" ) );
- }
return new DefaultArtifactRepository( "local-repository", "file://" + localRepository,
new DefaultRepositoryLayout() );
Modified: continuum/branches/continuum-flat-multi-module/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/UpdateWorkingCopyPhase.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/UpdateWorkingCopyPhase.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/UpdateWorkingCopyPhase.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/UpdateWorkingCopyPhase.java Thu May 6 09:23:13 2010
@@ -22,6 +22,7 @@ package org.apache.maven.continuum.relea
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.command.update.UpdateScmResult;
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.provider.ScmProvider;
@@ -82,11 +83,26 @@ public class UpdateWorkingCopyPhase
throw new ReleaseExecutionException( "Unable to configure SCM repository: " + e.getMessage(), e );
}
- UpdateScmResult result;
+ UpdateScmResult updateScmResult = null;
+ CheckOutScmResult checkOutScmResult = null;
+
+ File workingDirectory = new File( releaseDescriptor.getWorkingDirectory() );
+
try
{
- result = provider.update( repository, new ScmFileSet( new File( releaseDescriptor.getWorkingDirectory() ) ),
- (ScmVersion) null );
+ if ( !workingDirectory.exists() )
+ {
+ workingDirectory.mkdirs();
+ }
+
+ if( workingDirectory.listFiles().length > 1 )
+ {
+ updateScmResult = provider.update( repository, new ScmFileSet( workingDirectory ), (ScmVersion) null );
+ }
+ else
+ {
+ checkOutScmResult = provider.checkOut( repository, new ScmFileSet( workingDirectory ) );
+ }
}
catch ( ScmException e )
{
@@ -94,13 +110,25 @@ public class UpdateWorkingCopyPhase
e );
}
- if ( !result.isSuccess() )
+ if ( updateScmResult != null )
{
- throw new ReleaseScmCommandException( "Unable to update current working copy", result );
+ if( !updateScmResult.isSuccess() )
+ {
+ throw new ReleaseScmCommandException( "Unable to update current working copy", updateScmResult );
+ }
+
+ copyUpdated = updateScmResult.getUpdatedFiles().size() > 0;
+ }
+ else
+ {
+ if( !checkOutScmResult.isSuccess() )
+ {
+ throw new ReleaseScmCommandException( "Unable to checkout project", checkOutScmResult );
+ }
+
+ copyUpdated = checkOutScmResult.getCheckedOutFiles().size() > 0;
}
- copyUpdated = ( result.getUpdatedFiles().size() > 0 );
-
relResult.setResultCode( ReleaseResult.SUCCESS );
return relResult;
Modified: continuum/branches/continuum-flat-multi-module/continuum-release/src/main/mdo/prepared-releases.mdo
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-release/src/main/mdo/prepared-releases.mdo?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-release/src/main/mdo/prepared-releases.mdo (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-release/src/main/mdo/prepared-releases.mdo Thu May 6 09:23:13 2010
@@ -29,11 +29,11 @@
<classes>
<class rootElement="true" xml.tagName="prepared-releases">
<name>PreparedReleaseModel</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<fields>
<field>
<name>preparedReleases</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<description></description>
<required>true</required>
<association>
@@ -45,29 +45,36 @@
</class>
<class>
<name>PreparedRelease</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<fields>
<field>
<name>releaseId</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<required>true</required>
<description>release id</description>
<type>String</type>
</field>
<field>
<name>releaseName</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<required>true</required>
<description>prepared release name</description>
<type>String</type>
</field>
<field>
<name>buildAgentUrl</name>
- <version>1.0.0</version>
+ <version>1.0.0+</version>
<required>true</required>
<description>build agent url</description>
<type>String</type>
</field>
+ <field>
+ <name>releaseType</name>
+ <version>1.4.0+</version>
+ <required>true</required>
+ <description>type of release. possible values are "prepare" or "perform"</description>
+ <type>String</type>
+ </field>
</fields>
</class>
</classes>
Modified: continuum/branches/continuum-flat-multi-module/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutorTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutorTest.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutorTest.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutorTest.java Thu May 6 09:23:13 2010
@@ -32,13 +32,22 @@ import org.apache.maven.scm.repository.S
import org.apache.maven.scm.repository.ScmRepositoryException;
import org.apache.maven.shared.release.ReleaseResult;
import org.apache.maven.shared.release.config.ReleaseDescriptor;
+import org.apache.maven.shared.release.config.ReleaseDescriptorStoreException;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import org.codehaus.plexus.taskqueue.Task;
import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Properties;
/**
* @author Edwin Punzalan
@@ -89,7 +98,7 @@ public class ReleaseTaskExecutorTest
File scmTargetPath = new File( getBasedir(), "target/scm-test" ).getAbsoluteFile();
FileUtils.copyDirectoryStructure( scmPath, scmTargetPath );
}
-
+
public void releaseSimpleProject()
throws Exception
{
@@ -130,6 +139,8 @@ public class ReleaseTaskExecutorTest
releaseSimpleProject();
releaseAndRollbackProject();
releaseSimpleProjectWithNextVersion();
+ releasePerformWithExecutableInDescriptor();
+ releaseProjectWithDependencyOfCustomPackagingType();
}
public void releaseSimpleProjectWithNextVersion()
@@ -222,6 +233,119 @@ public class ReleaseTaskExecutorTest
//@todo when implemented already, check if tag was also removed
}
+ public void releasePerformWithExecutableInDescriptor()
+ throws Exception
+ {
+ String scmPath = new File( getBasedir(), "target/scm-test" ).getAbsolutePath().replace( '\\', '/' );
+ File workDir = new File( getBasedir(), "target/test-classes/work-dir" );
+ FileUtils.deleteDirectory( workDir );
+ File testDir = new File( getBasedir(), "target/test-classes/test-dir" );
+ FileUtils.deleteDirectory( testDir );
+
+ ContinuumReleaseDescriptor descriptor = new ContinuumReleaseDescriptor();
+ descriptor.setInteractive( false );
+ descriptor.setScmSourceUrl( "scm:svn:file://localhost/" + scmPath + "/trunk" );
+ descriptor.setWorkingDirectory( workDir.getAbsolutePath() );
+
+ ScmRepository repository = getScmRepositorty( descriptor.getScmSourceUrl() );
+ ScmFileSet fileSet = new ScmFileSet( workDir );
+ scmManager.getProviderByRepository( repository ).checkOut( repository, fileSet, (ScmVersion) null );
+
+ String pom = FileUtils.fileRead( new File( workDir, "pom.xml" ) );
+ assertTrue( "Test dev version", pom.indexOf( "<version>2.1-SNAPSHOT</version>" ) > 0 );
+
+ doPrepareWithNoError( descriptor );
+
+ pom = FileUtils.fileRead( new File( workDir, "pom.xml" ) );
+ assertTrue( "Test version increment", pom.indexOf( "<version>2.2-SNAPSHOT</version>" ) > 0 );
+
+ repository = getScmRepositorty( "scm:svn:file://localhost/" + scmPath + "/tags/test-artifact-2.1" );
+ fileSet = new ScmFileSet( testDir );
+ scmManager.getProviderByRepository( repository ).checkOut( repository, fileSet, (ScmVersion) null );
+
+ pom = FileUtils.fileRead( new File( testDir, "pom.xml" ) );
+ assertTrue( "Test released version", pom.indexOf( "<version>2.1</version>" ) > 0 );
+
+ File file = new File( descriptor.getWorkingDirectory(), "release.properties" );
+ assertTrue( "release.properties file does not exist", file.exists() );
+
+ Properties properties = new Properties();
+
+ InputStream inStream = null;
+ OutputStream outStream = null;
+
+ try
+ {
+ inStream = new FileInputStream( file );
+
+ properties.load( inStream );
+
+ properties.setProperty( "build.executable", "test/executable/mvn" );
+
+ outStream = new FileOutputStream( file );
+
+ properties.store( outStream, "release configuration" );
+ }
+ finally
+ {
+ IOUtil.close( inStream );
+ }
+
+ performExec.executeTask(
+ getPerformTask( "testRelease", descriptor, new File( getBasedir(), "target/test-classes/build-dir" ) ) );
+
+ ReleaseResult result = (ReleaseResult) releaseManager.getReleaseResults().get( "testRelease" );
+
+ if ( !result.getOutput().replace( "\\", "/" ).contains( "test/executable/mvn" ) )
+ {
+ fail( "Error in release:perform. Missing executable" );
+ }
+ }
+
+ // CONTINUUM-1814
+ public void releaseProjectWithDependencyOfCustomPackagingType()
+ throws Exception
+ {
+ String scmPath = new File( getBasedir(), "target/scm-test/continuum-1814" ).getAbsolutePath().replace( '\\', '/' );
+ File workDir = new File( getBasedir(), "target/test-classes/continuum-1814" );
+ FileUtils.deleteDirectory( workDir );
+ File testDir = new File( getBasedir(), "target/test-classes/test-dir" );
+ FileUtils.deleteDirectory( testDir );
+
+ ContinuumReleaseDescriptor descriptor = new ContinuumReleaseDescriptor();
+ descriptor.setInteractive( false );
+ descriptor.setScmSourceUrl( "scm:svn:file://localhost/" + scmPath + "/trunk" );
+ descriptor.setWorkingDirectory( workDir.getAbsolutePath() );
+
+ ScmRepository repository = getScmRepositorty( descriptor.getScmSourceUrl() );
+ ScmFileSet fileSet = new ScmFileSet( workDir );
+ scmManager.getProviderByRepository( repository ).checkOut( repository, fileSet, (ScmVersion) null );
+
+ String pom = FileUtils.fileRead( new File( workDir, "pom.xml" ) );
+ assertTrue( "Test dev version", pom.indexOf( "<version>1.6-SNAPSHOT</version>" ) > 0 );
+
+ doPrepareWithNoError( descriptor );
+
+ pom = FileUtils.fileRead( new File( workDir, "pom.xml" ) );
+ assertTrue( "Test version increment", pom.indexOf( "<version>1.7-SNAPSHOT</version>" ) > 0 );
+
+ repository = getScmRepositorty( "scm:svn:file://localhost/" + scmPath + "/tags/continuum-1814-1.6" );
+ fileSet = new ScmFileSet( testDir );
+ scmManager.getProviderByRepository( repository ).checkOut( repository, fileSet, (ScmVersion) null );
+
+ pom = FileUtils.fileRead( new File( testDir, "pom.xml" ) );
+ assertTrue( "Test released version", pom.indexOf( "<version>1.6</version>" ) > 0 );
+
+ performExec.executeTask(
+ getPerformTask( "testRelease", descriptor, new File( getBasedir(), "target/test-classes/build-dir" ) ) );
+
+ ReleaseResult result = (ReleaseResult) releaseManager.getReleaseResults().get( "testRelease" );
+ if ( result.getResultCode() != ReleaseResult.SUCCESS )
+ {
+ fail( "Error in release:perform. Release output follows:\n" + result.getOutput() );
+ }
+ }
+
private void doPrepareWithNoError( ReleaseDescriptor descriptor )
throws TaskExecutionException
{
Modified: continuum/branches/continuum-flat-multi-module/continuum-release/src/test/scm/db/current
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-release/src/test/scm/db/current?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-release/src/test/scm/db/current (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-release/src/test/scm/db/current Thu May 6 09:23:13 2010
@@ -1 +1 @@
-2 5 1
+5 i 1
Modified: continuum/branches/continuum-flat-multi-module/continuum-reports/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-reports/pom.xml?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-reports/pom.xml (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-reports/pom.xml Thu May 6 09:23:13 2010
@@ -22,7 +22,7 @@ under the License.
<parent>
<artifactId>continuum</artifactId>
<groupId>org.apache.continuum</groupId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
</parent>
<artifactId>continuum-reports</artifactId>
<name>Continuum :: Reports</name>
@@ -46,10 +46,6 @@ under the License.
<artifactId>continuum-api</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.continuum</groupId>
- <artifactId>continuum-api</artifactId>
- </dependency>
- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
Modified: continuum/branches/continuum-flat-multi-module/continuum-security/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-security/pom.xml?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-security/pom.xml (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-security/pom.xml Thu May 6 09:23:13 2010
@@ -21,7 +21,7 @@ under the License.
<parent>
<artifactId>continuum</artifactId>
<groupId>org.apache.continuum</groupId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>continuum-security</artifactId>
Modified: continuum/branches/continuum-flat-multi-module/continuum-store/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-store/pom.xml?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-store/pom.xml (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-store/pom.xml Thu May 6 09:23:13 2010
@@ -21,7 +21,7 @@ under the License.
<parent>
<artifactId>continuum</artifactId>
<groupId>org.apache.continuum</groupId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.4.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>continuum-store</artifactId>
Modified: continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java Thu May 6 09:23:13 2010
@@ -19,21 +19,21 @@ package org.apache.continuum.dao;
* under the License.
*/
-import org.apache.maven.continuum.model.project.BuildResult;
-import org.apache.maven.continuum.model.project.Project;
-import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.springframework.stereotype.Repository;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.jdo.Extent;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.springframework.stereotype.Repository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -71,6 +71,7 @@ public class BuildResultDaoImpl
project.setState( build.getState() );
+ //TODO: Use projectDao
pm.makePersistent( project );
tx.commit();
@@ -142,7 +143,45 @@ public class BuildResultDaoImpl
if ( result != null && !result.isEmpty() )
{
- return (BuildResult) result.get( 0 );
+ return result.get( 0 );
+ }
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ return null;
+ }
+
+ public BuildResult getLatestBuildResultForProjectWithDetails( int projectId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ pm.getFetchPlan().addGroup( BUILD_RESULT_WITH_DETAILS_FETCH_GROUP );
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int projectId" );
+
+ query.setFilter( "this.project.id == projectId && this.project.latestBuildId == this.id" );
+
+ List<BuildResult> result = (List<BuildResult>) query.execute( projectId );
+
+ result = (List<BuildResult>) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ if ( result != null && !result.isEmpty() )
+ {
+ return result.get( 0 );
}
}
finally
@@ -183,7 +222,7 @@ public class BuildResultDaoImpl
if ( result != null && !result.isEmpty() )
{
- return (BuildResult) result.get( 0 );
+ return result.get( 0 );
}
}
finally
@@ -251,11 +290,6 @@ public class BuildResultDaoImpl
return null;
}
- public Map<Integer, BuildResult> getLatestBuildResults()
- {
- return getLatestBuildResultsByProjectGroupId( -1 );
- }
-
public void removeBuildResult( BuildResult buildResult )
{
removeObject( buildResult );
@@ -278,9 +312,9 @@ public class BuildResultDaoImpl
query.declareParameters( "Integer projectId" );
- List result = (List) query.execute( projectId );
+ List<BuildResult> result = (List<BuildResult>) query.execute( projectId );
- result = (List) pm.detachCopyAll( result );
+ result = (List<BuildResult>) pm.detachCopyAll( result );
tx.commit();
@@ -316,9 +350,9 @@ public class BuildResultDaoImpl
query.setFilter( "this.project.id == projectId && this.buildNumber == buildNumber" );
- List result = (List) query.execute( projectId, buildNumber );
+ List<BuildResult> result = (List<BuildResult>) query.execute( projectId, buildNumber );
- result = (List) pm.detachCopyAll( result );
+ result = (List<BuildResult>) pm.detachCopyAll( result );
tx.commit();
@@ -403,9 +437,93 @@ public class BuildResultDaoImpl
}
}
+ public long getNbBuildResultsInSuccessForProject( int projectId, long fromDate )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int projectId, long fromDate, int state" );
+
+ query.setFilter( "this.project.id == projectId && this.startTime > fromDate && this.state == state" );
+
+ query.setResult( "count(this)" );
+
+ long result = (Long) query.execute( projectId, fromDate, ContinuumProjectState.OK );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public List<BuildResult> getBuildResultsForProjectWithDetails( int projectId, long fromDate, int tobuildResultId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+ pm.getFetchPlan().addGroup( BUILD_RESULT_WITH_DETAILS_FETCH_GROUP );
+
+ Query query = pm.newQuery( extent );
+
+ String parameters = "int projectId, long fromDate";
+ String filter = "this.project.id == projectId && this.startTime > fromDate";
+
+ if ( tobuildResultId > 0 )
+ {
+ parameters += ", int buildResultId";
+ filter += " && this.id < buildResultId";
+ }
+ query.declareParameters( parameters );
+
+ query.setFilter( filter );
+
+ query.setOrdering( "this.id descending" );
+
+ List<BuildResult> result;
+
+ if ( tobuildResultId > 0 )
+ {
+ result = (List<BuildResult>) query.execute( projectId, fromDate, tobuildResultId );
+ }
+ else
+ {
+ result = (List<BuildResult>) query.execute( projectId, fromDate );
+ }
+
+ result = (List<BuildResult>) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
public List<BuildResult> getBuildResultsForProject( int projectId )
{
- return getBuildResultsForProject( projectId, -1, -1 );
+ return getBuildResultsForProjectWithDetails( projectId, -1, -1 );
}
public List<BuildResult> getBuildResultsForProject( int projectId, long startIndex, long endIndex )
@@ -413,7 +531,7 @@ public class BuildResultDaoImpl
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
-
+
try
{
tx.begin();
@@ -433,9 +551,9 @@ public class BuildResultDaoImpl
query.setRange( startIndex, endIndex );
}
- List result = (List) query.execute( projectId );
+ List<BuildResult> result = (List<BuildResult>) query.execute( projectId );
- result = (List) pm.detachCopyAll( result );
+ result = (List<BuildResult>) pm.detachCopyAll( result );
tx.commit();
@@ -446,7 +564,7 @@ public class BuildResultDaoImpl
rollback( tx );
}
}
-
+
public List<BuildResult> getBuildResultsForProjectFromId( int projectId, long startId )
throws ContinuumStoreException
{
@@ -455,7 +573,7 @@ public class BuildResultDaoImpl
Transaction tx = pm.currentTransaction();
pm.getFetchPlan().addGroup( BUILD_RESULT_WITH_DETAILS_FETCH_GROUP );
-
+
try
{
tx.begin();
@@ -465,14 +583,14 @@ public class BuildResultDaoImpl
Query query = pm.newQuery( extent );
query.declareParameters( "int projectId, int buildNumber" );
-
+
query.setFilter( "this.project.id == projectId && this.buildNumber >= buildNumber" );
-
+
query.setOrdering( "this.startTime descending" );
- List result = (List) query.execute( projectId, startId );
+ List<BuildResult> result = (List<BuildResult>) query.execute( projectId, startId );
- result = (List) pm.detachCopyAll( result );
+ result = (List<BuildResult>) pm.detachCopyAll( result );
tx.commit();
@@ -488,14 +606,12 @@ public class BuildResultDaoImpl
}
}
- public List<BuildResult> getBuildResultsForProject( int projectId, long fromDate )
+ public BuildResult getLatestBuildResultInSuccess( int projectId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
- pm.getFetchPlan().addGroup( BUILD_RESULT_WITH_DETAILS_FETCH_GROUP );
-
try
{
tx.begin();
@@ -504,13 +620,17 @@ public class BuildResultDaoImpl
Query query = pm.newQuery( extent );
- query.declareParameters( "int projectId, long fromDate" );
+ query.declareParameters( "int projectId" );
+
+ String filter = "this.project.buildNumber == this.buildNumber && this.project.id == projectId";
+
+ query.setFilter( filter );
- query.setFilter( "this.project.id == projectId && this.startTime > fromDate" );
+ query.setUnique( true );
- List result = (List) query.execute( projectId, fromDate );
+ BuildResult result = (BuildResult) query.execute( projectId );
- result = (List) pm.detachCopyAll( result );
+ result = (BuildResult) pm.detachCopy( result );
tx.commit();
@@ -522,23 +642,52 @@ public class BuildResultDaoImpl
}
}
- public List<BuildResult> getBuildResultsInSuccessForProject( int projectId, long fromDate )
+ private int getPreviousBuildResultIdInSuccess( int projectId, int buildResultId )
{
- List<BuildResult> buildResults = getBuildResultsForProject( projectId, fromDate );
+ PersistenceManager pm = getPersistenceManager();
- List<BuildResult> results = new ArrayList<BuildResult>();
+ Transaction tx = pm.currentTransaction();
- if ( buildResults != null )
+ try
{
- for ( BuildResult res : buildResults )
- {
- if ( res.getState() == ContinuumProjectState.OK )
- {
- results.add( res );
- }
- }
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int projectId, int buildResultId" );
+
+ String filter = "this.id < buildResultId && this.state == " + ContinuumProjectState.OK +
+ " && this.project.id == projectId";
+
+ query.setFilter( filter );
+
+ query.setResult( "max(this.id)" );
+
+ int result = (Integer) query.execute( projectId, buildResultId );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public BuildResult getPreviousBuildResultInSuccess( int projectId, int buildResultId )
+ throws ContinuumStoreException
+ {
+ try
+ {
+ return getBuildResult( getPreviousBuildResultIdInSuccess( projectId, buildResultId ) );
+ }
+ catch ( NullPointerException e )
+ {
+ return null;
}
- return results;
}
public Map<Integer, BuildResult> getBuildResultsInSuccessByProjectGroupId( int projectGroupId )
@@ -599,10 +748,4 @@ public class BuildResultDaoImpl
return null;
}
-
- public Map<Integer, BuildResult> getBuildResultsInSuccess()
- {
- return getBuildResultsInSuccessByProjectGroupId( -1 );
- }
-
}
Modified: continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java Thu May 6 09:23:13 2010
@@ -119,10 +119,6 @@ public class DaoUtilsImpl
{
pmf.close();
}
- catch ( SecurityException e )
- {
- throw e;
- }
catch ( JDOUserException e )
{
if ( numTry < 5 )
@@ -176,9 +172,8 @@ public class DaoUtilsImpl
// might define their own build definitions
if ( projectGroupSource != null )
{
- for ( Iterator i = projectGroupSource.keySet().iterator(); i.hasNext(); )
+ for ( Integer projectGroupId : projectGroupSource.keySet() )
{
- Integer projectGroupId = (Integer) i.next();
List<Project> projectsInGroup = projectDao.getProjectsInGroup( projectGroupId );
for ( Project p : projectsInGroup )
Modified: continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/DirectoryPurgeConfigurationDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/DirectoryPurgeConfigurationDaoImpl.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/DirectoryPurgeConfigurationDaoImpl.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/DirectoryPurgeConfigurationDaoImpl.java Thu May 6 09:23:13 2010
@@ -74,6 +74,36 @@ public class DirectoryPurgeConfiguration
rollback( tx );
}
}
+
+ public List<DirectoryPurgeConfiguration> getEnableDirectoryPurgeConfigurationsBySchedule( int scheduleId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int scheduleId" );
+
+ query.setFilter( "this.schedule.id == scheduleId && this.enabled == true" );
+
+ List result = (List) query.execute( scheduleId );
+
+ return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+ }
+ finally
+ {
+ tx.commit();
+
+ rollback( tx );
+ }
+ }
public List<DirectoryPurgeConfiguration> getDirectoryPurgeConfigurationsByLocation( String location )
{
Modified: continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/InstallationDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/InstallationDaoImpl.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/InstallationDaoImpl.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/InstallationDaoImpl.java Thu May 6 09:23:13 2010
@@ -19,20 +19,20 @@ package org.apache.continuum.dao;
* under the License.
*/
-import org.apache.maven.continuum.model.system.Installation;
-import org.apache.maven.continuum.model.system.Profile;
-import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.codehaus.plexus.util.StringUtils;
-import org.springframework.stereotype.Repository;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
+
+import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.model.system.Profile;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.util.StringUtils;
+import org.springframework.stereotype.Repository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -85,9 +85,8 @@ public class InstallationDaoImpl
if ( result.size() != 0 )
{
- for ( Iterator<Profile> iterator = result.iterator(); iterator.hasNext(); )
+ for ( Profile profile : result )
{
- Profile profile = iterator.next();
profile.setJdk( null );
pm.makePersistent( profile );
}
@@ -106,9 +105,8 @@ public class InstallationDaoImpl
if ( result.size() != 0 )
{
- for ( Iterator<Profile> iterator = result.iterator(); iterator.hasNext(); )
+ for ( Profile profile : result )
{
- Profile profile = iterator.next();
profile.setBuilder( null );
pm.makePersistent( profile );
}
Modified: continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java Thu May 6 09:23:13 2010
@@ -19,19 +19,23 @@ package org.apache.continuum.dao;
* under the License.
*/
-import org.apache.maven.continuum.model.project.Project;
-import org.apache.maven.continuum.model.project.ProjectGroup;
-import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
-import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.springframework.stereotype.Repository;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+
+import org.apache.continuum.model.project.ProjectGroupSummary;
+import org.apache.continuum.model.project.ProjectSummaryResult;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.springframework.stereotype.Repository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -149,22 +153,33 @@ public class ProjectDaoImpl
}
}
- // todo get this natively supported in the store
public List<Project> getProjectsWithDependenciesByGroupId( int projectGroupId )
{
- List<Project> allProjects =
- getAllObjectsDetached( Project.class, "name ascending", PROJECT_DEPENDENCIES_FETCH_GROUP );
+ PersistenceManager pm = getPersistenceManager();
- List<Project> groupProjects = new ArrayList<Project>();
+ Transaction tx = pm.currentTransaction();
- for ( Project project : allProjects )
+ try
{
- if ( project.getProjectGroup().getId() == projectGroupId )
- {
- groupProjects.add( project );
- }
+ tx.begin();
+
+ Extent extent = pm.getExtent( Project.class, true );
+
+ Query query = pm.newQuery( extent, "projectGroup.id == " + projectGroupId );
+
+ pm.getFetchPlan().addGroup( PROJECT_DEPENDENCIES_FETCH_GROUP );
+ List<Project> result = (List<Project>) query.execute();
+
+ result = (List<Project>) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
}
- return groupProjects;
}
public Project getProjectWithBuilds( int projectId )
@@ -202,9 +217,9 @@ public class ProjectDaoImpl
query.setOrdering( "name ascending" );
- List result = (List) query.execute();
+ List<Project> result = (List<Project>) query.execute();
- result = (List) pm.detachCopyAll( result );
+ result = (List<Project>) pm.detachCopyAll( result );
tx.commit();
@@ -237,9 +252,9 @@ public class ProjectDaoImpl
pm.getFetchPlan().addGroup( PROJECTGROUP_PROJECTS_FETCH_GROUP );
- List result = (List) query.execute();
+ List<Project> result = (List<Project>) query.execute();
- result = (List) pm.detachCopyAll( result );
+ result = (List<Project>) pm.detachCopyAll( result );
tx.commit();
@@ -251,12 +266,6 @@ public class ProjectDaoImpl
}
}
-
- public List<Project> getAllProjectsWithAllDetails()
- {
- return getAllObjectsDetached( Project.class, "name ascending", PROJECT_ALL_DETAILS_FETCH_GROUP );
- }
-
public Project getProjectWithAllDetails( int projectId )
throws ContinuumStoreException
{
@@ -299,4 +308,78 @@ public class ProjectDaoImpl
{
return (Project) getObjectById( Project.class, projectId, PROJECT_DEPENDENCIES_FETCH_GROUP );
}
+
+ public Map<Integer, ProjectGroupSummary> getProjectsSummary()
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( Project.class );
+
+ Query query = pm.newQuery( extent );
+
+ query.setResult( "projectGroup.id as projectGroupId, state as projectState, count(state) as size" );
+
+ query.setResultClass( ProjectSummaryResult.class );
+
+ query.setGrouping( "projectGroup.id, state" );
+
+ List<ProjectSummaryResult> results = (List<ProjectSummaryResult>) query.execute();
+
+ Map<Integer, ProjectGroupSummary> summaries = processProjectGroupSummary( results );
+
+ tx.commit();
+
+ return summaries;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ private Map<Integer, ProjectGroupSummary> processProjectGroupSummary( List<ProjectSummaryResult> results )
+ {
+ Map<Integer, ProjectGroupSummary> map = new HashMap<Integer, ProjectGroupSummary>();
+
+ for ( ProjectSummaryResult result : results )
+ {
+ ProjectGroupSummary summary;
+ int projectGroupId = result.getProjectGroupId();
+ int size = new Long( result.getSize() ).intValue();
+ int state = result.getProjectState();
+
+ if ( map.containsKey( projectGroupId ) )
+ {
+ summary = map.get( projectGroupId );
+ }
+ else
+ {
+ summary = new ProjectGroupSummary( projectGroupId );
+ }
+
+ summary.addProjects( size );
+
+ if ( state == 2 )
+ {
+ summary.addNumberOfSuccesses( size );
+ }
+ else if ( state == 3 )
+ {
+ summary.addNumberOfFailures( size );
+ }
+ else if ( state == 4 )
+ {
+ summary.addNumberOfErrors( size );
+ }
+
+ map.put( projectGroupId, summary );
+ }
+ return map;
+ }
}
Modified: continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/RepositoryPurgeConfigurationDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/RepositoryPurgeConfigurationDaoImpl.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/RepositoryPurgeConfigurationDaoImpl.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-store/src/main/java/org/apache/continuum/dao/RepositoryPurgeConfigurationDaoImpl.java Thu May 6 09:23:13 2010
@@ -75,6 +75,36 @@ public class RepositoryPurgeConfiguratio
rollback( tx );
}
}
+
+ public List<RepositoryPurgeConfiguration> getEnableRepositoryPurgeConfigurationsBySchedule( int scheduleId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( RepositoryPurgeConfiguration.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int scheduleId" );
+
+ query.setFilter( "this.schedule.id == scheduleId && this.enabled == true" );
+
+ List result = (List) query.execute( scheduleId );
+
+ return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+ }
+ finally
+ {
+ tx.commit();
+
+ rollback( tx );
+ }
+ }
public List<RepositoryPurgeConfiguration> getRepositoryPurgeConfigurationsByLocalRepository( int repositoryId )
{
Modified: continuum/branches/continuum-flat-multi-module/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-flat-multi-module/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java?rev=941625&r1=941624&r2=941625&view=diff
==============================================================================
--- continuum/branches/continuum-flat-multi-module/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java (original)
+++ continuum/branches/continuum-flat-multi-module/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java Thu May 6 09:23:13 2010
@@ -1204,9 +1204,9 @@ public abstract class AbstractContinuumS
.getVersion(), project.getWorkingDirectory() );
}
- private static Project createTestProject( String artifactId, int buildNumber, String description, String groupId,
- String name, String scmUrl, int state, String url, String version,
- String workingDirectory )
+ protected static Project createTestProject( String artifactId, int buildNumber, String description, String groupId,
+ String name, String scmUrl, int state, String url, String version,
+ String workingDirectory )
{
Project project = new Project();
project.setArtifactId( artifactId );