You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ol...@apache.org on 2008/12/04 00:04:07 UTC

svn commit: r723119 - in /continuum/branches/continuum-1.2.x/continuum-core/src: main/java/org/apache/maven/continuum/execution/ main/java/org/apache/maven/continuum/execution/maven/m2/ test/java/org/apache/maven/continuum/execution/maven/m2/ test/reso...

Author: olamy
Date: Wed Dec  3 15:04:06 2008
New Revision: 723119

URL: http://svn.apache.org/viewvc?rev=723119&view=rev
Log:
[CONTINUUM-1915] Continuum 1.2 does not build the project when it has changes in sub-modules and the m2 build is recursive.


Added:
    continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutorTest.java   (with props)
    continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/applicationContextSlf4jPlexusLogger.xml   (with props)
Modified:
    continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
    continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
    continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/log4j.xml

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java?rev=723119&r1=723118&r2=723119&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java (original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java Wed Dec  3 15:04:06 2008
@@ -36,6 +36,8 @@
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.CommandLineException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.util.Collections;
@@ -52,6 +54,9 @@
     extends AbstractLogEnabled
     implements ContinuumBuildExecutor, Initializable
 {
+    
+    protected Logger logger = LoggerFactory.getLogger( getClass() );
+    
     private static final String SUDO_EXECUTABLE = "sudo";
 
     private static final String CHROOT_EXECUTABLE = "chroot";

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java?rev=723119&r1=723118&r2=723119&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java (original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java Wed Dec  3 15:04:06 2008
@@ -25,7 +25,6 @@
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -54,6 +53,8 @@
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -63,6 +64,7 @@
     extends AbstractBuildExecutor
     implements ContinuumBuildExecutor
 {
+    
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -394,15 +396,17 @@
         throws ContinuumBuildExecutorException
     {
         //Check if it's a recursive build
-        boolean isRecursive = StringUtils.isNotEmpty( buildDefinition.getArguments() ) && !(
-            buildDefinition.getArguments().indexOf( "-N" ) < 0 ||
-                buildDefinition.getArguments().indexOf( "--non-recursive" ) < 0 );
-
-        if ( isRecursive )
+        boolean isRecursive = false;
+        if (StringUtils.isNotEmpty( buildDefinition.getArguments() ) )
+            {
+            isRecursive =  buildDefinition.getArguments().indexOf( "-N" ) < 0 &&
+                buildDefinition.getArguments().indexOf( "--non-recursive" ) < 0 ;
+            }
+        if ( isRecursive && changes != null && !changes.isEmpty() )
         {
-            if ( getLogger().isDebugEnabled() )
+            if ( logger.isInfoEnabled() )
             {
-                getLogger().debug( "isRecursive --> shouldBuild = true" );
+                logger.info( "recursive build and changes found --> building" );
             }
             return true;
         }
@@ -412,15 +416,15 @@
         //CONTINUUM-1815: additional check for projects recently released
         if ( !continuumProject.getVersion().equals( project.getVersion() ) )
         {
-            getLogger().info( "Found changes in project's version ( maybe project was recently released ), building" );
+            logger.info( "Found changes in project's version ( maybe project was recently released ), building" );
             return true;
         }
         
         if ( changes.isEmpty() )
         {
-            if ( getLogger().isDebugEnabled() )
+            if ( logger.isInfoEnabled() )
             {
-                getLogger().info( "Found no changes, not building" );
+                logger.info( "Found no changes, not building" );
             }
             return false;
         }
@@ -438,15 +442,28 @@
         while ( i <= files.size() - 1 )
         {
             ChangeFile file = files.get( i );
+            if ( logger.isDebugEnabled() )
+            {
+                logger.debug( "changeFile.name " + file.getName() );
+                logger.debug( "check in modules " + modules );
+            }
             boolean found = false;
             for ( String module : modules )
             {
-                if ( file.getName().indexOf( module ) > 0 )
+                if ( file.getName().indexOf( module ) >= 0 )
                 {
+                    if ( logger.isDebugEnabled() )
+                    {
+                        logger.debug( "changeFile.name " + file.getName() + " removed because in a module" );
+                    }                    
                     files.remove( file );
                     found = true;
                     break;
                 }
+                if (logger.isDebugEnabled())
+                {
+                    logger.debug( "no remving file " + file.getName() + " not in module " + module );
+                }
             }
             if ( !found )
             {
@@ -458,12 +475,12 @@
 
         if ( !shouldBuild )
         {
-            getLogger().info( "Changes are only in sub-modules." );
+            logger.info( "Changes are only in sub-modules." );
         }
 
-        if ( getLogger().isDebugEnabled() )
+        if ( logger.isDebugEnabled() )
         {
-            getLogger().debug( "shoulbuild = " + shouldBuild );
+            logger.debug( "shoulbuild = " + shouldBuild );
         }
         return shouldBuild;
     }

Added: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutorTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutorTest.java?rev=723119&view=auto
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutorTest.java (added)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutorTest.java Wed Dec  3 15:04:06 2008
@@ -0,0 +1,115 @@
+package org.apache.maven.continuum.execution.maven.m2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.scm.ChangeFile;
+import org.apache.maven.continuum.model.scm.ChangeSet;
+
+/**
+ * @author olamy
+ * @since 1.2.3
+ * @version $Id$
+ */
+public class MavenTwoBuildExecutorTest
+    extends AbstractContinuumTest
+{
+       
+    
+    @Override
+    protected String getSpringConfigLocation()
+    {
+        return "applicationContextSlf4jPlexusLogger.xml";
+    }
+
+    public void testShouldNotBuildNonRecursive()
+        throws Exception
+    {
+        MavenTwoBuildExecutor executor = (MavenTwoBuildExecutor) lookup( ContinuumBuildExecutor.class, "maven2" );
+        BuildDefinition buildDefinition = new BuildDefinition();
+        buildDefinition.setArguments( "-N" );
+        Project continuumProject = new Project(){
+            {
+                setVersion( "1.0.3" );
+            }
+        };
+        assertFalse( executor.shouldBuild( new ArrayList<ChangeSet>(), continuumProject, new File( "target/test-classes/projects/continuum" ),
+                                           buildDefinition ) );
+    }
+    
+    public void testShouldNotBuildNonRecursiveChangeInAModule()
+        throws Exception
+    {
+        MavenTwoBuildExecutor executor = (MavenTwoBuildExecutor) lookup( ContinuumBuildExecutor.class, "maven2" );
+        BuildDefinition buildDefinition = new BuildDefinition();
+        buildDefinition.setArguments( "-N -Dfoo=bar" );
+        Project continuumProject = new Project()
+        {
+            {
+                setVersion( "1.0.3" );
+            }
+        };
+        final ChangeFile changeFile = new ChangeFile();
+        changeFile.setName( "continuum-notifiers/pom.xml");
+        ChangeSet changeSet = new ChangeSet()
+        {
+            {
+                addFile( changeFile );
+            }
+        };
+        List<ChangeSet> changeSets = new ArrayList<ChangeSet>();
+        changeSets.add( changeSet );
+        assertFalse( executor.shouldBuild(changeSets , continuumProject,
+                                           new File( "target/test-classes/projects/continuum" ), buildDefinition ) );
+    }    
+    
+    public void testShouldBuildRecursiveChangeInAModule()
+        throws Exception
+    {
+        MavenTwoBuildExecutor executor = (MavenTwoBuildExecutor) lookup( ContinuumBuildExecutor.class, "maven2" );
+        BuildDefinition buildDefinition = new BuildDefinition();
+        buildDefinition.setArguments( "-Dfoo=bar" );
+        Project continuumProject = new Project()
+        {
+            {
+                setVersion( "1.0.3" );
+            }
+        };
+        final ChangeFile changeFile = new ChangeFile();
+        changeFile.setName( "continuum-notifiers/pom.xml" );
+        ChangeSet changeSet = new ChangeSet()
+        {
+            {
+                addFile( changeFile );
+            }
+        };
+        List<ChangeSet> changeSets = new ArrayList<ChangeSet>();
+        changeSets.add( changeSet );
+        assertTrue( executor.shouldBuild( changeSets, continuumProject,
+                                          new File( "target/test-classes/projects/continuum" ), buildDefinition ) );
+    }       
+}

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutorTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutorTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/applicationContextSlf4jPlexusLogger.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/applicationContextSlf4jPlexusLogger.xml?rev=723119&view=auto
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/applicationContextSlf4jPlexusLogger.xml (added)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/applicationContextSlf4jPlexusLogger.xml Wed Dec  3 15:04:06 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+  <bean id="loggerManager" class="org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager"
+    init-method="initialize"/>
+  
+</beans>

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/applicationContextSlf4jPlexusLogger.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/applicationContextSlf4jPlexusLogger.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/applicationContextSlf4jPlexusLogger.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/log4j.xml?rev=723119&r1=723118&r2=723119&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/log4j.xml (original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/test/resources/log4j.xml Wed Dec  3 15:04:06 2008
@@ -1,41 +1,40 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<!-- ===================================================================== -->
-<!-- Log4j Configuration -->
-<!-- ===================================================================== -->
 
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
-  debug="false">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
 
   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
-    <param name="Target" value="System.out"/>
     <layout class="org.apache.log4j.PatternLayout">
-      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}.%M](%L) %m%n"/>
+      <param name="ConversionPattern" value="%d %-5p %c %x - %m%n"/>
     </layout>
   </appender>
 
   <!-- quiet spring loading :-) -->
-  <category name="org.springframework">
-    <priority value="ERROR"/>
-  </category>
-  <category name="org.codehaus.plexus">
-    <priority value="ERROR"/>
-  </category>
+  <logger name="org.springframework">
+    <level value="ERROR"/>
+  </logger>
+  <logger name="org.codehaus.plexus">
+    <level value="ERROR"/>
+  </logger>
   
-  <category name="org.apache.commons">
-    <priority value="ERROR"/>
-  </category>  
+  <logger name="org.apache.commons">
+    <level value="ERROR"/>
+  </logger>  
+  
+  <logger name="org.apache.maven.continuum.execution.maven.m2">
+    <level value="debug" />
+  </logger>
 
   <!-- JPOX -->
-  <category name="JPOX">
-    <priority value="WARN"/>
-  </category>
-  <category name="JPOX.RDBMS">
-    <priority value="ERROR"/>
-  </category>
+  <logger name="JPOX">
+    <level value="WARN"/>
+  </logger>
+  <logger name="JPOX.RDBMS">
+    <level value="ERROR"/>
+  </logger>
 
   <root>
-    <priority value="INFO"/>
+    <level value="INFO"/>
     <appender-ref ref="CONSOLE"/>
   </root>