You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/09/30 17:45:29 UTC
svn commit: r292781 - in /maven/components/trunk: maven-core-it/it0075/
maven-core-it/it0075/sub1/ maven-core-it/it0075/sub2/
maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/
maven-project/src/main/java/org/apa...
Author: jdcasey
Date: Fri Sep 30 08:45:20 2005
New Revision: 292781
URL: http://svn.apache.org/viewcvs?rev=292781&view=rev
Log:
Working on: MNG-786
o Changed the profile activation in it0075 to use a system property which is not always present
o Added projecthelp:active-profiles, package, and clean:clean to the goals list, in case it was only happening with the clean plugin
o Fixed the projecthelp mojos to be aggregators where appropriate
o Changed the ordering of modules in the profile injector (used to be that profile modules were prepended; now, they're appended)
NOTE: I still cannot reproduce the described behavior. Dan: Am I missing something WRT the test setup? I changed the activation trigger to be non-inherent, and I'm not using a boolean string to trigger the profile. What am I doing wrong??
Added:
maven/components/trunk/maven-core-it/it0075/cli-options.txt (with props)
Modified:
maven/components/trunk/maven-core-it/it0075/expected-results.txt
maven/components/trunk/maven-core-it/it0075/goals.txt
maven/components/trunk/maven-core-it/it0075/pom.xml
maven/components/trunk/maven-core-it/it0075/prebuild-hook.txt
maven/components/trunk/maven-core-it/it0075/sub1/pom.xml
maven/components/trunk/maven-core-it/it0075/sub2/pom.xml
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java
Added: maven/components/trunk/maven-core-it/it0075/cli-options.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0075/cli-options.txt?rev=292781&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0075/cli-options.txt (added)
+++ maven/components/trunk/maven-core-it/it0075/cli-options.txt Fri Sep 30 08:45:20 2005
@@ -0,0 +1 @@
+-Dactivate=anything
Propchange: maven/components/trunk/maven-core-it/it0075/cli-options.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0075/cli-options.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/maven-core-it/it0075/expected-results.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0075/expected-results.txt?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0075/expected-results.txt (original)
+++ maven/components/trunk/maven-core-it/it0075/expected-results.txt Fri Sep 30 08:45:20 2005
@@ -1,2 +1,2 @@
-sub1/.classpath
-sub2/.classpath
+!sub1/target/maven-core-it0075-sub1-1.0.jar
+!sub2/target/maven-core-it0075-sub2-1.0.jar
Modified: maven/components/trunk/maven-core-it/it0075/goals.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0075/goals.txt?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0075/goals.txt (original)
+++ maven/components/trunk/maven-core-it/it0075/goals.txt Fri Sep 30 08:45:20 2005
@@ -1 +1,4 @@
+projecthelp:active-profiles
+package
eclipse:eclipse
+clean:clean
Modified: maven/components/trunk/maven-core-it/it0075/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0075/pom.xml?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0075/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0075/pom.xml Fri Sep 30 08:45:20 2005
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.it</groupId>
<artifactId>maven-core-it0075-root</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0</version>
<packaging>pom</packaging>
<modules>
@@ -13,7 +13,9 @@
<profile>
<id>include-sub2</id>
<activation>
- <property><name>user.name</name></property>
+ <property>
+ <name>activate</name>
+ </property>
</activation>
<modules>
Modified: maven/components/trunk/maven-core-it/it0075/prebuild-hook.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0075/prebuild-hook.txt?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0075/prebuild-hook.txt (original)
+++ maven/components/trunk/maven-core-it/it0075/prebuild-hook.txt Fri Sep 30 08:45:20 2005
@@ -1,2 +1,2 @@
-rm sub1/.classpath
-rm sub2/.classpath
+rm sub1/target/maven-core-it0075-sub1-1.0.jar
+rm sub2/target/maven-core-it0075-sub2-1.0.jar
Modified: maven/components/trunk/maven-core-it/it0075/sub1/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0075/sub1/pom.xml?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0075/sub1/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0075/sub1/pom.xml Fri Sep 30 08:45:20 2005
@@ -3,7 +3,7 @@
<parent>
<groupId>org.apache.maven.it</groupId>
<artifactId>maven-core-it0075-root</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0</version>
</parent>
<artifactId>maven-core-it0075-sub1</artifactId>
Modified: maven/components/trunk/maven-core-it/it0075/sub2/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0075/sub2/pom.xml?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0075/sub2/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0075/sub2/pom.xml Fri Sep 30 08:45:20 2005
@@ -3,7 +3,7 @@
<parent>
<groupId>org.apache.maven.it</groupId>
<artifactId>maven-core-it0075-root</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0</version>
</parent>
<artifactId>maven-core-it0075-sub2</artifactId>
Modified: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java (original)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java Fri Sep 30 08:45:20 2005
@@ -4,7 +4,13 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -27,31 +33,110 @@
/** Lists the profiles which are currently active for this build.
*
* @goal active-profiles
+ * @aggregator
*/
public class ActiveProfilesPlugin extends AbstractMojo
{
/**
- * @parameter expression="${project.activeProfiles}"
+ * This is the list of projects currently slated to be built by Maven.
+ *
+ * @parameter expression="${reactorProjects}"
* @required
* @readonly
*/
- private List profiles;
+ private List projects;
+
+ /**
+ * This is an optional parameter for a file destination for the output
+ * of this mojo...the listing of active profiles per project.
+ *
+ * @parameter expression="${output}"
+ */
+ private File output;
public void execute()
throws MojoExecutionException
{
StringBuffer message = new StringBuffer();
+ for ( Iterator it = projects.iterator(); it.hasNext(); )
+ {
+ MavenProject project = (MavenProject) it.next();
+
+ getActiveProfileStatement( project, message );
+
+ message.append( "\n\n" );
+ }
+
+ if ( output != null )
+ {
+ writeFile( message );
+ }
+ else
+ {
+ Log log = getLog();
+ log.info( message );
+ }
+ }
+
+ private void writeFile( StringBuffer message )
+ throws MojoExecutionException
+ {
+ Writer writer = null;
+ try
+ {
+ File dir = output.getParentFile();
+
+ if( !dir.exists() )
+ {
+ dir.mkdirs();
+ }
+
+ writer = new FileWriter( output );
+
+ writer.write( "Created by: " + getClass().getName() + "\n" );
+ writer.write( "Created on: " + new Date() + "\n\n" );
+ writer.write( message.toString() );
+ writer.flush();
+
+ getLog().info( "Active profile report written to: " + output );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Cannot write output to file: " + output, e );
+ }
+ finally
+ {
+ if ( writer != null )
+ {
+ try
+ {
+ writer.close();
+ }
+ catch ( IOException e )
+ {
+ getLog().debug( "Failed to close output file writer.", e );
+ }
+ }
+ }
+ }
+
+ private void getActiveProfileStatement( MavenProject project, StringBuffer message )
+ {
+ List profiles = project.getActiveProfiles();
+
message.append( "\n" );
+ message.append( "Active Profiles for Project \'" + project.getId() + "\': \n\n" );
+
if( profiles == null || profiles.isEmpty() )
{
message.append( "There are no active profiles." );
}
else
{
- message.append( "The following profiles are active:\n\n" );
+ message.append( "The following profiles are active:\n" );
for ( Iterator it = profiles.iterator(); it.hasNext(); )
{
@@ -65,22 +150,12 @@
}
- message.append( "\n\n" );
-
- Log log = getLog();
-
- log.info( message );
-
- }
-
- protected final List getProfiles()
- {
- return profiles;
+ message.append( "\n" );
}
- protected final void setProfiles( List profiles )
+ public final void setProjects( List projects )
{
- this.profiles = profiles;
+ this.projects = projects;
}
}
Modified: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java Fri Sep 30 08:45:20 2005
@@ -21,6 +21,7 @@
/**
* @goal describe
+ * @aggregator
*/
public class DescribeMojo
extends AbstractMojo
Modified: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java (original)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java Fri Sep 30 08:45:20 2005
@@ -4,11 +4,15 @@
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
/*
* Copyright 2001-2005 The Apache Software Foundation.
@@ -29,58 +33,58 @@
/** Display the effective POM for this build, with the active profiles factored in.
*
* @goal effective-pom
+ * @aggregator
*/
public class EffectivePomPlugin
extends AbstractMojo
{
-
+
/**
- * @parameter expression="${project.model}"
+ * @parameter expression="${reactorProjects}"
* @required
* @readonly
*/
- private Model pom;
-
+ private List projects;
+
/**
- * @parameter
+ * @parameter expression="${output}"
*/
- private String output;
+ private File output;
public void execute()
throws MojoExecutionException
{
- StringWriter sWriter = new StringWriter();
+ StringBuffer message = new StringBuffer();
- MavenXpp3Writer pomWriter = new MavenXpp3Writer();
-
- try
+ for ( Iterator it = projects.iterator(); it.hasNext(); )
{
- pomWriter.write( sWriter, pom );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Cannot serialize POM to XML.", e );
+ MavenProject project = (MavenProject) it.next();
+
+ getEffectivePom( project, message );
+
+ message.append( "\n\n" );
}
- if( output != null && output.trim().length() > 0 )
+ if ( output != null )
{
FileWriter fWriter = null;
try
{
- File outFile = new File( output ).getAbsoluteFile();
-
- File dir = outFile.getParentFile();
-
- if( !dir.exists() )
+ File dir = output.getParentFile();
+
+ if ( !dir.exists() )
{
dir.mkdirs();
}
+
+ getLog().info( "Writing effective-POM to: " + output );
+
+ fWriter = new FileWriter( output );
+
+ fWriter.write( "Created by: " + getClass().getName() + "\n" );
+ fWriter.write( "Created on: " + new Date() + "\n\n" );
- getLog().info( "Writing effective-POM to: " + outFile );
-
- fWriter = new FileWriter( outFile );
-
- fWriter.write( sWriter.toString() );
+ fWriter.write( message.toString() );
}
catch ( IOException e )
{
@@ -88,13 +92,13 @@
}
finally
{
- if( fWriter != null )
+ if ( fWriter != null )
{
try
{
fWriter.close();
}
- catch( IOException e )
+ catch ( IOException e )
{
getLog().debug( "Cannot close FileWriter to output location: " + output, e );
}
@@ -103,34 +107,51 @@
}
else
{
- StringBuffer message = new StringBuffer();
-
- message.append( "\nEffective POM, after all profiles are factored in:\n\n" );
- message.append( sWriter.toString() );
- message.append( "\n\n" );
-
+ StringBuffer formatted = new StringBuffer();
+
+ formatted.append( "\nEffective POMs, after inheritance, interpolation, and profiles are applied:\n\n" );
+ formatted.append( message.toString() );
+ formatted.append( "\n" );
+
getLog().info( message );
}
}
- protected final String getOutput()
+ private void getEffectivePom( MavenProject project, StringBuffer message )
+ throws MojoExecutionException
{
- return output;
- }
+ Model pom = project.getModel();
+
+ StringWriter sWriter = new StringWriter();
+
+ MavenXpp3Writer pomWriter = new MavenXpp3Writer();
+
+ try
+ {
+ pomWriter.write( sWriter, pom );
+
+ message.append( "\n************************************************************************************" );
+ message.append( "\nEffective POM for project \'" + project.getId() + "\'" );
+ message.append( "\n************************************************************************************" );
+ message.append( "\n" );
+ message.append( sWriter.toString() );
+ message.append( "\n************************************************************************************" );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Cannot serialize POM to XML.", e );
+ }
- protected final void setOutput( String output )
- {
- this.output = output;
}
- protected final Model getPom()
+ protected final void setOutput( File output )
{
- return pom;
+ this.output = output;
}
- protected final void setPom( Model pom )
+ protected final void setProjects( List projects )
{
- this.pom = pom;
+ this.projects = projects;
}
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java?rev=292781&r1=292780&r2=292781&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java Fri Sep 30 08:45:20 2005
@@ -298,22 +298,26 @@
modelContainer.setConfiguration( configuration );
}
+ /**
+ * Append modules specified in the profile to the end of the list supplied by the model, if
+ * they don't already exist.
+ */
private void injectModules( Profile profile, Model model )
{
List modules = new ArrayList();
- List profileModules = profile.getModules();
+ List modelModules = model.getModules();
- if ( profileModules != null && !profileModules.isEmpty() )
+ if ( modelModules != null && !modelModules.isEmpty() )
{
- modules.addAll( profileModules );
+ modules.addAll( modelModules );
}
- List modelModules = model.getModules();
+ List profileModules = profile.getModules();
- if ( modelModules != null )
+ if ( profileModules != null )
{
- for ( Iterator it = modelModules.iterator(); it.hasNext(); )
+ for ( Iterator it = profileModules.iterator(); it.hasNext(); )
{
String module = (String) it.next();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org