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/11/09 13:24:19 UTC

svn commit: r593509 - in /maven/plugins/branches/MECLIPSE-333/src: main/java/org/apache/maven/plugin/eclipse/writers/ main/java/org/apache/maven/plugin/eclipse/writers/wtp/ test/java/org/apache/maven/plugin/eclipse/ test/resources/projects/project-05/e...

Author: aheritier
Date: Fri Nov  9 04:24:19 2007
New Revision: 593509

URL: http://svn.apache.org/viewvc?rev=593509&view=rev
Log:
Apply patcMECLIPSE-333 : WTP-2.0 support with howto apt, refactoring and contextroot handling
Applied :
wtp-2.0-and-more-2.5-SNAPSHOT-2.patch

Modified:
    maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
    maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/AbstractWtpResourceWriter.java
    maven/plugins/branches/MECLIPSE-333/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java
    maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-05/expected/.wtpmodules
    maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-35/multymodule-ear/pom.xml

Modified: maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java?rev=593509&r1=593508&r2=593509&view=diff
==============================================================================
--- maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java (original)
+++ maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java Fri Nov  9 04:24:19 2007
@@ -33,6 +33,7 @@
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.eclipse.BuildCommand;
+import org.apache.maven.plugin.eclipse.Constants;
 import org.apache.maven.plugin.eclipse.EclipseSourceDir;
 import org.apache.maven.plugin.eclipse.Messages;
 import org.apache.maven.plugin.ide.IdeDependency;
@@ -488,8 +489,9 @@
 
         }
 
