[MPLUGIN-319] @since values ignored in report
Only use plugin.xml for M3.4.0 and above due to MNG-6109 git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1770562 13f79535-47bb-0310-9956-ffa450edef68master
parent
f223b01735
commit
89a82c2963
|
|
@ -0,0 +1,18 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you 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.
|
||||
|
||||
invoker.goals = clean plugin:report
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you 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.
|
||||
-->
|
||||
|
||||
<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>
|
||||
|
||||
<groupId>org.apache.maven.plugins.its.plugin</groupId>
|
||||
<artifactId>report-since</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<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>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>@project.version@</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>@sitePluginVersion@</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>index</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>@project.version@</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package org;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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;
|
||||
|
||||
/**
|
||||
* Does nothing.
|
||||
*
|
||||
* @goal noop
|
||||
* @phase process-sources
|
||||
* @requiresDependencyResolution test
|
||||
* @requiresDirectInvocation true
|
||||
* @requiresOnline
|
||||
* @inheritByDefault false
|
||||
* @execute phase="compile"
|
||||
* @aggregator
|
||||
* @since 1.0
|
||||
*
|
||||
* @deprecated You don't use test goals, do you?
|
||||
*/
|
||||
public class MyMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
/**
|
||||
* This is a test.
|
||||
*
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
@SuppressWarnings( "unused" )
|
||||
private String required;
|
||||
|
||||
/**
|
||||
* This is a test.
|
||||
*
|
||||
* @parameter expression="${string}" default-value="${project.version}/</markup-must-be-escaped>"
|
||||
* @deprecated Just testing.
|
||||
* @since 1.1
|
||||
*/
|
||||
@SuppressWarnings( "unused" )
|
||||
private String string;
|
||||
|
||||
public void execute()
|
||||
{
|
||||
// intentional do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
assert new File( basedir, 'target/generated-site' ).exists()
|
||||
|
||||
content = new File( basedir, 'target/generated-site/xdoc/noop-mojo.xml' ).text
|
||||
|
||||
assert content.contains( '<li><strong>Since</strong>: <code>1.0</code></li>' )
|
||||
assert content.contains( '<li><strong>Since</strong>: <code>1.1</code></li>' )
|
||||
|
||||
return true
|
||||
|
|
@ -90,6 +90,10 @@ under the License.
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>@project.version@</version>
|
||||
<configuration>
|
||||
<!-- ignore MNG-6109 issue -->
|
||||
<pluginXmlSpec>[2.0,)</pluginXmlSpec>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
|
|
|||
|
|
@ -19,10 +19,24 @@ package org.apache.maven.plugin.plugin;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.apache.maven.doxia.sink.Sink;
|
||||
import org.apache.maven.doxia.siterenderer.Renderer;
|
||||
import org.apache.maven.execution.RuntimeInformation;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
|
|
@ -50,17 +64,6 @@ import org.codehaus.plexus.configuration.PlexusConfigurationException;
|
|||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Generates the Plugin's documentation report: <code>plugin-info.html</code> plugin overview page,
|
||||
* and one <code><i>goal</i>-mojo.html</code> per goal.
|
||||
|
|
@ -186,6 +189,19 @@ public class PluginReport
|
|||
*/
|
||||
@Parameter( defaultValue = "${localRepository}", required = true, readonly = true )
|
||||
protected ArtifactRepository local;
|
||||
|
||||
/**
|
||||
* @since 3.5.1
|
||||
*/
|
||||
@Component
|
||||
private RuntimeInformation rtInfo;
|
||||
|
||||
/**
|
||||
* By default pluginXml should be read with Maven-3.4.0+ (MNG-6109)
|
||||
* For some integration-tests this is not an issue, they can reduce this spec.
|
||||
*/
|
||||
@Parameter( readonly = true )
|
||||
private String pluginXmlSpec = "(3.3.9,)";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
|
@ -250,19 +266,22 @@ public class PluginReport
|
|||
private PluginDescriptor extractPluginDescriptor()
|
||||
throws MavenReportException
|
||||
{
|
||||
PluginDescriptorBuilder builder = new PluginDescriptorBuilder();
|
||||
try
|
||||
if ( usePluginXml() )
|
||||
{
|
||||
return builder.build( new FileReader( new File( project.getBuild().getOutputDirectory(),
|
||||
"META-INF/maven/plugin.xml" ) ) );
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
getLog().debug( "Failed to read META-INF/maven/plugin.xml, fall back to mojoScanner" );
|
||||
}
|
||||
catch ( PlexusConfigurationException e )
|
||||
{
|
||||
getLog().debug( "Failed to read META-INF/maven/plugin.xml, fall back to mojoScanner" );
|
||||
PluginDescriptorBuilder builder = new PluginDescriptorBuilder();
|
||||
try
|
||||
{
|
||||
return builder.build( new FileReader( new File( project.getBuild().getOutputDirectory(),
|
||||
"META-INF/maven/plugin.xml" ) ) );
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
getLog().debug( "Failed to read META-INF/maven/plugin.xml, fall back to mojoScanner" );
|
||||
}
|
||||
catch ( PlexusConfigurationException e )
|
||||
{
|
||||
getLog().debug( "Failed to read META-INF/maven/plugin.xml, fall back to mojoScanner" );
|
||||
}
|
||||
}
|
||||
|
||||
// Copy from AbstractGeneratorMojo#execute()
|
||||
|
|
@ -319,6 +338,19 @@ public class PluginReport
|
|||
return pluginDescriptor;
|
||||
}
|
||||
|
||||
private boolean usePluginXml()
|
||||
{
|
||||
try
|
||||
{
|
||||
VersionRange versionRange = VersionRange.createFromVersionSpec( pluginXmlSpec );
|
||||
return versionRange.containsVersion( rtInfo.getApplicationVersion() );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue