maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r688259 - in /maven/components/branches/maven-2.0.10-RC: ./ maven-core/src/main/java/org/apache/maven/lifecycle/ maven-project/src/test/java/org/apache/maven/project/ maven-project/src/test/resources/project-dynamism/
Date Sat, 23 Aug 2008 04:07:12 GMT
Author: jdcasey
Date: Fri Aug 22 21:07:12 2008
New Revision: 688259

URL: http://svn.apache.org/viewvc?rev=688259&view=rev
Log:
[MNG-3724] make execution-project instances short lived, to remove problems of syncing compile/test-compile/script
source roots added to the corresponding main project.

Added:
    maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-source-roots.xml
Modified:
    maven/components/branches/maven-2.0.10-RC/   (props changed)
    maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java

Propchange: maven/components/branches/maven-2.0.10-RC/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Aug 22 21:07:12 2008
@@ -1,4 +1,4 @@
-bootstrap`
+bootstrap
 release.properties
 maven.log
 target

Modified: maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=688259&r1=688258&r2=688259&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
(original)
+++ maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
Fri Aug 22 21:07:12 2008
@@ -711,20 +711,20 @@
                 throw new LifecycleExecutionException( e.getMessage(), e );
             }
             
-//            if ( hasFork )
-//            {
-//                project.setExecutionProject( null );
-//                
-//                if ( usesReactorProjects )
-//                {
-//                    List reactorProjects = session.getSortedProjects();
-//                    for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
-//                    {
-//                        MavenProject reactorProject = (MavenProject) it.next();
-//                        reactorProject.setExecutionProject( null );
-//                    }
-//                }
-//            }
+            if ( hasFork )
+            {
+                project.setExecutionProject( null );
+                
+                if ( usesReactorProjects )
+                {
+                    List reactorProjects = session.getSortedProjects();
+                    for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+                    {
+                        MavenProject reactorProject = (MavenProject) it.next();
+                        reactorProject.setExecutionProject( null );
+                    }
+                }
+            }
             
 //            if ( usesReactorProjects )
 //            {

Modified: maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java?rev=688259&r1=688258&r2=688259&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java
(original)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java
Fri Aug 22 21:07:12 2008
@@ -90,7 +90,7 @@
                 + " should have a an interpolated POM groupId as its value.", children[i].getValue(),
                           project.getGroupId() );
         }
-        
+
         project.getProperties().setProperty( "foo", "bar" );
 
         projectBuilder.restoreDynamicState( project, new DefaultProjectBuilderConfiguration()
);
@@ -221,7 +221,7 @@
 
         assertEquals( "Concrete build directory should be absolute.", new File( baseDir,
"target" ).getAbsolutePath(),
                       new File( build.getDirectory() ).getAbsolutePath() );
-        
+
         // Next, we have to change something to ensure the project is restored to its dynamic
state.
         project.getProperties().setProperty( "restoreTrigger", "true" );
 
@@ -483,52 +483,108 @@
         throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException,
         ModelInterpolationException
     {
-        // TODO: Make this run!
         MavenProject project = buildProject( "pom-plugins.xml" );
 
         String firstPlugin = "one:first-maven-plugin";
         String secondPlugin = "two:second-maven-plugin";
         String thirdPlugin = "three:third-maven-plugin";
-        
+
         project.getBuild().flushPluginMap();
         Map pluginMap = project.getBuild().getPluginsAsMap();
-        
-        assertNotNull( "Before calculating concrete state, project should contain plugin:
" + firstPlugin, pluginMap.get( firstPlugin ) );
-        assertNotNull( "Before calculating concrete state, project should contain plugin:
" + secondPlugin, pluginMap.get( secondPlugin ) );
-        assertNull( "Before calculating concrete state, project should NOT contain plugin:
" + thirdPlugin, pluginMap.get( thirdPlugin ) );
+
+        assertNotNull( "Before calculating concrete state, project should contain plugin:
" + firstPlugin,
+                       pluginMap.get( firstPlugin ) );
+        assertNotNull( "Before calculating concrete state, project should contain plugin:
" + secondPlugin,
+                       pluginMap.get( secondPlugin ) );
+        assertNull( "Before calculating concrete state, project should NOT contain plugin:
" + thirdPlugin,
+                    pluginMap.get( thirdPlugin ) );
 
         ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
         projectBuilder.calculateConcreteState( project, config );
-        
+
         project.getBuild().flushPluginMap();
         pluginMap = project.getBuild().getPluginsAsMap();
-        
-        assertNotNull( "After calculating concrete state, project should contain plugin:
" + firstPlugin, pluginMap.get( firstPlugin ) );
-        assertNotNull( "After calculating concrete state, project should contain plugin:
" + secondPlugin, pluginMap.get( secondPlugin ) );
-        assertNull( "After calculating concrete state, project should NOT contain plugin:
" + thirdPlugin, pluginMap.get( thirdPlugin ) );
-        
+
+        assertNotNull( "After calculating concrete state, project should contain plugin:
" + firstPlugin,
+                       pluginMap.get( firstPlugin ) );
+        assertNotNull( "After calculating concrete state, project should contain plugin:
" + secondPlugin,
+                       pluginMap.get( secondPlugin ) );
+        assertNull( "After calculating concrete state, project should NOT contain plugin:
" + thirdPlugin,
+                    pluginMap.get( thirdPlugin ) );
+
         Plugin third = new Plugin();
         third.setGroupId( "three" );
         third.setArtifactId( "third-maven-plugin" );
         third.setVersion( "3" );
-        
+
         project.addPlugin( third );
-        
+
         project.getBuild().flushPluginMap();
         pluginMap = project.getBuild().getPluginsAsMap();
-        
-        assertNotNull( "After adding third plugin, project should contain plugin: " + firstPlugin,
pluginMap.get( firstPlugin ) );
-        assertNotNull( "After adding third plugin, project should contain plugin: " + secondPlugin,
pluginMap.get( secondPlugin ) );
-        assertNotNull( "After adding third plugin, project should contain plugin: " + thirdPlugin,
pluginMap.get( thirdPlugin ) );
-        
+
+        assertNotNull( "After adding third plugin, project should contain plugin: " + firstPlugin,
+                       pluginMap.get( firstPlugin ) );
+        assertNotNull( "After adding third plugin, project should contain plugin: " + secondPlugin,
+                       pluginMap.get( secondPlugin ) );
+        assertNotNull( "After adding third plugin, project should contain plugin: " + thirdPlugin,
+                       pluginMap.get( thirdPlugin ) );
+
         projectBuilder.restoreDynamicState( project, config );
 
         project.getBuild().flushPluginMap();
         pluginMap = project.getBuild().getPluginsAsMap();
+
+        assertNotNull( "After restoring project dynamism, project should contain plugin:
" + firstPlugin,
+                       pluginMap.get( firstPlugin ) );
+        assertNotNull( "After restoring project dynamism, project should contain plugin:
" + secondPlugin,
+                       pluginMap.get( secondPlugin ) );
+        assertNotNull( "After restoring project dynamism, project should contain plugin:
" + thirdPlugin,
+                       pluginMap.get( thirdPlugin ) );
+    }
+
+    public void testShouldMaintainAddedAndExistingSourceRootsInRoundTrip()
+        throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException,
+        ModelInterpolationException
+    {
+        MavenProject project = buildProject( "pom-source-roots.xml" );
+        
+        File basedir = project.getBasedir();
+
+        ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
+        projectBuilder.calculateConcreteState( project, config );
+
+        assertTrue( "Before adding source roots, project should be concrete", project.isConcrete()
);
+        assertEquals( "Before adding source roots, project should contain one compile source
root", 1, project.getCompileSourceRoots().size() );
+        assertEquals( "First compile source root should be absolute ref to src/main/java",
new File( basedir, "src/main/java" ).getAbsolutePath(), project.getCompileSourceRoots().get(
0 ) );
+        
+        assertEquals( "Before adding source roots, project should contain one test source
root", 1, project.getTestCompileSourceRoots().size() );
+        assertEquals( "First test source root should be absolute ref to src/test/java", new
File( basedir, "src/test/java" ).getAbsolutePath(), project.getTestCompileSourceRoots().get(
0 ) );
+        
+        assertEquals( "Before adding source roots, project should contain one script source
root", 1, project.getScriptSourceRoots().size() );
+        assertEquals( "First script source root should be absolute ref to src/main/scripts",
new File( basedir, "src/main/scripts" ).getAbsolutePath(), project.getScriptSourceRoots().get(
0 ) );
+
+        project.addCompileSourceRoot( new File( basedir, "target/generated/src/main/java"
).getAbsolutePath() );
+        project.addTestCompileSourceRoot( new File( basedir, "target/generated/src/test/java"
).getAbsolutePath() );
+        project.addScriptSourceRoot( new File( basedir, "target/generated/src/main/scripts"
).getAbsolutePath() );
+        
+        project.getProperties().setProperty( "trigger-transition", "true" );
+        
+        projectBuilder.restoreDynamicState( project, config );
+        
+        projectBuilder.calculateConcreteState( project, config );
         
-        assertNotNull( "After restoring project dynamism, project should contain plugin:
" + firstPlugin, pluginMap.get( firstPlugin ) );
-        assertNotNull( "After restoring project dynamism, project should contain plugin:
" + secondPlugin, pluginMap.get( secondPlugin ) );
-        assertNotNull( "After restoring project dynamism, project should contain plugin:
" + thirdPlugin, pluginMap.get( thirdPlugin ) );
+        assertTrue( "After adding source roots and transitioning, project should be concrete",
project.isConcrete() );
+        assertEquals( "After adding source roots and transitioning, project should contain
two compile source roots", 2, project.getCompileSourceRoots().size() );
+        assertEquals( "First compile source root should be absolute ref to src/main/java",
new File( basedir, "src/main/java" ).getAbsolutePath(), project.getCompileSourceRoots().get(
0 ) );
+        assertEquals( "Second compile source root should be absolute ref to target/generated/src/main/java",
new File( basedir, "target/generated/src/main/java" ).getAbsolutePath(), project.getCompileSourceRoots().get(
1 ) );
+        
+        assertEquals( "After adding source roots and transitioning, project should contain
two test source roots", 2, project.getTestCompileSourceRoots().size() );
+        assertEquals( "First test source root should be absolute ref to src/test/java", new
File( basedir, "src/test/java" ).getAbsolutePath(), project.getTestCompileSourceRoots().get(
0 ) );
+        assertEquals( "Second test source root should be absolute ref to target/generated/src/test/java",
new File( basedir, "target/generated/src/test/java" ).getAbsolutePath(), project.getTestCompileSourceRoots().get(
1 ) );
+        
+        assertEquals( "After adding source roots and transitioning, project should contain
two script source roots", 2, project.getScriptSourceRoots().size() );
+        assertEquals( "First script source root should be absolute ref to src/main/scripts",
new File( basedir, "src/main/scripts" ).getAbsolutePath(), project.getScriptSourceRoots().get(
0 ) );
+        assertEquals( "Second script source root should be absolute ref to target/generated/src/main/scripts",
new File( basedir, "target/generated/src/main/scripts" ).getAbsolutePath(), project.getScriptSourceRoots().get(
1 ) );
     }
 
     public void testShouldInterpolatePluginLevelDependency()

Added: maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-source-roots.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-source-roots.xml?rev=688259&view=auto
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-source-roots.xml
(added)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-source-roots.xml
Fri Aug 22 21:07:12 2008
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"

+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+         
+  <modelVersion>4.0.0</modelVersion>
+  
+  <groupId>org.test</groupId>
+  <artifactId>test-build-dynamism</artifactId>
+  <version>1</version>
+  
+  <build>
+    <sourceDirectory>src/main/java</sourceDirectory>
+    <testSourceDirectory>src/test/java</testSourceDirectory>
+    <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
+  </build>
+
+</project>
\ No newline at end of file



Mime
View raw message