-        if ( config.getWtpapplicationxml() && kind.equals( ATTR_VAR ) && !dep.isTestDependency() && !dep.isProvided() &&
-            !dep.isSystemScoped() )
+        if ( Constants.PROJECT_PACKAGING_WAR.equals( this.config.getPackaging() ) && config.getWtpapplicationxml()
+            && kind.equals( ATTR_VAR ) && !dep.isTestDependency() && !dep.isProvided()
+            && !dep.isSystemScopedOutsideProject( this.config.getProject() ) )
         {
             if ( !attributeElemOpen )
             {

Modified: maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/AbstractWtpResourceWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/AbstractWtpResourceWriter.java?rev=593509&r1=593508&r2=593509&view=diff
==============================================================================
--- maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/AbstractWtpResourceWriter.java (original)
+++ maven/plugins/branches/MECLIPSE-333/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/AbstractWtpResourceWriter.java Fri Nov  9 04:24:19 2007
@@ -154,6 +154,14 @@
     {
         String handle;
         String dependentObject = null;
+        String archiveName;
+
+        // ejb's and wars must always eb toplevel
+        if ( Constants.PROJECT_PACKAGING_WAR.equals( dep.getType() )
+            || Constants.PROJECT_PACKAGING_EJB.equals( dep.getType() ) )
+        {
+            deployPath = "/";
+        }
 
         if ( dep.isReferencedProject() )
         {
@@ -171,6 +179,7 @@
             {
                 dependentObject = "WebModule_";
             }
+            archiveName = dep.getEclipseProjectName() + "." + dep.getType();
         }
         else
         {
@@ -204,11 +213,22 @@
                     +
                     IdeUtils.toRelativeAndFixSeparator( localRepositoryFile, repoFile, false );
             }
+            if ( Constants.PROJECT_PACKAGING_EAR.equals( this.config.getPackaging() ) && !"/".equals( deployPath ) )
+            {
+                // This is a very ugly hack around a WTP bug! a delpoydir in the configuration file is duplicated.
+                // a deploy dir like "lib" will be used as "lib/lib" the only workig workaround is to include a ..
+                // in the archive name.
+                archiveName = "../" + artifactPath.getName();
+            }
+            else
+            {
+                archiveName = artifactPath.getName();
+            }
         }
 
         writer.startElement( ELT_DEPENDENT_MODULE );
 
-        writer.addAttribute( "archiveName", dep.getEclipseProjectName() + "." + dep.getType() );
+        writer.addAttribute( "archiveName", archiveName );
 
         writer.addAttribute( ATTR_DEPLOY_PATH, deployPath ); //$NON-NLS-1$
         writer.addAttribute( ATTR_HANDLE, handle );

Modified: maven/plugins/branches/MECLIPSE-333/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MECLIPSE-333/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java?rev=593509&r1=593508&r2=593509&view=diff
==============================================================================
--- maven/plugins/branches/MECLIPSE-333/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java (original)
+++ maven/plugins/branches/MECLIPSE-333/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java Fri Nov  9 04:24:19 2007
@@ -387,6 +387,33 @@
 
         checkContextRoot( basedir, "multymodule-war", "multymodule-ear", "/somethingVeryDifferent" );
 
+        FileReader reader =
+            new FileReader( new File( basedir, "multymodule-war/.settings/org.eclipse.wst.common.component" ) );
+        Xpp3Dom warComponent = Xpp3DomBuilder.build( reader );
+        Xpp3Dom[] dependentModules = warComponent.getChild( "wb-module" ).getChildren( "dependent-module" );
+        assertEquals( 2, dependentModules.length );
+        for ( int index = 0; index < dependentModules.length; index++ )
+        {
+            assertEquals( "/WEB-INF/lib", dependentModules[index].getAttribute( "deploy-path" ) );
+        }
+                     
+        reader = new FileReader( new File( basedir, "multymodule-ear/.settings/org.eclipse.wst.common.component" ) );
+        Xpp3Dom earComponent = Xpp3DomBuilder.build( reader );
+        dependentModules = earComponent.getChild( "wb-module" ).getChildren( "dependent-module" );
+        assertEquals( 2, dependentModules.length );
+        for ( int index = 0; index < dependentModules.length; index++ )
+        {
+            if ( dependentModules[index].getAttribute( "archiveName" ).endsWith( "war" ) )
+            {
+                assertEquals( "/", dependentModules[index].getAttribute( "deploy-path" ) );
+                assertTrue( !dependentModules[index].getAttribute( "archiveName" ).startsWith( ".." ) );
+            }
+            else
+            {
+                assertEquals( "lib", dependentModules[index].getAttribute( "deploy-path" ) );
+                assertTrue( dependentModules[index].getAttribute( "archiveName" ).startsWith( ".." ) );
+            }
+        }
     }
 
     private void checkContextRoot( File basedir, String warModule, String earModule, String expectedContextRoot )

Modified: maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-05/expected/.wtpmodules
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-05/expected/.wtpmodules?rev=593509&r1=593508&r2=593509&view=diff
==============================================================================
--- maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-05/expected/.wtpmodules (original)
+++ maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-05/expected/.wtpmodules Fri Nov  9 04:24:19 2007
@@ -5,7 +5,7 @@
       <property name="context-root" value="contextName"/>
     </module-type>
     <wb-resource deploy-path="/" source-path="/src/main/webapp"/>
-    <dependent-module archiveName="maven-core.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/maven/maven-core/98.0/maven-core-98.0.jar">
+    <dependent-module archiveName="maven-core-98.0.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/maven/maven-core/98.0/maven-core-98.0.jar">
       <dependency-type>uses</dependency-type>
     </dependent-module>
     <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>

Modified: maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-35/multymodule-ear/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-35/multymodule-ear/pom.xml?rev=593509&r1=593508&r2=593509&view=diff
==============================================================================
--- maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-35/multymodule-ear/pom.xml (original)
+++ maven/plugins/branches/MECLIPSE-333/src/test/resources/projects/project-35/multymodule-ear/pom.xml Fri Nov  9 04:24:19 2007
@@ -36,5 +36,10 @@
 			<version>1.0</version>
 			<type>war</type>
 		</dependency>
+		<dependency>
+			<groupId>maven</groupId>
+			<artifactId>maven-core</artifactId>
+			<version>98.0</version>
+		</dependency>
 	</dependencies>
 </project>