PR: MNG-471

add lifecycle mapping model


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191380 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-06-20 03:17:43 +00:00
parent 68e52f7f9c
commit 4e42fdf78e
4 changed files with 196 additions and 0 deletions

View File

@ -19,4 +19,26 @@
<version>1.0-alpha-4-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<version>1.0-alpha-3-SNAPSHOT</version>
<configuration>
<model>src/main/mdo/lifecycle.mdo</model>
<version>1.0.0</version>
</configuration>
<executions>
<execution>
<goals>
<goal>java</goal>
<goal>xpp3-reader</goal>
<goal>xpp3-writer</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,100 @@
<model>
<id>lifecycle-mappings</id>
<name>LifecycleMappings</name>
<description><![CDATA[
Configuration of custom lifecycle mappings for the plugin.
]]></description>
<defaults>
<default>
<key>package</key>
<value>org.apache.maven.plugin.lifecycle</value>
</default>
</defaults>
<classes>
<class rootElement="true" xml.tagName="lifecycles">
<name>LifecycleConfiguration</name>
<version>1.0.0</version>
<description>Root element of the lifecycle.xml file.</description>
<fields>
<field xml.listStyle="flat">
<name>lifecycles</name>
<version>1.0.0</version>
<association>
<type>Lifecycle</type>
<multiplicity>*</multiplicity>
</association>
</field>
</fields>
</class>
<class>
<name>Lifecycle</name>
<version>1.0.0</version>
<description><![CDATA[
A custom lifecycle mapping definition.
]]></description>
<fields>
<field>
<name>id</name>
<required>true</required>
<version>1.0.0</version>
<type>String</type>
<description>The ID of this lifecycle, for identification in the mojo descriptor.</description>
</field>
<field>
<name>phases</name>
<version>1.0.0</version>
<description>The phase mappings for this lifecycle.</description>
<association>
<type>Phase</type>
<multiplicity>*</multiplicity>
</association>
</field>
</fields>
</class>
<class>
<name>Phase</name>
<version>1.0.0</version>
<description>A phase mapping definition.</description>
<fields>
<field>
<name>id</name>
<required>true</required>
<version>1.0.0</version>
<type>String</type>
<description>The ID of this phase, eg &lt;code&gt;generate-sources&lt;/code&gt;.</description>
</field>
<field>
<name>executions</name>
<version>1.0.0</version>
<description>The goals to execute within the phase.</description>
<association>
<type>Execution</type>
<multiplicity>*</multiplicity>
</association>
</field>
</fields>
</class>
<class>
<name>Execution</name>
<version>1.0.0</version>
<description>A set of goals to execute.</description>
<fields>
<field>
<name>configuration</name>
<version>1.0.0</version>
<type>DOM</type>
<description>Configuration to pass to the goals.</description>
</field>
<field>
<name>goals</name>
<version>1.0.0</version>
<description>The goals to execute.</description>
<association>
<type>String</type>
<multiplicity>*</multiplicity>
</association>
</field>
</fields>
</class>
</classes>
</model>

View File

@ -0,0 +1,54 @@
package org.apache.maven.plugin.lifecycle;
/*
* 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.
*/
import junit.framework.TestCase;
import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.InputStreamReader;
import java.io.IOException;
/**
* Test the lifecycle reader.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class LifecycleXpp3ReaderTest
extends TestCase
{
public void testLifecycleReader()
throws IOException, XmlPullParserException
{
LifecycleMappingsXpp3Reader reader = new LifecycleMappingsXpp3Reader();
LifecycleConfiguration config = reader.read( new InputStreamReader( getClass().getResourceAsStream( "/lifecycle.xml" ) ) );
assertEquals( "check number of lifecycles", 1, config.getLifecycles().size() );
Lifecycle l = (Lifecycle) config.getLifecycles().iterator().next();
assertEquals( "check id", "clover", l.getId() );
assertEquals( "check number of phases", 1, l.getPhases().size() );
Phase p = (Phase) l.getPhases().iterator().next();
assertEquals( "check id", "generate-sources", p.getId() );
assertEquals( "check number of executions", 1, p.getExecutions().size() );
Execution e = (Execution) p.getExecutions().iterator().next();
assertEquals( "check configuration", "true", ((Xpp3Dom) e.getConfiguration()).getChild( "debug" ).getValue() );
assertEquals( "check number of goals", 1, e.getGoals().size() );
String g = (String) e.getGoals().iterator().next();
assertEquals( "check goal", "clover:compiler", g );
}
}

View File

@ -0,0 +1,20 @@
<lifecycles>
<lifecycle>
<id>clover</id>
<phases>
<phase>
<id>generate-sources</id>
<executions>
<execution>
<configuration>
<debug>true</debug>
</configuration>
<goals>
<goal>clover:compiler</goal>
</goals>
</execution>
</executions>
</phase>
</phases>
</lifecycle>
</lifecycles>