diff --git a/maven-plugin-plugin/src/it/mplugin-191/invoker.properties b/maven-plugin-plugin/src/it/mplugin-191/invoker.properties new file mode 100644 index 0000000..1cfcc19 --- /dev/null +++ b/maven-plugin-plugin/src/it/mplugin-191/invoker.properties @@ -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 compile plugin:report diff --git a/maven-plugin-plugin/src/it/mplugin-191/pom.xml b/maven-plugin-plugin/src/it/mplugin-191/pom.xml new file mode 100644 index 0000000..b6b6356 --- /dev/null +++ b/maven-plugin-plugin/src/it/mplugin-191/pom.xml @@ -0,0 +1,67 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.plugin.its + mplugin-191 + 1.0-SNAPSHOT + maven-plugin + + Verify that plugin-info.html and mojo pages are generated in the correct folder + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + + org.apache.maven.plugins + maven-plugin-plugin + @project.version@ + + true + + + + + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + @project.version@ + + + org.apache.maven + maven-plugin-api + 2.2.1 + + + + \ No newline at end of file diff --git a/maven-plugin-plugin/src/it/mplugin-191/src/main/java/org/apache/maven/plugins/plugin/it/MyMojo.java b/maven-plugin-plugin/src/it/mplugin-191/src/main/java/org/apache/maven/plugins/plugin/it/MyMojo.java new file mode 100644 index 0000000..f6b893c --- /dev/null +++ b/maven-plugin-plugin/src/it/mplugin-191/src/main/java/org/apache/maven/plugins/plugin/it/MyMojo.java @@ -0,0 +1,81 @@ +package org.apache.maven.plugins.plugin.it; + +/* + * 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; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * Goal which touches a timestamp file. + */ +@Mojo(name = "touch", defaultPhase = LifecyclePhase.PROCESS_RESOURCES) +public class MyMojo + extends AbstractMojo +{ + /** + * Location of the file. + */ + @Parameter(defaultValue = "${project.build.directory}", required = true) + 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 + } + } + } + } +} diff --git a/maven-plugin-plugin/src/it/mplugin-191/verify.groovy b/maven-plugin-plugin/src/it/mplugin-191/verify.groovy new file mode 100644 index 0000000..e3f3f46 --- /dev/null +++ b/maven-plugin-plugin/src/it/mplugin-191/verify.groovy @@ -0,0 +1,24 @@ +/* + * 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. + */ + +File pluginInfo = new File( basedir, "target/site/plugin-info.html" ); +assert pluginInfo.isFile() + +File touchMojo = new File( basedir, "target/generated-site/xdoc/touch-mojo.xml" ); +assert touchMojo.isFile() + +return true; diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java index d29587d..ca6742b 100644 --- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java +++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java @@ -71,7 +71,7 @@ public class PluginReport extends AbstractMavenReport { /** - * Report output directory. + * Report output directory for mojo pages. */ @Parameter( defaultValue = "${project.build.directory}/generated-site/xdoc" ) private File outputDirectory; @@ -195,7 +195,8 @@ public class PluginReport */ protected String getOutputDirectory() { - return outputDirectory.getPath(); + // PLUGIN-191: output directory of plugin.html, not *-mojo.xml + return project.getReporting().getOutputDirectory(); } /** @@ -327,7 +328,7 @@ public class PluginReport { try { - File outputDir = new File( getOutputDirectory() ); + File outputDir = outputDirectory; outputDir.mkdirs(); PluginXdocGenerator generator = new PluginXdocGenerator( project, locale );