You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ah...@apache.org on 2007/05/14 23:27:48 UTC
svn commit: r537985 - in
/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin:
eclipse/writers/ eclipse/writers/rad/ ide/
Author: aheritier
Date: Mon May 14 14:27:47 2007
New Revision: 537985
URL: http://svn.apache.org/viewvc?view=rev&rev=537985
Log:
MECLIPSE-268 :Move some useful methods about J2EE in IdeUtils.java to use them in WTP and in RAD
Modified:
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadApplicationXMLWriter.java
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/eclipse/writers/AbstractWtpResourceWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java?view=diff&rev=537985&r1=537984&r2=537985
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java Mon May 14 14:27:47 2007
@@ -27,8 +27,6 @@
import org.codehaus.plexus.util.xml.XMLWriter;
import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
/**
* Base class to hold common constants used by extending classes.
@@ -89,7 +87,7 @@
writer.startElement( ELT_VERSION );
- writer.writeText( resolveServletVersion() );
+ writer.writeText( IdeUtils.resolveServletVersion(project) );
writer.endElement();
// use finalName as context root only if it has been explicitely set
@@ -110,7 +108,7 @@
writer.addAttribute( ATTR_MODULE_TYPE_ID, "jst.ejb" ); //$NON-NLS-1$
writer.startElement( ELT_VERSION );
- writer.writeText( resolveEjbVersion() );
+ writer.writeText( IdeUtils.resolveEjbVersion(project) );
writer.endElement();
@@ -127,7 +125,7 @@
writer.addAttribute( ATTR_MODULE_TYPE_ID, "jst.ear" ); //$NON-NLS-1$
writer.startElement( ELT_VERSION );
- writer.writeText( resolveJ2eeVersion() );
+ writer.writeText( IdeUtils.resolveJ2eeVersion(project) );
writer.endElement();
}
else
@@ -231,140 +229,6 @@
addDependency( writer, dep, localRepository, config.getProject().getBasedir() );
}
}
- }
-
- protected String resolveServletVersion()
- {
- String[] artifactIds = new String[] { "servlet-api", "servletapi", "geronimo-spec-servlet" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- String version = IdeUtils.getDependencyVersion( artifactIds, config.getProject().getDependencies(), 3 );
-
- // For new Geronimo APIs, the version of the artifact isn't the one of the spec
- if ( version == null )
- {
- if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-servlet_2.4_spec" },
- config.getProject().getDependencies(), 3 ) != null )
- return "2.4";
- }
- if ( version == null )
- {
- if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-servlet_2.5_spec" },
- config.getProject().getDependencies(), 3 ) != null )
- return "2.5";
- }
-
- if ( version == null )
- {
- // No servlet dependency detected. Try to resolve the servlet
- // version from J2EE/JEE.
- String versionJEE = resolveJ2eeVersionWithoutDefault();
-
- if ( versionJEE != null )
- {
- // A J2EE version was found, now determine the servlet
- // version to be used from it.
- Map conversionTable = new HashMap();
- conversionTable.put( "1.3", "2.3" );
- conversionTable.put( "1.4", "2.4" );
- conversionTable.put( "5", "2.5" );
- if ( conversionTable.containsKey( versionJEE ) )
- {
- version = (String) conversionTable.get( versionJEE );
- }
- }
- }
- return version == null ? "2.4" : version; //$NON-NLS-1$
- }
-
- protected String resolveEjbVersion()
- {
- String[] artifactIds = new String[] { "ejb", "geronimo-spec-ejb" }; //$NON-NLS-1$
-
- String version = IdeUtils.getDependencyVersion( artifactIds, config.getProject().getDependencies(), 3 );
-
- // For new Geronimo APIs, the version of the artifact isn't the one of the spec
- if ( version == null )
- {
- if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-ejb_2.1_spec" },
- config.getProject().getDependencies(), 3 ) != null )
- return "2.1";
- }
- if ( version == null )
- {
- if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-ejb_3.0_spec" },
- config.getProject().getDependencies(), 3 ) != null )
- return "3.0";
- }
-
- if ( version == null )
- {
- // No ejb dependency detected. Try to resolve the ejb
- // version from J2EE/JEE.
- String versionJEE = resolveJ2eeVersionWithoutDefault();
-
- if ( versionJEE != null )
- {
- // A J2EE version was found, now determine the ejb
- // version to be used from it.
- Map conversionTable = new HashMap();
- conversionTable.put( "1.3", "2.0" );
- conversionTable.put( "1.4", "2.1" );
- conversionTable.put( "5", "3.0" );
- if ( conversionTable.containsKey( versionJEE ) )
- {
- version = (String) conversionTable.get( versionJEE );
- }
- }
- }
- return version == null ? "2.1" : version; //$NON-NLS-1$
- }
-
- protected String resolveJ2eeVersion()
- {
- String version = resolveJ2eeVersionWithoutDefault();
-
- return version == null ? "1.3" : version; //$NON-NLS-1$
- }
-
- protected String resolveJ2eeVersionWithoutDefault()
- {
- String[] artifactIds = new String[] { "javaee-api", "j2ee", "geronimo-spec-j2ee" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- String version = IdeUtils.getDependencyVersion( artifactIds, config.getProject().getDependencies(), 3 );
-
- // For new Geronimo APIs, the version of the artifact isn't the one of the spec
- if ( version == null )
- {
- if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-j2ee_1.4_spec" },
- config.getProject().getDependencies(), 3 ) != null )
- return "1.4";
- }
-
- return version;
- }
-
- protected String resolveJavaVersion()
- {
- String version = IdeUtils.getCompilerTargetVersion( config.getProject() );
- if ( version == null )
- {
- version = IdeUtils.getCompilerSourceVersion( config.getProject() );
- }
-
- if ( "1.5".equals( version ) ) //$NON-NLS-1$ //$NON-NLS-2$
- {
- version = "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$ //$NON-NLS-2$
- {
- version = "6.0";
- }
- 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 ? "1.4" : version; //$NON-NLS-1$
}
}
Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java?view=diff&rev=537985&r1=537984&r2=537985
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java Mon May 14 14:27:47 2007
@@ -26,6 +26,7 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.eclipse.Messages;
+import org.apache.maven.plugin.ide.IdeUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
@@ -120,7 +121,7 @@
writer.endElement(); // fixed
writer.startElement( ELT_INSTALLED );
writer.addAttribute( ATTR_FACET, FACET_JST_WEB );
- writer.addAttribute( ATTR_VERSION, resolveServletVersion() );
+ writer.addAttribute( ATTR_VERSION, IdeUtils.resolveServletVersion(config.getProject()) );
writer.endElement(); // installed
}
else if ( "ejb".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
@@ -130,7 +131,7 @@
writer.endElement(); // fixed
writer.startElement( ELT_INSTALLED );
writer.addAttribute( ATTR_FACET, FACET_JST_EJB );
- writer.addAttribute( ATTR_VERSION, resolveEjbVersion() );
+ writer.addAttribute( ATTR_VERSION, IdeUtils.resolveEjbVersion(config.getProject()) );
writer.endElement(); // installed
}
else if ( "ear".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
@@ -140,7 +141,7 @@
writer.endElement(); // fixed
writer.startElement( ELT_INSTALLED );
writer.addAttribute( ATTR_FACET, FACET_JST_EAR );
- writer.addAttribute( ATTR_VERSION, resolveJ2eeVersion() );
+ writer.addAttribute( ATTR_VERSION, IdeUtils.resolveJ2eeVersion(config.getProject()) );
writer.endElement(); // installed
}
else if ( "jar".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
@@ -157,7 +158,7 @@
// common installed element
writer.startElement( ELT_INSTALLED );
writer.addAttribute( ATTR_FACET, FACET_JST_JAVA );
- writer.addAttribute( ATTR_VERSION, resolveJavaVersion() );
+ writer.addAttribute( ATTR_VERSION, IdeUtils.resolveJavaVersion(config.getProject()) );
writer.endElement(); // installed
writeAdditionalProjectFacets( writer );
Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadApplicationXMLWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadApplicationXMLWriter.java?view=diff&rev=537985&r1=537984&r2=537985
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadApplicationXMLWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadApplicationXMLWriter.java Mon May 14 14:27:47 2007
@@ -41,7 +41,7 @@
/**
* This writer creates the application.xml and the .modulemaps files for RAD6
- * the the META-INF directory in the project root. this is where RAD6 requires
+ * in the META-INF directory in the project root. this is where RAD6 requires
* the files to be. These will be independent of the real application.xml witch
* will be generated the stad. maven way.
*
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=537985&r1=537984&r2=537985
==============================================================================
--- 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 Mon May 14 14:27:47 2007
@@ -35,8 +35,10 @@
import java.io.File;
import java.io.IOException;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
@@ -51,19 +53,14 @@
private static final String ARTIFACT_MAVEN_COMPILER_PLUGIN = "maven-compiler-plugin"; //$NON-NLS-1$
/**
- * 'target' property for maven-compiler-plugin.
- */
- private static final String PROPERTY_TARGET = "target"; //$NON-NLS-1$
-
- /**
* 'source' property for maven-compiler-plugin.
*/
private static final String PROPERTY_SOURCE = "source"; //$NON-NLS-1$
- private IdeUtils()
- {
- // don't instantiate
- }
+ /**
+ * 'target' property for maven-compiler-plugin.
+ */
+ private static final String PROPERTY_TARGET = "target"; //$NON-NLS-1$
public static String getCanonicalPath( File file )
throws MojoExecutionException
@@ -78,62 +75,69 @@
.getAbsolutePath() ), e );
}
}
-
- public static String getProjectName( MavenProject project, boolean addVersionToProjectName )
+
+ /**
+ * Returns a compiler plugin settings, considering also settings altered in plugin executions .
+ * @param project maven project
+ * @return option value (may be null)
+ */
+ public static String getCompilerPluginSetting( MavenProject project, String optionName )
{
- return getProjectName( project.getArtifactId(), project.getVersion(), addVersionToProjectName );
+ String value = findCompilerPluginSettingInPlugins( project.getModel().getBuild().getPlugins(), optionName );
+ if ( value == null && project.getModel().getBuild().getPluginManagement() != null )
+ {
+ value =
+ findCompilerPluginSettingInPlugins( project.getModel().getBuild().getPluginManagement().getPlugins(),
+ optionName );
+ }
+ return value;
}
- public static String getProjectName( IdeDependency dep, boolean addVersionToProjectName )
+ /**
+ * Returns the source version configured for the compiler plugin. Returns the minimum version required to compile
+ * both standard and test sources, if settings are different.
+ * @param project maven project
+ * @return java source version
+ */
+ public static String getCompilerSourceVersion( MavenProject project )
{
- return getProjectName( dep.getArtifactId(), dep.getVersion(), addVersionToProjectName );
+ return IdeUtils.getCompilerPluginSetting( project, PROPERTY_SOURCE );
}
- private static String getProjectName( String artifactId, String version, boolean addVersionToProjectName )
+ /**
+ * Returns the target version configured for the compiler plugin. Returns the minimum version required to compile
+ * both standard and test sources, if settings are different.
+ * @param project maven project
+ * @return java target version
+ */
+ public static String getCompilerTargetVersion( MavenProject project )
{
- if( addVersionToProjectName )
- {
- return artifactId + '-' + version;
- }
- else
- {
- return artifactId;
- }
+ return IdeUtils.getCompilerPluginSetting( project, PROPERTY_TARGET );
}
-
- public static String toRelativeAndFixSeparator( File basedir, File fileToAdd, boolean replaceSlashesWithDashes )
- throws MojoExecutionException
+
+ /**
+ * Extracts the version of the first matching dependency in the given list.
+ *
+ * @param artifactIds artifact names to compare against for extracting version
+ * @param dependencies Collection of dependencies for our project
+ * @param len expected length of the version sub-string
+ * @return
+ */
+ public static String getDependencyVersion( String[] artifactIds, List dependencies, int len )
{
- String basedirpath;
- String absolutePath;
-
- basedirpath = getCanonicalPath( basedir );
- absolutePath = getCanonicalPath( fileToAdd );
-
- String relative;
-
- if ( absolutePath.equals( basedirpath ) )
- {
- relative = "."; //$NON-NLS-1$
- }
- else if ( absolutePath.startsWith( basedirpath ) )
- {
- relative = absolutePath.substring( basedirpath.length() + 1 );
- }
- else
- {
- relative = absolutePath;
- }
-
- relative = StringUtils.replace( relative, '\\', '/' );
-
- if ( replaceSlashesWithDashes )
+ for ( int j = 0; j < artifactIds.length; j++ )
{
- relative = StringUtils.replace( relative, '/', '-' );
- relative = StringUtils.replace( relative, ':', '-' ); // remove ":" for absolute paths in windows
+ String id = artifactIds[j];
+ for ( Iterator itr = dependencies.iterator(); itr.hasNext(); )
+ {
+ Dependency dependency = (Dependency) itr.next();
+ if ( id.equals( dependency.getArtifactId() ) )
+ {
+ return StringUtils.substring( dependency.getVersion(), 0, len );
+ }
+ }
}
-
- return relative;
+ return null;
}
/**
@@ -160,6 +164,16 @@
return defaultValue;
}
+ public static String getProjectName( IdeDependency dep, boolean addVersionToProjectName )
+ {
+ return getProjectName( dep.getArtifactId(), dep.getVersion(), addVersionToProjectName );
+ }
+
+ public static String getProjectName( MavenProject project, boolean addVersionToProjectName )
+ {
+ return getProjectName( project.getArtifactId(), project.getVersion(), addVersionToProjectName );
+ }
+
public static Artifact resolveArtifactWithClassifier( String groupId, String artifactId, String version,
String classifier, ArtifactRepository localRepository,
ArtifactResolver artifactResolver,
@@ -196,70 +210,175 @@
return resolvedArtifact;
}
- /**
- * Extracts the version of the first matching dependency in the given list.
- *
- * @param artifactIds artifact names to compare against for extracting version
- * @param dependencies Collection of dependencies for our project
- * @param len expected length of the version sub-string
- * @return
- */
- public static String getDependencyVersion( String[] artifactIds, List dependencies, int len )
+ public static String resolveEjbVersion(MavenProject project)
{
- for ( int j = 0; j < artifactIds.length; j++ )
+ String[] artifactIds = new String[] { "ejb", "geronimo-spec-ejb" }; //$NON-NLS-1$
+
+ String version = IdeUtils.getDependencyVersion( artifactIds, project.getDependencies(), 3 );
+
+ // For new Geronimo APIs, the version of the artifact isn't the one of the spec
+ if ( version == null )
{
- String id = artifactIds[j];
- for ( Iterator itr = dependencies.iterator(); itr.hasNext(); )
+ if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-ejb_2.1_spec" },
+ project.getDependencies(), 3 ) != null )
+ return "2.1";
+ }
+ if ( version == null )
+ {
+ if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-ejb_3.0_spec" },
+ project.getDependencies(), 3 ) != null )
+ return "3.0";
+ }
+
+ if ( version == null )
+ {
+ // No ejb dependency detected. Try to resolve the ejb
+ // version from J2EE/JEE.
+ String versionJEE = resolveJ2eeVersionWithoutDefault(project);
+
+ if ( versionJEE != null )
{
- Dependency dependency = (Dependency) itr.next();
- if ( id.equals( dependency.getArtifactId() ) )
+ // A J2EE version was found, now determine the ejb
+ // version to be used from it.
+ Map conversionTable = new HashMap();
+ conversionTable.put( "1.3", "2.0" );
+ conversionTable.put( "1.4", "2.1" );
+ conversionTable.put( "5", "3.0" );
+ if ( conversionTable.containsKey( versionJEE ) )
{
- return StringUtils.substring( dependency.getVersion(), 0, len );
+ version = (String) conversionTable.get( versionJEE );
}
}
}
- return null;
+ return version == null ? "2.1" : version; //$NON-NLS-1$
}
- /**
- * Returns the target version configured for the compiler plugin. Returns the minimum version required to compile
- * both standard and test sources, if settings are different.
- * @param project maven project
- * @return java target version
- */
- public static String getCompilerTargetVersion( MavenProject project )
+ public static String resolveJ2eeVersion(MavenProject project)
{
- return IdeUtils.getCompilerPluginSetting( project, PROPERTY_TARGET );
+ String version = resolveJ2eeVersionWithoutDefault(project);
+
+ return version == null ? "1.3" : version; //$NON-NLS-1$
}
- /**
- * Returns the source version configured for the compiler plugin. Returns the minimum version required to compile
- * both standard and test sources, if settings are different.
- * @param project maven project
- * @return java source version
- */
- public static String getCompilerSourceVersion( MavenProject project )
+ public static String resolveJ2eeVersionWithoutDefault(MavenProject project)
{
- return IdeUtils.getCompilerPluginSetting( project, PROPERTY_SOURCE );
+ String[] artifactIds = new String[] { "javaee-api", "j2ee", "geronimo-spec-j2ee" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ String version = IdeUtils.getDependencyVersion( artifactIds, project.getDependencies(), 3 );
+
+ // For new Geronimo APIs, the version of the artifact isn't the one of the spec
+ if ( version == null )
+ {
+ if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-j2ee_1.4_spec" },
+ project.getDependencies(), 3 ) != null )
+ return "1.4";
+ }
+
+ return version;
}
-
- /**
- * Returns a compiler plugin settings, considering also settings altered in plugin executions .
- * @param project maven project
- * @return option value (may be null)
- */
- public static String getCompilerPluginSetting( MavenProject project, String optionName )
+
+ public static String resolveJavaVersion(MavenProject project)
{
- String value = findCompilerPluginSettingInPlugins( project.getModel().getBuild().getPlugins(), optionName );
- if ( value == null && project.getModel().getBuild().getPluginManagement() != null )
+ String version = IdeUtils.getCompilerTargetVersion( project );
+ if ( version == null )
{
- value =
- findCompilerPluginSettingInPlugins( project.getModel().getBuild().getPluginManagement().getPlugins(),
- optionName );
+ version = IdeUtils.getCompilerSourceVersion( project );
}
- return value;
+
+ if ( "1.5".equals( version ) ) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ version = "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$ //$NON-NLS-2$
+ {
+ version = "6.0";
+ }
+ 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 ? "1.4" : version; //$NON-NLS-1$
}
+
+ public static String resolveServletVersion(MavenProject project)
+ {
+ String[] artifactIds = new String[] { "servlet-api", "servletapi", "geronimo-spec-servlet" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ String version = IdeUtils.getDependencyVersion( artifactIds, project.getDependencies(), 3 );
+
+ // For new Geronimo APIs, the version of the artifact isn't the one of the spec
+ if ( version == null )
+ {
+ if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-servlet_2.4_spec" },
+ project.getDependencies(), 3 ) != null )
+ return "2.4";
+ }
+ if ( version == null )
+ {
+ if ( IdeUtils.getDependencyVersion( new String[] { "geronimo-servlet_2.5_spec" },
+ project.getDependencies(), 3 ) != null )
+ return "2.5";
+ }
+
+ if ( version == null )
+ {
+ // No servlet dependency detected. Try to resolve the servlet
+ // version from J2EE/JEE.
+ String versionJEE = resolveJ2eeVersionWithoutDefault(project);
+ if ( versionJEE != null )
+ {
+ // A J2EE version was found, now determine the servlet
+ // version to be used from it.
+ Map conversionTable = new HashMap();
+ conversionTable.put( "1.3", "2.3" );
+ conversionTable.put( "1.4", "2.4" );
+ conversionTable.put( "5", "2.5" );
+ if ( conversionTable.containsKey( versionJEE ) )
+ {
+ version = (String) conversionTable.get( versionJEE );
+ }
+ }
+ }
+ return version == null ? "2.4" : version; //$NON-NLS-1$
+ }
+
+ public static String toRelativeAndFixSeparator( File basedir, File fileToAdd, boolean replaceSlashesWithDashes )
+ throws MojoExecutionException
+ {
+ String basedirpath;
+ String absolutePath;
+
+ basedirpath = getCanonicalPath( basedir );
+ absolutePath = getCanonicalPath( fileToAdd );
+
+ String relative;
+
+ if ( absolutePath.equals( basedirpath ) )
+ {
+ relative = "."; //$NON-NLS-1$
+ }
+ else if ( absolutePath.startsWith( basedirpath ) )
+ {
+ relative = absolutePath.substring( basedirpath.length() + 1 );
+ }
+ else
+ {
+ relative = absolutePath;
+ }
+
+ relative = StringUtils.replace( relative, '\\', '/' );
+
+ if ( replaceSlashesWithDashes )
+ {
+ relative = StringUtils.replace( relative, '/', '-' );
+ relative = StringUtils.replace( relative, ':', '-' ); // remove ":" for absolute paths in windows
+ }
+
+ return relative;
+ }
+
/**
* Returns a compiler plugin settings from a list of plugins .
* @param project maven project
@@ -299,5 +418,22 @@
}
}
return value;
+ }
+
+ private static String getProjectName( String artifactId, String version, boolean addVersionToProjectName )
+ {
+ if( addVersionToProjectName )
+ {
+ return artifactId + '-' + version;
+ }
+ else
+ {
+ return artifactId;
+ }
+ }
+
+ private IdeUtils()
+ {
+ // don't instantiate
}
}