continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1070743 - in /continuum/trunk: continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/ continuum-release/src/main/java/org/apache/maven/continuum/release/phase/ continuum-release/src/test...
Date Tue, 15 Feb 2011 01:55:05 GMT
Author: ctan
Date: Tue Feb 15 01:55:05 2011
New Revision: 1070743

URL: http://svn.apache.org/viewvc?rev=1070743&view=rev
Log:
[CONTINUUM-2610] explicitly activate profile in profile manager when argument has -P

Added:
    continuum/trunk/continuum-release/src/test/scm/db/revprops/6   (with props)
    continuum/trunk/continuum-release/src/test/scm/db/revs/6   (with props)
Modified:
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfigurationService.java
    continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java
    continuum/trunk/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutorTest.java
    continuum/trunk/continuum-release/src/test/scm/db/current

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfigurationService.java?rev=1070743&r1=1070742&r2=1070743&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfigurationService.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfigurationService.java
Tue Feb 15 01:55:05 2011
@@ -110,7 +110,7 @@ public class DefaultBuildAgentConfigurat
             }
             else
             {
-                return "There are no output for this build.";
+                return "There is no output for this build.";
             }
         }
         catch ( IOException e )

Modified: continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java?rev=1070743&r1=1070742&r2=1070743&view=diff
==============================================================================
--- continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java
(original)
+++ continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/GenerateReactorProjectsPhase.java
Tue Feb 15 01:55:05 2011
@@ -23,7 +23,15 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
 
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
@@ -68,6 +76,10 @@ public class GenerateReactorProjectsPhas
 
     private PlexusContainer container;
 
+    private static final char SET_SYSTEM_PROPERTY = 'D';
+
+    private static final char ACTIVATE_PROFILES = 'P';
+
     public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, Settings settings,
List reactorProjects )
         throws ReleaseExecutionException, ReleaseFailureException
     {
@@ -116,15 +128,26 @@ public class GenerateReactorProjectsPhas
         MavenProject project;
         try
         {
-            ArtifactRepository repository = getLocalRepository( descriptor.getAdditionalArguments()
);
+            String arguments = descriptor.getAdditionalArguments();
+            ArtifactRepository repository = getLocalRepository( arguments );
+            ProfileManager profileManager = getProfileManager( getSettings() );
+
+            if ( arguments != null )
+            {
+                activateProfiles( arguments, profileManager );
+            }
 
             project = projectBuilder.build( getProjectDescriptorFile( descriptor ), repository,
-                                                            getProfileManager( getSettings()
) );
+                                            profileManager );
 
             reactorProjects.add( project );
 
             addModules( reactorProjects, project, repository );
         }
+        catch ( ParseException e )
+        {
+            throw new ContinuumReleaseException( "Unable to parse arguments.", e );
+        }
         catch ( ProjectBuildingException e )
         {
             throw new ContinuumReleaseException( "Failed to build project.", e );
@@ -234,7 +257,8 @@ public class GenerateReactorProjectsPhas
 
     private ProfileManager getProfileManager( Settings settings )
     {
-        return new DefaultProfileManager( container, settings );
+        Properties props = new Properties();
+        return new DefaultProfileManager( container, settings, props );
     }
 
     private Settings getSettings()
@@ -254,6 +278,59 @@ public class GenerateReactorProjectsPhas
         }
     }
 
+    @SuppressWarnings( "static-access" )
+    private void activateProfiles( String arguments, ProfileManager profileManager )
+        throws ParseException
+    {
+        CommandLineParser parser = new GnuParser();
+
+        Options options = new Options();
+
+        options.addOption( OptionBuilder.withLongOpt( "activate-profiles" )
+                                    .withDescription( "Comma-delimited list of profiles to
activate" )
+                                    .hasArg()
+                                    .create( ACTIVATE_PROFILES ) );
+
+        options.addOption( OptionBuilder.withLongOpt( "define" )
+                           .hasArg()
+                           .withDescription( "Define a system property" )
+                           .create( SET_SYSTEM_PROPERTY ) );
+
+        String[] args = StringUtils.split( arguments );
+
+        CommandLine commandLine = parser.parse( options, args );
+
+        if ( commandLine.hasOption( ACTIVATE_PROFILES ) )
+        {
+            String [] profileOptionValues = commandLine.getOptionValues( ACTIVATE_PROFILES
);
+
+            if ( profileOptionValues != null )
+            {
+                for ( int i = 0; i < profileOptionValues.length; ++i )
+                {
+                    StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i],
"," );
+
+                    while ( profileTokens.hasMoreTokens() )
+                    {
+                        String profileAction = profileTokens.nextToken().trim();
+
+                        if ( profileAction.startsWith( "-" ) || profileAction.startsWith(
"!" ) )
+                        {
+                            profileManager.explicitlyDeactivate( profileAction.substring(
1 ) );
+                        }
+                        else if ( profileAction.startsWith( "+" ) )
+                        {
+                            profileManager.explicitlyActivate( profileAction.substring( 1
) );
+                        }
+                        else
+                        {
+                            profileManager.explicitlyActivate( profileAction );
+                        }
+                    }
+                }
+            }
+        }
+    }
 
 	public void contextualize(Context context) throws ContextException {
 		container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);

