mirror of https://github.com/apache/maven.git
(Merging 389199:389201 from branch.)
o Cleaned up example in the comment-header of the plugin-metadata.mdo o Added code to initialize a dummy Model instance in MavenProject, to avoid NPEs in things like getId(). git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@389203 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
02fd611c54
commit
cedf9e04bc
|
@ -1,40 +1,51 @@
|
|||
<!--
|
||||
<pluginMetadata>
|
||||
<mojos>
|
||||
<mojo goal="myGoal"
|
||||
phase="compile"
|
||||
requiresDependencyResolution="compile"
|
||||
requiresProject="true"
|
||||
requiresReports="true"
|
||||
requiresOnline="true"
|
||||
inheritByDefault="true"
|
||||
requiresDirectInvocation="true"
|
||||
aggregator="true">
|
||||
<pluginMetadata>
|
||||
<mojos>
|
||||
<mojo>
|
||||
<goal>myGoal</goal>
|
||||
<phase>compile</phase>
|
||||
<requiresDependencyResolution>compile</requiresDependencyResolution>
|
||||
<requiresProject>true</requiresProject>
|
||||
<requiresReports>true</requiresReports>
|
||||
<requiresOnline>true</requiresOnline>
|
||||
<inheritByDefault>true</inheritByDefault>
|
||||
<requiresDirectInvocation>true</requiresDirectInvocation>
|
||||
<aggregator>true</aggregator>
|
||||
|
||||
<execute phase="initialize" lifecycle="mine" goal="some:goal"/>
|
||||
<components>
|
||||
<component role="stuff" hint="more"/>
|
||||
</components>
|
||||
<parameters>
|
||||
<parameter name="nom"
|
||||
property="prop"
|
||||
required="true"
|
||||
readonly="true"
|
||||
expression="${my.property}"
|
||||
defaultValue="${project.artifactId}"
|
||||
type="org.apache.maven.project.MavenProject"
|
||||
alias="otherProp">
|
||||
<description>Test parameter</description>
|
||||
<deprecated>Use something else</deprecated>
|
||||
</parameter>
|
||||
</parameters>
|
||||
<description>
|
||||
This is a test.
|
||||
</description>
|
||||
<deprecated>Use another mojo</deprecated>
|
||||
</mojo>
|
||||
</mojos>
|
||||
</pluginMetadata>
|
||||
<execute>
|
||||
<phase>initialize</phase>
|
||||
<lifecycle>mine</lifecycle>
|
||||
<goal>goal</goal>
|
||||
</execute>
|
||||
|
||||
<components>
|
||||
<component>
|
||||
<role>stuff</role>
|
||||
<hint>more</hint>
|
||||
</component>
|
||||
</components>
|
||||
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>nom</name>
|
||||
<property>prop</property>
|
||||
<required>true</required>
|
||||
<readonly>true</readonly>
|
||||
<expression>${my.property}</expression>
|
||||
<defaultValue>${project.artifactId}</defaultValue>
|
||||
<type>org.apache.maven.project.MavenProject</type>
|
||||
<alias>otherProp</alias>
|
||||
<description>Test parameter</description>
|
||||
<deprecated>Use something else</deprecated>
|
||||
</parameter>
|
||||
</parameters>
|
||||
<description>
|
||||
This is a test.
|
||||
</description>
|
||||
<deprecated>Use another mojo</deprecated>
|
||||
</mojo>
|
||||
</mojos>
|
||||
</pluginMetadata>
|
||||
-->
|
||||
<model>
|
||||
<id>plugin-metadata</id>
|
||||
|
|
|
@ -78,6 +78,12 @@ import java.util.Set;
|
|||
*/
|
||||
public class MavenProject
|
||||
{
|
||||
public static final String EMPTY_PROJECT_GROUP_ID = "unknown";
|
||||
|
||||
public static final String EMPTY_PROJECT_ARTIFACT_ID = "empty-project";
|
||||
|
||||
public static final String EMPTY_PROJECT_VERSION = "0";
|
||||
|
||||
private Model model;
|
||||
|
||||
private MavenProject parent;
|
||||
|
@ -139,6 +145,17 @@ public class MavenProject
|
|||
|
||||
private Map moduleAdjustments;
|
||||
|
||||
public MavenProject()
|
||||
{
|
||||
Model model = new Model();
|
||||
|
||||
model.setGroupId( EMPTY_PROJECT_GROUP_ID );
|
||||
model.setArtifactId( EMPTY_PROJECT_ARTIFACT_ID );
|
||||
model.setVersion( EMPTY_PROJECT_VERSION );
|
||||
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public MavenProject( Model model )
|
||||
{
|
||||
this.model = model;
|
||||
|
|
|
@ -24,6 +24,15 @@ import org.apache.maven.model.Model;
|
|||
public class MavenProjectTest
|
||||
extends AbstractMavenProjectTestCase
|
||||
{
|
||||
|
||||
public void testEmptyConstructor()
|
||||
{
|
||||
MavenProject project = new MavenProject();
|
||||
|
||||
assertEquals( MavenProject.EMPTY_PROJECT_GROUP_ID + ":" + MavenProject.EMPTY_PROJECT_ARTIFACT_ID + ":jar:"
|
||||
+ MavenProject.EMPTY_PROJECT_VERSION, project.getId() );
|
||||
}
|
||||
|
||||
public void testCopyConstructor() throws Exception
|
||||
{
|
||||
File f = getFileForClasspathResource( "canonical-pom.xml" );
|
||||
|
|
Loading…
Reference in New Issue