[MPLUGIN-222] 'Since' information is not shown on generated site (ANT Mojos).

Submitted by Tinguaro Barreno.

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1367250 13f79535-47bb-0310-9956-ffa450edef68
master
Olivier Lamy 2012-07-30 19:57:20 +00:00
parent 6a460fe73d
commit a2ee6a2ed2
11 changed files with 336 additions and 0 deletions

View File

@ -0,0 +1,58 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>maven-since-3.x</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>test</groupId>
<artifactId>antsample-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>ANT Sample</name>
<description>Just a test project</description>
<url>http://nowere.test</url>
<inceptionYear>2012</inceptionYear>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>@project.version@</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools-ant</artifactId>
<version>@project.version@</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>@project.version@</version>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="ant-tasks">
<!-- +++++++++++++++++++++++++++++++++++++++++++ -->
<!-- Global Properties -->
<!-- +++++++++++++++++++++++++++++++++++++++++++ -->
<!-- taskdef resource="net/sf/antcontrib/antcontrib.properties"/-->
<!-- +++++++++++++++++++++++++++++++++++++++++++ -->
<!-- Main task -->
<!-- +++++++++++++++++++++++++++++++++++++++++++ -->
<target name="sample-task">
<echo message="${message}."/>
</target>
</project>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<pluginMetadata>
<mojos>
<mojo>
<goal>sample</goal>
<call>sample-task</call>
<description>Just a test</description>
<requiresDirectInvocation>false</requiresDirectInvocation>
<requiresProject>false</requiresProject>
<since>1.0</since>
<parameters>
<parameter>
<name>message</name>
<type>java.lang.String</type>
<required>true</required>
<readonly>false</readonly>
<since>0.9</since>
<description>Test param</description>
</parameter>
</parameters>
</mojo>
</mojos>
</pluginMetadata>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="${artifactId}">
<publishDate position="right" format="dd/MM/yyyy, HH:mm" />
<version position="right"/>
<poweredBy>
<logo name="Maven" href="http://maven.apache.org/"
img="${project.url}/images/maven-feather.png" />
</poweredBy>
<body>
<menu name="Overview">
<item name="Introduction" href="index.html"/>
<item name="Goals" href="plugin-info.html"/>
<item name="Usage" href="usage.html"/>
<item name="FAQ" href="faq.html"/>
</menu>
${reports}
</body>
</project>

View File

@ -0,0 +1,3 @@
invoker.goals.1 = clean install site

View File

@ -0,0 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>maven-since-3.x</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>test</groupId>
<artifactId>javasample-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Java Sample</name>
<description>Java Maven Mojo.</description>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,82 @@
package test;
/*
* 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 org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
/**
* Goal which touches a timestamp file.
*
* @goal touch
* @since 1.0
*
* @phase process-sources
*/
public class MyMojo
extends AbstractMojo
{
/**
* Location of the file.
* @parameter property="project.build.directory"
* @required
*/
private File outputDirectory;
public void execute()
throws MojoExecutionException
{
File f = outputDirectory;
if ( !f.exists() )
{
f.mkdirs();
}
File touch = new File( f, "touch.txt" );
FileWriter w = null;
try
{
w = new FileWriter( touch );
w.write( "touch.txt" );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Error creating file " + touch, e );
}
finally
{
if ( w != null )
{
try
{
w.close();
}
catch ( IOException e )
{
// ignore
}
}
}
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="${artifactId}">
<publishDate position="right" format="dd/MM/yyyy, HH:mm" />
<version position="right"/>
<poweredBy>
<logo name="Maven" href="http://maven.apache.org/"
img="${project.url}/images/maven-feather.png" />
</poweredBy>
<body>
<menu name="Overview">
<item name="Introduction" href="index.html"/>
<item name="Goals" href="plugin-info.html"/>
<item name="Usage" href="usage.html"/>
<item name="FAQ" href="faq.html"/>
</menu>
${reports}
</body>
</project>

View File

@ -0,0 +1,74 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>maven-since-3.x</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Samples</name>
<packaging>pom</packaging>
<description>Just a test project</description>
<url>http://nowere.test</url>
<inceptionYear>2012</inceptionYear>
<modules>
<module>antsample-maven-plugin</module>
<module>javasample-maven-plugin</module>
</modules>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>generated-helpmojo</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools-ant</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.1</version>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -0,0 +1,8 @@
File touchFile = new File( basedir, "antsample-maven-plugin/target/site/sample-mojo.html" )
assert touchFile.exists()
assert touchFile.isFile()
content = touchFile.text
assert content.contains('Since');
return true;

View File

@ -126,6 +126,7 @@ public class PluginMetadataParser
descriptor.setRequiresReports( mojo.isRequiresReports() );
descriptor.setDescription( mojo.getDescription() );
descriptor.setDeprecated( mojo.getDeprecation() );
descriptor.setSince( mojo.getSince() );
LifecycleExecution le = mojo.getExecution();
if ( le != null )
@ -147,6 +148,7 @@ public class PluginMetadataParser
dParam.setEditable( !param.isReadonly() );
dParam.setExpression( param.getExpression() );
dParam.setDefaultValue( param.getDefaultValue() );
dParam.setSince( param.getSince() );
String property = param.getProperty();
if ( StringUtils.isNotEmpty( property ) )