[MPLUGIN-177] Required JDK incorrectly specified if using default for m-compiler-p

o if the target isn't there, refer the reader to the compiler plugin. Don't try to 
maintain a list of default versions for compiler plugin versions, and never say '1.1'.


git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1164584 13f79535-47bb-0310-9956-ffa450edef68
master
Benson Margulies 2011-09-02 15:38:56 +00:00
parent 2a9baa7354
commit 89be0cfb89
4 changed files with 163 additions and 5 deletions

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.its</groupId>
<artifactId>jdk-default-version</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>
<!--
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
-->
</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>
</plugin>
<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,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
}
}
}
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
<body>
<menu name="Overview">
<item name="Goals" href="plugin-info.html"/>
</menu>
<menu ref="reports" inherit="bottom" />
</body>
</project>

View File

@ -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;
}
}
}
}