Modified: continuum/trunk/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutorTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutorTest.java?rev=1070743&r1=1070742&r2=1070743&view=diff
==============================================================================
--- continuum/trunk/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutorTest.java
(original)
+++ continuum/trunk/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutorTest.java
Tue Feb 15 01:55:05 2011
@@ -141,6 +141,7 @@ public class ReleaseTaskExecutorTest
         releaseSimpleProjectWithNextVersion();
         releasePerformWithExecutableInDescriptor();
         releaseProjectWithDependencyOfCustomPackagingType();
+        releaseProjectWithProfile();
     }
 
     public void releaseSimpleProjectWithNextVersion()
@@ -350,6 +351,54 @@ public class ReleaseTaskExecutorTest
 */
     }
 
+    // CONTINUUM-2610
+    public void releaseProjectWithProfile()
+        throws Exception
+    {
+        String scmPath = new File( getBasedir(), "target/scm-test/continuum-2610" ).getAbsolutePath().replace(
'\\', '/' );
+        File workDir = new File( getBasedir(), "target/test-classes/continuum-2610" );
+        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() );
+        descriptor.setAdditionalArguments( "-Pall" );
+
+        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 root dev version", pom.indexOf( "<version>1.0-SNAPSHOT</version>"
) > 0 );
+        String moduleAPom = FileUtils.fileRead( new File( workDir, "module-A/pom.xml" ) );
+        assertTrue( "Test module A dev version", moduleAPom.indexOf( "<version>1.0-SNAPSHOT</version>"
) > 0 );
+        String moduleBPom = FileUtils.fileRead( new File( workDir, "module-B/pom.xml" ) );
+        assertTrue( "Test module B dev version", moduleBPom.indexOf( "<version>1.0-SNAPSHOT</version>"
) > 0 );
+
+        doPrepareWithNoError( descriptor );
+
+        pom = FileUtils.fileRead( new File( workDir, "pom.xml" ) );
+        assertTrue( "Test root version increment", pom.indexOf( "<version>1.1-SNAPSHOT</version>"
) > 0 );
+        moduleAPom = FileUtils.fileRead( new File( workDir, "module-A/pom.xml" ) );
+        assertTrue( "Test module A version increment", moduleAPom.indexOf( "<version>1.1-SNAPSHOT</version>"
) > 0 );
+        moduleBPom = FileUtils.fileRead( new File( workDir, "module-B/pom.xml" ) );
+        assertTrue( "Test module B version increment", moduleBPom.indexOf( "<version>1.1-SNAPSHOT</version>"
) > 0 );
+
+        repository = getScmRepositorty( "scm:svn:file://localhost/" + scmPath + "/tags/continuum-2610-1.0"
);
+        fileSet = new ScmFileSet( testDir );
+        scmManager.getProviderByRepository( repository ).checkOut( repository, fileSet, (ScmVersion)
null );
+
+        pom = FileUtils.fileRead( new File( testDir, "pom.xml" ) );
+        assertTrue( "Test root released version", pom.indexOf( "<version>1.0</version>"
) > 0 );
+        moduleAPom = FileUtils.fileRead( new File( testDir, "module-A/pom.xml" ) );
+        assertTrue( "Test module A released version", moduleAPom.indexOf( "<version>1.0</version>"
) > 0 );
+        moduleBPom = FileUtils.fileRead( new File( testDir, "module-B/pom.xml" ) );
+        assertTrue( "Test module B released version", moduleBPom.indexOf( "<version>1.0</version>"
) > 0 );
+    }
+
     private void doPrepareWithNoError( ReleaseDescriptor descriptor )
         throws TaskExecutionException
     {

Modified: continuum/trunk/continuum-release/src/test/scm/db/current
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-release/src/test/scm/db/current?rev=1070743&r1=1070742&r2=1070743&view=diff
==============================================================================
--- continuum/trunk/continuum-release/src/test/scm/db/current (original)
+++ continuum/trunk/continuum-release/src/test/scm/db/current Tue Feb 15 01:55:05 2011
@@ -1 +1 @@
-5 i 1
+6 2e 1

Added: continuum/trunk/continuum-release/src/test/scm/db/revprops/6
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-release/src/test/scm/db/revprops/6?rev=1070743&view=auto
==============================================================================
--- continuum/trunk/continuum-release/src/test/scm/db/revprops/6 (added)
+++ continuum/trunk/continuum-release/src/test/scm/db/revprops/6 Tue Feb 15 01:55:05 2011
@@ -0,0 +1,13 @@
+K 10
+svn:author
+V 6
+marica
+K 8
+svn:date
+V 27
+2011-02-14T23:59:29.491812Z
+K 7
+svn:log
+V 37
+added test project for CONTINUUM-2610
+END

Propchange: continuum/trunk/continuum-release/src/test/scm/db/revprops/6
------------------------------------------------------------------------------
    svn:executable = *

Added: continuum/trunk/continuum-release/src/test/scm/db/revs/6
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-release/src/test/scm/db/revs/6?rev=1070743&view=auto
==============================================================================
Binary file - no diff available.

Propchange: continuum/trunk/continuum-release/src/test/scm/db/revs/6
------------------------------------------------------------------------------
    svn:executable = *

Propchange: continuum/trunk/continuum-release/src/test/scm/db/revs/6
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message