Author: jdcasey
Date: Wed Jun 8 10:54:11 2005
New Revision: 189612
URL: http://svn.apache.org/viewcvs?rev=189612&view=rev
Log:
o Started maven-projecthelp-plugin to help with build analysis (this helped me
to visualize profile stuff)
current goals:
projecthelp:active-profiles
projecthelp:effective-pom
o Added source attribute to the Profile model class in maven-model, along with
code in the normalization utilities (converters from profiles.xml and
settings.xml models to maven-model instances) to identify the source of a
particular profile.
o Added a activeProfiles cache of the Profiles in effect for the current
project, on the MavenProject class
Added:
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml
(with props)
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java
(with props)
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java
(with props)
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/model/ModelNormalizationUtils.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ExternalProfileInjector.java
maven/components/trunk/maven-model/maven.mdo
maven/components/trunk/maven-model/pom.xml
maven/components/trunk/maven-plugins/pom.xml
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/model/ModelNormalizationUtils.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/model/ModelNormalizationUtils.java?rev=189612&r1=189611&r2=189612&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/model/ModelNormalizationUtils.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/model/ModelNormalizationUtils.java
Wed Jun 8 10:54:11 2005
@@ -35,6 +35,8 @@
public static Profile convertFromSettingsProfile(
org.apache.maven.settings.Profile settingsProfile )
{
Profile profile = new Profile();
+
+ profile.setSource( "settings.xml" );
org.apache.maven.settings.Activation settingsActivation =
settingsProfile.getActivation();
@@ -86,6 +88,8 @@
{
Profile profile = new Profile();
+ profile.setSource( "profiles.xml" );
+
org.apache.maven.profiles.Activation profileActivation =
profileXmlProfile.getActivation();
if ( profileActivation != null )
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ExternalProfileInjector.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ExternalProfileInjector.java?rev=189612&r1=189611&r2=189612&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ExternalProfileInjector.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ExternalProfileInjector.java
Wed Jun 8 10:54:11 2005
@@ -67,6 +67,8 @@
project.addProfileConfiguration( props );
}
}
+
+ project.addActiveProfiles( activeProfiles );
}
private void mergePluginRepositories( MavenProject project, Model model,
Profile profile ) throws ProjectBuildingException
Modified: maven/components/trunk/maven-model/maven.mdo
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/maven.mdo?rev=189612&r1=189611&r2=189612&view=diff
==============================================================================
--- maven/components/trunk/maven-model/maven.mdo (original)
+++ maven/components/trunk/maven-model/maven.mdo Wed Jun 8 10:54:11 2005
@@ -2319,6 +2319,19 @@
{
return properties;
}
+
+ // default source for this profile is in the pom itself.
+ private String source = "pom";
+
+ public void setSource( String source )
+ {
+ this.source = source;
+ }
+
+ public String getSource()
+ {
+ return source;
+ }
]]></code>
</codeSegment>
</codeSegments>
Modified: maven/components/trunk/maven-model/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/pom.xml?rev=189612&r1=189611&r2=189612&view=diff
==============================================================================
--- maven/components/trunk/maven-model/pom.xml (original)
+++ maven/components/trunk/maven-model/pom.xml Wed Jun 8 10:54:11 2005
@@ -20,7 +20,8 @@
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
- <version>1.0-alpha-3-SNAPSHOT</version>
+ <version>1.0-alpha-2</version>
+ <!-- version>1.0-alpha-3-SNAPSHOT</version -->
<configuration>
<version>4.0.0</version>
<model>maven.mdo</model>
Added: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml?rev=189612&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml
(added)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml Wed
Jun 8 10:54:11 2005
@@ -0,0 +1,30 @@
+<model>
+ <parent>
+ <artifactId>maven-plugin-parent</artifactId>
+ <groupId>org.apache.maven.plugins</groupId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>maven-projecthelp-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>Maven Project-Help Plugin</name>
+ <version>2.0-alpha-3-SNAPSHOT</version>
+ <inceptionYear>2001</inceptionYear>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-tools-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</model>
Propchange:
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Propchange:
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
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=189612&view=auto
==============================================================================
---
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java
(added)
+++
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java
Wed Jun 8 10:54:11 2005
@@ -0,0 +1,76 @@
+package org.apache.maven.plugins.projecthelp;
+
+import org.apache.maven.model.Profile;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+
+import java.util.Iterator;
+import java.util.List;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/** Lists the profiles which are currently active for this build.
+ *
+ * @goal active-profiles
+ */
+public class ActiveProfilesPlugin extends AbstractMojo
+{
+
+ /**
+ * @parameter expression="${project.activeProfiles}"
+ * @required
+ * @readonly
+ */
+ private List profiles;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ StringBuffer message = new StringBuffer();
+
+ message.append( "\n" );
+
+ if( profiles == null || profiles.isEmpty() )
+ {
+ message.append( "There are no active profiles." );
+ }
+ else
+ {
+ message.append( "The following profiles are active:\n\n" );
+
+ for ( Iterator it = profiles.iterator(); it.hasNext(); )
+ {
+ Profile profile = (Profile) it.next();
+
+ message.append( "\n - " )
+ .append( profile.getId() )
+ .append(" (source: " )
+ .append( profile.getSource() ).append( ")" );
+ }
+
+ }
+
+ message.append( "\n\n" );
+
+ Log log = getLog();
+
+ log.info( message );
+
+ }
+
+}
Propchange:
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added:
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=189612&view=auto
==============================================================================
---
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java
(added)
+++
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java
Wed Jun 8 10:54:11 2005
@@ -0,0 +1,116 @@
+package org.apache.maven.plugins.projecthelp;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/** Display the effective POM for this build, with the active profiles
factored in.
+ *
+ * @goal effective-pom
+ */
+public class EffectivePomPlugin
+ extends AbstractMojo
+{
+
+ /**
+ * @parameter expression="${project.model}"
+ * @required
+ * @readonly
+ */
+ private Model pom;
+
+ /**
+ * @parameter
+ */
+ private String output;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ StringWriter sWriter = new StringWriter();
+
+ MavenXpp3Writer pomWriter = new MavenXpp3Writer();
+
+ try
+ {
+ pomWriter.write( sWriter, pom );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Cannot serialize POM to XML.",
e );
+ }
+
+ if( output != null && output.trim().length() > 0 )
+ {
+ FileWriter fWriter = null;
+ try
+ {
+ File outFile = new File( output ).getAbsoluteFile();
+
+ File dir = outFile.getParentFile();
+
+ if( !dir.exists() )
+ {
+ dir.mkdirs();
+ }
+
+ getLog().info( "Writing effective-POM to: " + outFile );
+
+ fWriter = new FileWriter( outFile );
+
+ fWriter.write( sWriter.toString() );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Cannot write effective-POM
to output: " + output, e );
+ }
+ finally
+ {
+ if( fWriter != null )
+ {
+ try
+ {
+ fWriter.close();
+ }
+ catch( IOException e )
+ {
+ getLog().debug( "Cannot close FileWriter to output
location: " + output, e );
+ }
+ }
+ }
+ }
+ 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" );
+
+ getLog().info( message );
+ }
+ }
+
+}
Propchange:
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Modified: maven/components/trunk/maven-plugins/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/pom.xml?rev=189612&r1=189611&r2=189612&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/pom.xml (original)
+++ maven/components/trunk/maven-plugins/pom.xml Wed Jun 8 10:54:11 2005
@@ -87,6 +87,7 @@
<module>maven-install-plugin</module>
<module>maven-jar-plugin</module>
<module>maven-plugin-plugin</module>
+ <module>maven-projecthelp-plugin</module>
<module>maven-release-plugin</module>
<module>maven-resources-plugin</module>
<module>maven-site-plugin</module>
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=189612&r1=189611&r2=189612&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Wed Jun 8 10:54:11 2005
@@ -280,6 +280,8 @@
MavenProject parentProject = project.getParent();
project = new MavenProject( model );
+
+ project.addActiveProfiles( activePomProfiles );
project.setPluginArtifactRepositories(
ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(),
artifactRepositoryFactory, container ) );
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=189612&r1=189611&r2=189612&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
Wed Jun 8 10:54:11 2005
@@ -175,6 +175,8 @@
private ArtifactRepository distMgmtArtifactRepository;
+ private List activeProfiles = new ArrayList();
+
public void addCompileSourceRoot( String path )
{
if ( path != null )
@@ -897,6 +899,16 @@
public void addProfileConfiguration( Properties profileConfiguration )
{
this.profileConfiguration = profileConfiguration;
+ }
+
+ public void addActiveProfiles( List activeProfiles )
+ {
+ this.activeProfiles.addAll( activeProfiles );
+ }
+
+ public List getActiveProfiles()
+ {
+ return activeProfiles;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]