Permalink
Browse files

add back in the changes made for flat multi-module support

(note: some parts needs to be reviewed and updated as necessary before merging to trunk)


git-svn-id: https://svn.apache.org/repos/asf/continuum/branches/continuum-flat-multi-module@943159 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 201887f commit cb4e1d01a605bd08f1d07d612c9d3e098aa01c58 @oching oching committed May 11, 2010
Showing with 2,088 additions and 363 deletions.
  1. +4 −2 continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
  2. +22 −3 continuum-api/src/main/java/org/apache/continuum/taskqueue/CheckOutTask.java
  3. +2 −1 continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
  4. +1 −1 continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
  5. +4 −2 continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java
  6. +12 −0 ...-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuildingResult.java
  7. +7 −0 continuum-api/src/main/java/org/apache/maven/continuum/utils/WorkingDirectoryService.java
  8. +3 −1 ...buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
  9. +33 −1 continuum-commons/pom.xml
  10. +17 −0 ...uum-commons/src/main/java/org/apache/maven/continuum/utils/ChrootJailWorkingDirectoryService.java
  11. +89 −5 continuum-commons/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java
  12. +174 −0 ...um-commons/src/test/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryServiceTest.java
  13. +7 −5 continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
  14. +154 −82 continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
  15. +53 −4 continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
  16. +80 −21 continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
  17. +4 −1 ...um-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
  18. +7 −2 continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckWorkingDirectoryAction.java
  19. +30 −4 ...uum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
  20. +6 −1 continuum-core/src/main/java/org/apache/maven/continuum/core/action/CleanWorkingDirectoryAction.java
  21. +27 −13 ...m-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
  22. +6 −2 ...nuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
  23. +4 −1 ...nuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
  24. +6 −3 ...java/org/apache/maven/continuum/core/action/UpdateProjectFromWorkingDirectoryContinuumAction.java
  25. +20 −5 ...ain/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
  26. +3 −3 continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
  27. +2 −2 ...inuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
  28. +4 −4 ...c/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
  29. +42 −13 ...c/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
  30. +5 −0 continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java
  31. +143 −49 ...uum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
  32. +8 −0 continuum-core/src/test-projects/flat-multi-module/.cvsignore
  33. +21 −2 continuum-core/src/test-projects/flat-multi-module/module-a/pom.xml
  34. +32 −0 ...src/test-projects/flat-multi-module/module-a/src/main/java/org/apache/continuum/module/a/App.java
  35. +57 −0 ...test-projects/flat-multi-module/module-a/src/test/java/org/apache/continuum/module/a/AppTest.java
  36. +20 −1 continuum-core/src/test-projects/flat-multi-module/module-b/pom.xml
  37. +32 −0 ...src/test-projects/flat-multi-module/module-b/src/main/java/org/apache/continuum/module/b/App.java
  38. +57 −0 ...test-projects/flat-multi-module/module-b/src/test/java/org/apache/continuum/module/b/AppTest.java
  39. +45 −0 continuum-core/src/test-projects/flat-multi-module/module-c/module-d/pom.xml
  40. +32 −0 ...projects/flat-multi-module/module-c/module-d/src/main/java/org/apache/continuum/module/d/App.java
  41. +57 −0 ...ects/flat-multi-module/module-c/module-d/src/test/java/org/apache/continuum/module/d/AppTest.java
  42. +20 −1 continuum-core/src/test-projects/flat-multi-module/parent-project/pom.xml
  43. +40 −0 continuum-core/src/test-projects/multi-module/module-C/module-D/pom.xml
  44. +32 −0 ...test-projects/multi-module/module-C/module-D/src/main/java/org/apache/continuum/module/c/App.java
  45. +57 −0 ...-projects/multi-module/module-C/module-D/src/test/java/org/apache/continuum/module/b/AppTest.java
  46. +1 −0 continuum-core/src/test-projects/multi-module/pom.xml
  47. +12 −12 continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
  48. +4 −4 continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueueTest.java
  49. +4 −4 continuum-core/src/test/java/org/apache/maven/continuum/AddMaven2ProjectTest.java
  50. +2 −2 continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java
  51. +134 −2 continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
  52. +11 −1 ...uum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
  53. +108 −30 ...uum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
  54. +2 −2 ...src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
  55. +2 −2 ...st/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java
  56. +45 −1 ...st/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
  57. +160 −16 ...core/src/test/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutorTest.java
  58. +6 −0 continuum-model/src/main/mdo/continuum.xml
  59. +7 −0 continuum-model/src/main/resources/package-default.orm
  60. +1 −1 ...nuum-release/src/main/java/org/apache/continuum/release/phase/AbstractContinuumRunGoalsPhase.java
  61. +51 −47 ...elease/src/main/java/org/apache/maven/continuum/release/executors/PerformReleaseTaskExecutor.java
  62. +2 −1 ...-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java
  63. +15 −0 continuum-release/src/main/resources/META-INF/plexus/components.xml
  64. +14 −0 continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
  65. +20 −1 continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
  66. +3 −1 continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java
  67. +1 −0 continuum-webapp/src/main/resources/localization/Continuum.properties
  68. +1 −0 continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp
  69. +1 −1 pom.xml
@@ -92,13 +92,15 @@ void prepareBuildProjects( Map<Integer, Integer> projectsBuildDefinitionsMap, Bu
* @param projectId
* @param projectName
* @param workingDirectory
+ * @param scmRootUrl TODO
* @param scmUsername
* @param scmPassword
* @param defaultBuildDefinition
+ * @param subProjects TODO
* @throws BuildManagerException
*/
- void checkoutProject( int projectId, String projectName, File workingDirectory, String scmUsername,
- String scmPassword, BuildDefinition defaultBuildDefinition )
+ void checkoutProject( int projectId, String projectName, File workingDirectory, String scmRootUrl,
+ String scmUsername, String scmPassword, BuildDefinition defaultBuildDefinition, List<Project> subProjects )
throws BuildManagerException;
/**
@@ -20,7 +20,9 @@
*/
import java.io.File;
+import java.util.List;
+import org.apache.maven.continuum.model.project.Project;
import org.codehaus.plexus.taskqueue.Task;
/**
@@ -39,9 +41,13 @@
private final String scmUserName;
private final String scmPassword;
-
+
+ private final String scmRootUrl;
+
+ private final List<Project> projectsWithCommonScmRoot;
+
public CheckOutTask( int projectId, File workingDirectory, String projectName, String scmUserName,
- String scmPassword )
+ String scmPassword, String scmRootUrl, List<Project> projectsWithCommonScmRoot )
{
this.projectId = projectId;
@@ -52,6 +58,10 @@ public CheckOutTask( int projectId, File workingDirectory, String projectName, S
this.scmUserName = scmUserName;
this.scmPassword = scmPassword;
+
+ this.scmRootUrl = scmRootUrl;
+
+ this.projectsWithCommonScmRoot = projectsWithCommonScmRoot;
}
public int getProjectId()
@@ -85,9 +95,18 @@ public String getScmPassword()
return scmPassword;
}
-
public int getHashCode()
{
return this.hashCode();
}
+
+ public String getScmRootUrl()
+ {
+ return scmRootUrl;
+ }
+
+ public List<Project> getProjectsWithCommonScmRoot()
+ {
+ return projectsWithCommonScmRoot;
+ }
}
@@ -322,13 +322,14 @@ public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, in
* @param useCredentialsCache whether to use cached scm account credentials or not
* @param loadRecursiveProjects if multi modules project record all projects (if false only root project added)
* @param buildDefintionTemplateId buildDefintionTemplateId
+ * @param checkoutInSingleDirectory TODO
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
boolean checkProtocol, boolean useCredentialsCache,
boolean loadRecursiveProjects,
- int buildDefintionTemplateId )
+ int buildDefintionTemplateId, boolean checkoutInSingleDirectory )
throws ContinuumException;
/**
@@ -55,7 +55,7 @@ void updateProjectFromCheckOut( File workingDirectory, Project project, BuildDef
throws ContinuumBuildExecutorException;
//TODO: Move as a plugin
- void backupTestFiles( Project project, int buildId );
+ void backupTestFiles( Project project, int buildId, String projectScmRootUrl, List<Project> projectsWithCommonScmRoot );
boolean shouldBuild( List<ChangeSet> changes, Project continuumProject, File workingDirectory,
BuildDefinition buildDefinition )
@@ -35,12 +35,14 @@ ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String userna
throws ContinuumProjectBuilderException;
ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
- boolean recursiveProjects )
+ boolean recursiveProjects,
+ boolean checkoutInSingleDirectory )
throws ContinuumProjectBuilderException;
ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
boolean recursiveProjects,
- BuildDefinitionTemplate buildDefinitionTemplate )
+ BuildDefinitionTemplate buildDefinitionTemplate,
+ boolean checkoutInSingleDirectory )
throws ContinuumProjectBuilderException;
BuildDefinitionTemplate getDefaultBuildDefinitionTemplate()
@@ -92,6 +92,8 @@
private final Map<String, String> errors = new HashMap<String, String>();
private static final String LS = System.getProperty( "line.separator" );
+
+ private Project rootProject;
public void addProject( Project project )
{
@@ -222,4 +224,14 @@ public String getErrorsAsString()
}
return message.toString();
}
+
+ public Project getRootProject()
+ {
+ return rootProject;
+ }
+
+ public void setRootProject( Project rootProject )
+ {
+ this.rootProject = rootProject;
+ }
}
@@ -22,6 +22,7 @@
import org.apache.maven.continuum.model.project.Project;
import java.io.File;
+import java.util.List;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -32,4 +33,10 @@
String ROLE = WorkingDirectoryService.class.getName();
File getWorkingDirectory( Project project );
+
+ File getWorkingDirectory( Project project, boolean shouldSet );
+
+ File getWorkingDirectory( Project project, String projectScmRootUrl, List<Project> projects );
+
+ File getWorkingDirectory( Project project, String projectScmRootUrl, List<Project> projects, boolean shouldSet );
}
@@ -998,7 +998,9 @@ private void processProject( String workingDirectory, String pomFilename, boolea
{
for ( Iterator modules = model.getModules().iterator(); modules.hasNext(); )
{
- processProject( workingDirectory + "/" + modules.next().toString(), "pom.xml", autoVersionSubmodules,
+ String module = StringUtils.replace( modules.next().toString(), '\\', '/' );
+
+ processProject( workingDirectory + "/" + module, "pom.xml", autoVersionSubmodules,
projects );
}
}
@@ -48,6 +48,10 @@ under the License.
<scope>runtime</scope>
</dependency>
<dependency>
+ <groupId>org.apache.maven.release</groupId>
+ <artifactId>maven-release-manager</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>
@@ -67,7 +71,35 @@ under the License.
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>runtime</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock-junit3</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- dependency of jmock3 -->
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- dependency of jmock3 -->
+ <dependency>
+ <groupId>org.objenesis</groupId>
+ <artifactId>objenesis</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock</artifactId>
+ <version>2.4.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jmock</groupId>
+ <artifactId>jmock</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
@@ -20,6 +20,8 @@
*/
import java.io.File;
+import java.util.List;
+
import javax.annotation.Resource;
import org.apache.maven.continuum.configuration.ConfigurationService;
@@ -65,10 +67,25 @@ public File getChrootJailDirectory()
public File getWorkingDirectory( Project project )
{
+ return getWorkingDirectory( project, true );
+ }
+
+ public File getWorkingDirectory( Project project, boolean shouldSet )
+ {
ProjectGroup projectGroup = project.getProjectGroup();
File f = new File( getChrootJailDirectory(), projectGroup.getGroupId() );
f = new File( f, getConfigurationService().getWorkingDirectory().getPath() );
return new File( f, Integer.toString( project.getId() ) );
}
+
+ public File getWorkingDirectory( Project project, String projectScmRoot, List<Project> projects )
+ {
+ return getWorkingDirectory( project, true );
+ }
+
+ public File getWorkingDirectory( Project project, String projectScmRoot, List<Project> projects, boolean shouldSet )
+ {
+ return getWorkingDirectory( project, shouldSet );
+ }
}
@@ -21,9 +21,11 @@
import org.apache.maven.continuum.configuration.ConfigurationService;
import org.apache.maven.continuum.model.project.Project;
+import org.codehaus.plexus.util.StringUtils;
import org.springframework.stereotype.Service;
import java.io.File;
+import java.util.List;
import javax.annotation.Resource;
@@ -54,19 +56,94 @@ public ConfigurationService getConfigurationService()
public File getWorkingDirectory( Project project )
{
+ return getWorkingDirectory( project, null, null );
+ }
+
+ public File getWorkingDirectory( Project project, boolean shouldSet )
+ {
+ return getWorkingDirectory( project, null, null, shouldSet );
+ }
+
+ /**
+ *
+ * @param project
+ * @param projectScmRoot
+ * @param projects projects under the same projectScmRoot
+ * @return
+ */
+ public File getWorkingDirectory( Project project, String projectScmRoot, List<Project> projects )
+ {
+ return getWorkingDirectory( project, projectScmRoot, projects, true );
+ }
+
+ /**
+ *
+ * @param project
+ * @param projectScmRoot
+ * @param projects projects under the same projectScmRoot
+ * @param shouldSet
+ * @return
+ */
+ public File getWorkingDirectory( Project project, String projectScmRoot, List<Project> projects, boolean shouldSet )
+ {
// TODO: Enable, this is what we really want
// ContinuumProjectGroup projectGroup = project.getProjectGroup();
//
// return new File( projectGroup.getWorkingDirectory(),
// project.getPath() );
- if ( project.getWorkingDirectory() == null )
+ String workingDirectory = project.getWorkingDirectory();
+
+ if ( project.getWorkingDirectory() == null || "".equals( project.getWorkingDirectory() ) )
+ {
+ if ( project.isCheckedOutInSingleDirectory() && projectScmRoot != null && !"".equals( projectScmRoot ) )
+ {
+ Project rootProject = project;
+ if( projects != null )
+ {
+ // the root project should have the lowest id since it's always added first
+ for( Project projectUnderScmRoot : projects )
+ {
+ if( projectUnderScmRoot.getId() < rootProject.getId() )
+ {
+ rootProject = projectUnderScmRoot;
+ }
+ }
+ }
+
+ // determine the path
+ String projectScmUrl = project.getScmUrl();
+ int indexDiff = StringUtils.differenceAt( projectScmUrl, projectScmRoot );
+
+ String pathToProject = "";
+ if( indexDiff != -1 )
+ {
+ pathToProject = projectScmUrl.substring( indexDiff );
+ }
+
+ if( pathToProject.startsWith( "\\" ) || pathToProject.startsWith( "/" ) )
+ {
+ workingDirectory = Integer.toString( rootProject.getId() ) + pathToProject;
+ }
+ else
+ {
+ workingDirectory = Integer.toString( rootProject.getId() ) + File.separatorChar + pathToProject;
+ }
+ }
+ else
+ {
+ workingDirectory = Integer.toString( project.getId() );
+ }
+ }
+
+ if ( shouldSet )
{
- project.setWorkingDirectory( Integer.toString( project.getId() ) );
+ project.setWorkingDirectory( workingDirectory );
}
File workDir;
- File projectWorkingDirectory = new File( project.getWorkingDirectory() );
+ File projectWorkingDirectory = new File( workingDirectory );
+
if ( projectWorkingDirectory.isAbsolute() )
{
// clean the project working directory path if it's a subdirectory of the global working directory
@@ -79,15 +156,22 @@ public File getWorkingDirectory( Project project )
{
pwd = pwd.substring( 1 );
}
- project.setWorkingDirectory( pwd );
+
+ if ( shouldSet )
+ {
+ project.setWorkingDirectory( pwd );
+ }
}
workDir = projectWorkingDirectory;
}
else
{
- workDir = new File( getConfigurationService().getWorkingDirectory(), project.getWorkingDirectory() );
+ File baseWorkingDir = getConfigurationService().getWorkingDirectory();
+
+ workDir = new File( baseWorkingDir, workingDirectory );
}
+
return workDir;
}
}
Oops, something went wrong. Retry.

0 comments on commit cb4e1d0

Please sign in to comment.