Author: jdcasey
Date: Thu May 31 10:29:02 2007
New Revision: 543188
URL: http://svn.apache.org/viewvc?view=rev&rev=543188
Log:
Reverting changes to IdeUtils, since the problem with ClassCastException on
plugin.getConfiguration() is fixed in maven trunk.
Modified:
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java
Modified:
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java?view=diff&rev=543188&r1=543187&r2=543188
==============================================================================
---
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java
(original)
+++
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/IdeUtils.java
Thu May 31 10:29:02 2007
@@ -32,12 +32,9 @@
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.IOException;
-import java.io.StringReader;
import java.util.Iterator;
import java.util.List;
@@ -75,8 +72,7 @@
*/
private static final String PROPERTY_TARGET = "target"; //$NON-NLS-1$
- public static String getCanonicalPath( final File file )
- throws MojoExecutionException
+ public static String getCanonicalPath( File file ) throws
MojoExecutionException
{
try
{
@@ -96,10 +92,10 @@
* maven project
* @return option value (may be null)
*/
- public static String getCompilerPluginSetting( final MavenProject project,
final String optionName )
+ public static String getCompilerPluginSetting( MavenProject project,
String optionName )
{
String value = findCompilerPluginSettingInPlugins(
project.getModel().getBuild().getPlugins(), optionName );
- if ( ( value == null ) && (
project.getModel().getBuild().getPluginManagement() != null ) )
+ if ( value == null &&
project.getModel().getBuild().getPluginManagement() != null )
{
value =
findCompilerPluginSettingInPlugins(
project.getModel().getBuild().getPluginManagement().getPlugins(),
@@ -116,7 +112,7 @@
* maven project
* @return java source version
*/
- public static String getCompilerSourceVersion( final MavenProject project )
+ public static String getCompilerSourceVersion( MavenProject project )
{
return IdeUtils.getCompilerPluginSetting( project, PROPERTY_SOURCE );
}
@@ -129,7 +125,7 @@
* maven project
* @return java target version
*/
- public static String getCompilerTargetVersion( final MavenProject project )
+ public static String getCompilerTargetVersion( MavenProject project )
{
return IdeUtils.getCompilerPluginSetting( project, PROPERTY_TARGET );
}
@@ -145,7 +141,7 @@
* expected length of the version sub-string
* @return
*/
- public static String getDependencyVersion( final String[] artifactIds,
final List dependencies, final int len )
+ public static String getDependencyVersion( String[] artifactIds, List
dependencies, int len )
{
for ( int j = 0; j < artifactIds.length; j++ )
{
@@ -165,8 +161,8 @@
/**
* @todo there should be a better way to do this
*/
- public static String getPluginSetting( final MavenProject project, final
String artifactId,
- final String optionName, final
String defaultValue )
+ public static String getPluginSetting( MavenProject project, String
artifactId, String optionName,
+ String defaultValue )
{
for ( Iterator it =
project.getModel().getBuild().getPlugins().iterator(); it.hasNext(); )
{
@@ -176,7 +172,7 @@
{
Xpp3Dom o = (Xpp3Dom) plugin.getConfiguration();
- if ( ( o != null ) && ( o.getChild( optionName ) != null ) )
+ if ( o != null && o.getChild( optionName ) != null )
{
return o.getChild( optionName ).getValue();
}
@@ -186,22 +182,20 @@
return defaultValue;
}
- public static String getProjectName( final IdeDependency dep, final
boolean addVersionToProjectName )
+ public static String getProjectName( IdeDependency dep, boolean
addVersionToProjectName )
{
return getProjectName( dep.getArtifactId(), dep.getVersion(),
addVersionToProjectName );
}
- public static String getProjectName( final MavenProject project, final
boolean addVersionToProjectName )
+ public static String getProjectName( MavenProject project, boolean
addVersionToProjectName )
{
return getProjectName( project.getArtifactId(), project.getVersion(),
addVersionToProjectName );
}
- public static Artifact resolveArtifactWithClassifier( final String
groupId, final String artifactId,
- final String
version, final String classifier,
- final
ArtifactRepository localRepository,
- final
ArtifactResolver artifactResolver,
- final
ArtifactFactory artifactFactory,
- final List
remoteRepos, final Log log )
+ public static Artifact resolveArtifactWithClassifier( String groupId,
String artifactId, String version,
+ String classifier,
ArtifactRepository localRepository,
+ ArtifactResolver
artifactResolver,
+ ArtifactFactory
artifactFactory, List remoteRepos, Log log )
{
String type = classifier;
@@ -237,7 +231,7 @@
/**
* @deprecated Use [EMAIL PROTECTED]
JeeUtils#resolveEjbVersion(MavenProject)} instead
*/
- public static String resolveEjbVersion( final MavenProject project )
+ public static String resolveEjbVersion( MavenProject project )
{
return JeeUtils.resolveEjbVersion( project );
}
@@ -245,12 +239,12 @@
/**
* @deprecated Use [EMAIL PROTECTED]
JeeUtils#resolveJeeVersion(MavenProject)} instead
*/
- public static String resolveJ2eeVersion( final MavenProject project )
+ public static String resolveJ2eeVersion( MavenProject project )
{
return JeeUtils.resolveJeeVersion( project );
}
- public static String resolveJavaVersion( final MavenProject project )
+ public static String resolveJavaVersion( MavenProject project )
{
String version = IdeUtils.getCompilerTargetVersion( project );
if ( version == null )
@@ -258,32 +252,31 @@
version = IdeUtils.getCompilerSourceVersion( project );
}
- if ( "1.5".equals( version ) ) //$NON-NLS-1$
+ if ( "1.5".equals( version ) ) //$NON-NLS-1$ //$NON-NLS-2$
{
- version = IdeUtils.JAVA_5_0;// see MECLIPSE-47 eclipse only accept
5.0 as a valid version
+ version = IdeUtils.JAVA_5_0;// see MECLIPSE-47 eclipse only accept
5.0 as a valid version //$NON-NLS-1$
}
- else if ( "1.6".equals( version ) ) //$NON-NLS-1$
+ else if ( "1.6".equals( version ) ) //$NON-NLS-1$ //$NON-NLS-2$
{
version = IdeUtils.JAVA_6_0;
}
- else if ( ( version != null ) && ( version.length() == 1 ) )
+ else if ( version != null && version.length() == 1 )
{
version = version + ".0";// 5->5.0 6->6.0 7->7.0 //$NON-NLS-1$
}
- return version == null ? IdeUtils.JAVA_1_4 : version;
+ return version == null ? IdeUtils.JAVA_1_4 : version; //$NON-NLS-1$
}
/**
* @deprecated Use [EMAIL PROTECTED]
JeeUtils#resolveServletVersion(MavenProject)} instead
*/
- public static String resolveServletVersion( final MavenProject project )
+ public static String resolveServletVersion( MavenProject project )
{
return JeeUtils.resolveServletVersion( project );
}
- public static String toRelativeAndFixSeparator( final File basedir, final
File fileToAdd,
- final boolean
replaceSlashesWithDashes )
+ public static String toRelativeAndFixSeparator( File basedir, File
fileToAdd, boolean replaceSlashesWithDashes )
throws MojoExecutionException
{
String basedirpath;
@@ -325,7 +318,7 @@
* maven project
* @return option value (may be null)
*/
- private static String findCompilerPluginSettingInPlugins( final List
plugins, final String optionName )
+ private static String findCompilerPluginSettingInPlugins( List plugins,
String optionName )
{
String value = null;
@@ -335,33 +328,10 @@
if ( plugin.getArtifactId().equals( ARTIFACT_MAVEN_COMPILER_PLUGIN
) )
{
- Xpp3Dom o;
- try
- {
- o = Xpp3DomBuilder.build( new StringReader(
plugin.getConfiguration().toString() ) );
- }
- catch ( XmlPullParserException e )
- {
- IllegalStateException error =
- new IllegalStateException( "Failed to read
configuration for plugin: "
- + plugin.getKey() );
- error.initCause( e );
-
- throw error;
- }
- catch ( IOException e )
- {
- IllegalStateException error =
- new IllegalStateException( "Failed to read
configuration for plugin: "
- + plugin.getKey() );
- error.initCause( e );
-
- throw error;
- }
-
+ Xpp3Dom o = (Xpp3Dom) plugin.getConfiguration();
// this is the default setting
- if ( ( o != null ) && ( o.getChild( optionName ) != null ) )
+ if ( o != null && o.getChild( optionName ) != null )
{
value = o.getChild( optionName ).getValue();
}
@@ -372,35 +342,9 @@
for ( Iterator iter = executions.iterator(); iter.hasNext(); )
{
PluginExecution execution = (PluginExecution) iter.next();
+ o = (Xpp3Dom) execution.getConfiguration();
- // round-trip this configuration through a String, so that
- // any plexus-utils shading that may happen in future maven
- // releases will not cause a ClassCastException on Xpp3Dom.
- String config = String.valueOf(
execution.getConfiguration() );
- try
- {
- o = Xpp3DomBuilder.build( new StringReader( config ) );
- }
- catch ( XmlPullParserException e )
- {
- IllegalStateException error =
- new IllegalStateException( "Failed to read
configuration for plugin-execution: "
- + plugin.getKey() + ":"
+ execution.getId() );
- error.initCause( e );
-
- throw error;
- }
- catch ( IOException e )
- {
- IllegalStateException error =
- new IllegalStateException( "Failed to read
configuration for plugin-execution: "
- + plugin.getKey() + ":"
+ execution.getId() );
- error.initCause( e );
-
- throw error;
- }
-
- if ( ( o != null ) && ( o.getChild( optionName ) != null )
)
+ if ( o != null && o.getChild( optionName ) != null )
{
value = o.getChild( optionName ).getValue();
}
@@ -410,8 +354,7 @@
return value;
}
- private static String getProjectName( final String artifactId, final
String version,
- final boolean
addVersionToProjectName )
+ private static String getProjectName( String artifactId, String version,
boolean addVersionToProjectName )
{
if ( addVersionToProjectName )
{