Author: jdcasey
Date: Wed Aug 3 13:43:58 2005
New Revision: 227259
URL: http://svn.apache.org/viewcvs?rev=227259&view=rev
Log:
Resolving: MNG-282
Added:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java
(with props)
maven/components/trunk/maven-core-it/it0045/
maven/components/trunk/maven-core-it/it0045/cli-options.txt (with props)
maven/components/trunk/maven-core-it/it0045/expected-results.txt (with
props)
maven/components/trunk/maven-core-it/it0045/goals.txt (with props)
maven/components/trunk/maven-core-it/it0045/pom.xml (with props)
maven/components/trunk/maven-core-it/it0045/prebuild-hook.txt (with props)
maven/components/trunk/maven-core-it/it0045/subproject/
maven/components/trunk/maven-core-it/it0045/subproject/pom.xml (with
props)
Modified:
maven/components/trunk/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypeMojo.java
maven/components/trunk/maven-core-it/README.txt
maven/components/trunk/maven-core-it/integration-tests.txt
maven/components/trunk/maven-core-it/it0044/pom.xml
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
Modified:
maven/components/trunk/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypeMojo.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypeMojo.java?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
---
maven/components/trunk/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypeMojo.java
(original)
+++
maven/components/trunk/maven-archetype/maven-archetype-plugin/src/main/java/org/apache/maven/plugin/archetype/MavenArchetypeMojo.java
Wed Aug 3 13:43:58 2005
@@ -33,6 +33,7 @@
* Builds archetype containers.
*
* @goal create
+ * @requiresProject false
*/
public class MavenArchetypeMojo
extends AbstractMojo
Added:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java?rev=227259&view=auto
==============================================================================
---
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java
(added)
+++
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java
Wed Aug 3 13:43:58 2005
@@ -0,0 +1,143 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * Copyright 2001-2004 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+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.util.Map;
+
+/**
+ * Mojo which touches a file without requiring a project.
+ *
+ * @goal light-touch
+ * @requiresProject false
+ *
+ */
+public class NoProjectMojo
+ extends AbstractMojo
+{
+ /**
+ * @parameter expression="${project}"
+ */
+ private MavenProject project;
+
+ /**
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+ private String outputDirectory;
+
+ /** Test setting of plugin-artifacts on the PluginDescriptor instance.
+ * @parameter expression="${plugin.artifactMap}"
+ * @required
+ */
+ private Map pluginArtifacts;
+
+ /**
+ * @parameter expression="target/test-basedir-alignment"
+ */
+ private File basedirAlignmentDirectory;
+
+ /**
+ * @parameter
+ */
+ private String pluginItem = "foo";
+
+ /**
+ * @parameter
+ */
+ private String goalItem = "bar";
+
+ /**
+ * @parameter expression="${artifactToFile}"
+ */
+ private String artifactToFile;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ touch( new File( outputDirectory ), "touch.txt" );
+
+ // This parameter should be aligned to the basedir as the parameter
type is specified
+ // as java.io.File
+
+ if ( basedirAlignmentDirectory.getPath().equals(
"target/test-basedir-alignment" ) )
+ {
+ throw new MojoExecutionException( "basedirAlignmentDirectory not
aligned" );
+ }
+
+ touch( basedirAlignmentDirectory, "touch.txt" );
+
+ File outDir = new File( outputDirectory );
+
+ // Test parameter setting
+ if ( pluginItem != null )
+ {
+ touch( outDir, pluginItem );
+ }
+
+ if ( goalItem != null )
+ {
+ touch( outDir, goalItem );
+ }
+
+ if ( artifactToFile != null )
+ {
+ Artifact artifact = (Artifact) pluginArtifacts.get( artifactToFile
);
+
+ File artifactFile = artifact.getFile();
+
+ String filename = artifactFile.getAbsolutePath().replace('/',
'_').replace(':', '_') + ".txt";
+
+ touch( outDir, filename );
+ }
+
+ project.getBuild().setFinalName( "coreitified" );
+ }
+
+ private void touch( File dir, String file )
+ throws MojoExecutionException
+ {
+ try
+ {
+ if ( !dir.exists() )
+ {
+ dir.mkdirs();
+ }
+
+ File touch = new File( dir, file );
+
+ getLog().info( "Touching: " + touch );
+
+ FileWriter w = new FileWriter( touch );
+
+ w.write( file );
+
+ w.close();
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error touching file", e );
+ }
+ }
+}
Propchange:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/NoProjectMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/maven-core-it/README.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/README.txt?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/README.txt (original)
+++ maven/components/trunk/maven-core-it/README.txt Wed Aug 3 13:43:58 2005
@@ -126,6 +126,8 @@
it0044: Test --settings CLI option
+it0045: Test non-reactor behavior when plugin declares "@requiresProject false"
+
-------------------------------------------------------------------------------
- generated sources
Modified: maven/components/trunk/maven-core-it/integration-tests.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/integration-tests.txt?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/integration-tests.txt (original)
+++ maven/components/trunk/maven-core-it/integration-tests.txt Wed Aug 3
13:43:58 2005
@@ -1,3 +1,4 @@
+it0045
it0044
it0043
it0042
Modified: maven/components/trunk/maven-core-it/it0044/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0044/pom.xml?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0044/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0044/pom.xml Wed Aug 3 13:43:58 2005
@@ -1,7 +1,7 @@
<model>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-it0023</artifactId>
+ <artifactId>maven-it0044</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
Added: maven/components/trunk/maven-core-it/it0045/cli-options.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0045/cli-options.txt?rev=227259&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0045/cli-options.txt (added)
+++ maven/components/trunk/maven-core-it/it0045/cli-options.txt Wed Aug 3
13:43:58 2005
@@ -0,0 +1 @@
+--no-plugin-registry --check-plugin-latest
Propchange: maven/components/trunk/maven-core-it/it0045/cli-options.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0045/cli-options.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it0045/expected-results.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0045/expected-results.txt?rev=227259&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0045/expected-results.txt (added)
+++ maven/components/trunk/maven-core-it/it0045/expected-results.txt Wed Aug 3
13:43:58 2005
@@ -0,0 +1,2 @@
+target/touch.txt
+!subproject/target/touch.txt
Propchange: maven/components/trunk/maven-core-it/it0045/expected-results.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0045/expected-results.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it0045/goals.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0045/goals.txt?rev=227259&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0045/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it0045/goals.txt Wed Aug 3 13:43:58
2005
@@ -0,0 +1 @@
+core-it:light-touch
Propchange: maven/components/trunk/maven-core-it/it0045/goals.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0045/goals.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it0045/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0045/pom.xml?rev=227259&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0045/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0045/pom.xml Wed Aug 3 13:43:58 2005
@@ -0,0 +1,17 @@
+<model>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core-it0009</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0</version>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshots</id>
+ <name>Maven Central Plugins Development Repository</name>
+ <url>http://snapshots.maven.codehaus.org/maven2/plugins</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <modules>
+ <module>subproject</module>
+ </modules>
+</model>
Propchange: maven/components/trunk/maven-core-it/it0045/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0045/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it0045/prebuild-hook.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0045/prebuild-hook.txt?rev=227259&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0045/prebuild-hook.txt (added)
+++ maven/components/trunk/maven-core-it/it0045/prebuild-hook.txt Wed Aug 3
13:43:58 2005
@@ -0,0 +1 @@
+#rm
${artifact:org.apache.maven.plugins:maven-core-it-plugin:1.0-SNAPSHOT:maven-plugin}
Propchange: maven/components/trunk/maven-core-it/it0045/prebuild-hook.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0045/prebuild-hook.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it0045/subproject/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0045/subproject/pom.xml?rev=227259&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0045/subproject/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0045/subproject/pom.xml Wed Aug 3
13:43:58 2005
@@ -0,0 +1,10 @@
+<model>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core-it0045</artifactId>
+ <version>1.0</version>
+ </parent>
+ <artifactId>maven-core-it0045-subproject</artifactId>
+ <packaging>jar</packaging>
+</model>
Propchange: maven/components/trunk/maven-core-it/it0045/subproject/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0045/subproject/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
Wed Aug 3 13:43:58 2005
@@ -140,14 +140,15 @@
projects = collectProjects( files, request.getLocalRepository(),
request.isRecursive(),
request.getSettings() );
-
+
// the reasoning here is that the list is still unsorted according
to dependency, so the first project
// SHOULD BE the top-level, or the one we want to start with if
we're doing an aggregated build.
if ( !projects.isEmpty() )
{
// TODO: !![jc; 28-jul-2005] check this; if we're using '-r'
and there are aggregator tasks, this will result in weirdness.
- topLevelProject = (MavenProject) projects.get( 0 );
+ topLevelProject = findTopLevelProject( projects,
request.getPomFile() );
+
projects = ProjectSorter.getSortedProjects( projects );
}
else
@@ -266,6 +267,49 @@
throw e;
}
+ }
+
+ private MavenProject findTopLevelProject( List projects, String
customPomPath ) throws IOException
+ {
+ File topPomFile;
+
+ if ( customPomPath != null )
+ {
+ topPomFile = new File( customPomPath ).getCanonicalFile();
+ }
+ else
+ {
+ topPomFile = new File( userDir, RELEASE_POMv4 );
+
+ if ( !topPomFile.exists() )
+ {
+ topPomFile = new File( userDir, POMv4 );
+
+ if ( !topPomFile.exists() )
+ {
+ getLogger().warn( "Cannot find top-level project file in
directory: " + userDir + ". Using first project in project-list." );
+
+ return (MavenProject) projects.get( 0 );
+ }
+ }
+ }
+
+ MavenProject topProject = null;
+
+ for ( Iterator it = projects.iterator(); it.hasNext(); )
+ {
+ MavenProject project = (MavenProject) it.next();
+
+ File projectFile = project.getFile().getCanonicalFile();
+
+ if ( topPomFile.equals( projectFile ) )
+ {
+ topProject = project;
+ break;
+ }
+ }
+
+ return topProject;
}
private List collectProjects( List files, ArtifactRepository
localRepository, boolean recursive, Settings settings )
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
Wed Aug 3 13:43:58 2005
@@ -289,7 +289,10 @@
getLogger().debug( "", e );
}
- if ( mojo != null && mojo.isAggregator() )
+ // if the mojo descriptor was found, determine aggregator
status according to:
+ // 1. whether the mojo declares itself an aggregator
+ // 2. whether the mojo DOES NOT require a project to function
(implicitly avoid reactor)
+ if ( mojo != null && ( mojo.isAggregator() ||
!mojo.isProjectRequired() ) )
{
if ( currentSegment != null && !currentSegment.aggregate()
)
{
Modified:
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java?rev=227259&r1=227258&r2=227259&view=diff
==============================================================================
---
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
(original)
+++
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
Wed Aug 3 13:43:58 2005
@@ -236,7 +236,12 @@
if ( requiresProject != null )
{
- mojoDescriptor.setProjectRequired( true );
+ String requiresProjectValue = requiresProject.getValue();
+
+ if ( requiresProjectValue != null )
+ {
+ mojoDescriptor.setProjectRequired( Boolean.valueOf(
requiresProjectValue ).booleanValue() );
+ }
}
//
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]