diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/pom.xml b/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/pom.xml new file mode 100644 index 0000000..18b0a36 --- /dev/null +++ b/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + org.apache.maven.its + jdk-default-version + 1.0-SNAPSHOT + maven-plugin + + UTF-8 + + + + org.apache.maven + maven-plugin-api + 2.0 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + + org.apache.maven.plugins + maven-plugin-plugin + @project.version@ + + + org.apache.maven.plugins + maven-site-plugin + @sitePluginVersion@ + + + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.4 + + + org.apache.maven.plugins + maven-plugin-plugin + @project.version@ + + + + diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/src/main/java/org/apache/maven/plugins/issues/plugin/MyMojo.java b/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/src/main/java/org/apache/maven/plugins/issues/plugin/MyMojo.java new file mode 100644 index 0000000..3f2d827 --- /dev/null +++ b/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/src/main/java/org/apache/maven/plugins/issues/plugin/MyMojo.java @@ -0,0 +1,81 @@ +package org.apache.maven.plugins.issues.plugin; + +/* + * 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 + * + * @phase process-sources + */ +public class MyMojo + extends AbstractMojo +{ + /** + * Location of the file. + * @parameter expression="${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 + } + } + } + } +} diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/src/site/site.xml b/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/src/site/site.xml new file mode 100644 index 0000000..7821e34 --- /dev/null +++ b/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/src/site/site.xml @@ -0,0 +1,10 @@ + + + + + + + + + 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 9fdb3cf..1044800 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 @@ -615,8 +615,7 @@ public class PluginReport } if ( jdk == null ) { - // The Maven Compiler Plugin uses a fixed default value, not the current JDK version. - jdk = "1.1"; + jdk = "Unknown"; } return jdk; @@ -635,6 +634,7 @@ public class PluginReport } String jdk = null; + String backupJdk = null; for ( Iterator it = pluginsAsMap.keySet().iterator(); it.hasNext(); ) { String key = it.next().toString(); @@ -647,17 +647,18 @@ public class PluginReport Object value = pluginsAsMap.get( key ); Xpp3Dom pluginConf = null; + backupJdk = "Default version for maven-compiler-plugin"; if ( value instanceof Plugin ) { Plugin plugin = (Plugin) value; - + backupJdk = "Default target for maven-compiler-plugin version " + plugin.getVersion(); pluginConf = (Xpp3Dom) plugin.getConfiguration(); } if ( value instanceof ReportPlugin ) { ReportPlugin reportPlugin = (ReportPlugin) value; - + backupJdk = "Default target for maven-compiler-plugin version " + reportPlugin.getVersion(); pluginConf = (Xpp3Dom) reportPlugin.getConfiguration(); } @@ -674,7 +675,14 @@ public class PluginReport jdk = pluginConf.getChild( "target" ).getValue(); } - return jdk; + if ( jdk == null ) + { + return backupJdk; + } + else + { + return jdk; + } } } }