Author: aheritier
Date: Mon Nov 26 22:53:06 2007
New Revision: 598528

URL: http://svn.apache.org/viewvc?rev=598528&view=rev
Log:
[MECLIPSE-357] RadManifestWriter uses hardcoded web application source directory
Submitted by: Siarhei Dudzin

Added:
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-rad-7/expected/WebContent/META-INF/
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-rad-7/expected/WebContent/META-INF/MANIFEST.MF
Modified:
    
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/RadCleanMojo.java
    
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/RadPluginTest.java

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/RadCleanMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/RadCleanMojo.java?rev=598528&r1=598527&r2=598528&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/RadCleanMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/RadCleanMojo.java
 Mon Nov 26 22:53:06 2007
@@ -21,6 +21,8 @@
 import java.io.File;
 
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.ide.IdeUtils;
+import org.apache.maven.plugin.ide.JeeUtils;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.FileUtils;
 
@@ -111,9 +113,19 @@
     private void handleWarLibs()
         throws MojoExecutionException
     {
+       File basedir = this.project.getBasedir();
+       
+        File warSourceDirectory =
+            new File( IdeUtils.getPluginSetting( this.project, 
JeeUtils.ARTIFACT_MAVEN_WAR_PLUGIN,
+                                                 "warSourceDirectory", 
//$NON-NLS-1$
+                                                 "src/main/webapp" ) ); 
//$NON-NLS-1$
+        
+        String webContentDir = IdeUtils.toRelativeAndFixSeparator( basedir,
+                warSourceDirectory, false );
+       
         String srcMainWebappWebInfLibDirname =
-            this.project.getBasedir().getAbsolutePath() + File.separatorChar + 
"src" + File.separatorChar + "main" +
-                File.separatorChar + "webapp" + File.separatorChar + "WEB-INF" 
+ File.separatorChar + "lib";
+               basedir.getAbsolutePath() + File.separatorChar + webContentDir 
+ 
+               File.separatorChar + "WEB-INF" + File.separatorChar + "lib";
 
         File srcMainWebappWebInfLibDir = new File( 
srcMainWebappWebInfLibDirname );
         srcMainWebappWebInfLibDir.mkdirs();
@@ -122,7 +134,7 @@
     }
 
     /**
-     * delete all Jar artifacts in the spedified directory.
+     * delete all Jar artifacts in the specified directory.
      * 
      * @param directory to delete the jars from
      * @throws MojoExecutionException only if a file exists and can't be 
deleted

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java?rev=598528&r1=598527&r2=598528&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java
 Mon Nov 26 22:53:06 2007
@@ -38,6 +38,8 @@
 import org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter;
 import org.apache.maven.plugin.eclipse.writers.wtp.AbstractWtpResourceWriter;
 import org.apache.maven.plugin.ide.IdeDependency;
+import org.apache.maven.plugin.ide.IdeUtils;
+import org.apache.maven.plugin.ide.JeeUtils;
 import org.apache.maven.project.MavenProject;
 
 /**
@@ -56,22 +58,33 @@
 
     private static final String META_INF_DIRECTORY = "META-INF";
 
-    private static final String WEBAPP_RESOURCE_DIR =
+    private static final String DEFAULT_WEBAPP_RESOURCE_DIR =
         "src" + File.separatorChar + "main" + File.separatorChar + "webapp";
 
     /**
      * Search the project for the existing META-INF directory where the 
manifest should be located.
      * 
      * @return the apsolute path to the META-INF directory
+     * @throws MojoExecutionException 
      */
-    private String getMetaInfBaseDirectory( MavenProject project )
+    private String getMetaInfBaseDirectory( MavenProject project ) throws 
MojoExecutionException
     {
         String metaInfBaseDirectory = null;
 
         if ( config.getProject().getPackaging().equals( 
Constants.PROJECT_PACKAGING_WAR ) )
         {
+            // Generating web content settings based on war plug-in 
warSourceDirectory property 
+            File warSourceDirectory =
+                new File( IdeUtils.getPluginSetting( config.getProject(), 
JeeUtils.ARTIFACT_MAVEN_WAR_PLUGIN,
+                                                     "warSourceDirectory", 
//$NON-NLS-1$
+                                                     
config.getProject().getBasedir() + DEFAULT_WEBAPP_RESOURCE_DIR ) ); 
//$NON-NLS-1$
+            
+            String webContentDir = IdeUtils.toRelativeAndFixSeparator( 
config.getEclipseProjectDirectory(),
+                    warSourceDirectory, false );
+
+               
             metaInfBaseDirectory =
-                config.getProject().getBasedir().getAbsolutePath() + 
File.separatorChar + WEBAPP_RESOURCE_DIR;
+                config.getProject().getBasedir().getAbsolutePath() + 
File.separatorChar + webContentDir;
 
             log.debug( "Attempting to use: " + metaInfBaseDirectory + " for 
location of META-INF in war project." );
 

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/RadPluginTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/RadPluginTest.java?rev=598528&r1=598527&r2=598528&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/RadPluginTest.java
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/RadPluginTest.java
 Mon Nov 26 22:53:06 2007
@@ -263,7 +263,8 @@
     }
     
     /**
-     * Tests warSourceDirectory setting to be reflected in generated 
.websettings
+     * Tests warSourceDirectory setting to be reflected in generated 
.websettings,
+     * location of jars in WEB-INF/lib and generation of MANIFEST.MF at the 
right place
      * @throws Exception
      */
     public void testProject7()
@@ -294,6 +295,7 @@
         }
         
         compareDirectoryContent( basedir, projectOutputDir, 
"WebContent/WEB-INF/lib/" );
+        compareDirectoryContent( basedir, projectOutputDir, 
"WebContent/META-INF/" );
 
        }
 

Added: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-rad-7/expected/WebContent/META-INF/MANIFEST.MF
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-rad-7/expected/WebContent/META-INF/MANIFEST.MF?rev=598528&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-rad-7/expected/WebContent/META-INF/MANIFEST.MF
 (added)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/projects/project-rad-7/expected/WebContent/META-INF/MANIFEST.MF
 Mon Nov 26 22:53:06 2007
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: deps-direct-compile-1.0.jar
+


Reply via email to