maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject svn commit: r1650354 - in /maven/plugins/trunk/maven-war-plugin/src: it/MWAR-167/ it/MWAR-167/src/ it/MWAR-167/src/main/ it/MWAR-167/src/main/resources/ it/MWAR-167/src/main/webapp/ main/java/org/apache/maven/plugin/war/ main/java/org/apache/maven/plug...
Date Thu, 08 Jan 2015 18:58:02 GMT
Author: khmarbaise
Date: Thu Jan  8 18:58:02 2015
New Revision: 1650354

URL: http://svn.apache.org/r1650354
Log:
[MWAR-167] Final manifest not written to exploded location
 Applied patch with slight modifications.

Added:
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/invoker.properties
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/pom.xml
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/src/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/src/main/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/src/main/resources/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/src/main/resources/MANIFEST.MF
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/src/main/webapp/
    maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/verify.bsh
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/CopyUserManifestTask.java
Modified:
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java

Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/invoker.properties?rev=1650354&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/invoker.properties (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/invoker.properties Thu Jan  8 18:58:02
2015
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+invoker.goals=clean war:exploded

Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/pom.xml?rev=1650354&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/pom.xml (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/pom.xml Thu Jan  8 18:58:02 2015
@@ -0,0 +1,49 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<project xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd' xmlns='http://maven.apache.org/POM/4.0.0'>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>testwar</groupId>
+  <artifactId>MWAR-167</artifactId>
+  <packaging>war</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>MWAR-167 Maven Webapp</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+ <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <archive>
+	         <manifestFile>src/main/resources/MANIFEST.MF</manifestFile>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/src/main/resources/MANIFEST.MF
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/src/main/resources/MANIFEST.MF?rev=1650354&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/src/main/resources/MANIFEST.MF (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/src/main/resources/MANIFEST.MF Thu
Jan  8 18:58:02 2015
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-Name: Dummy Bundle
+Bundle-SymbolicName: dummy.bundle
+Bundle-ManifestVersion: 2
+Bundle-Version: 1.0.0.SNAPSHOT
\ No newline at end of file

Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/verify.bsh?rev=1650354&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/verify.bsh (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-167/verify.bsh Thu Jan  8 18:58:02 2015
@@ -0,0 +1,74 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.io.*;
+import org.codehaus.plexus.util.*;
+
+boolean result = true;
+
+try
+{
+    File manifest = new File( basedir, "target/MWAR-167-1.0-SNAPSHOT/META-INF/MANIFEST.MF"
);
+    if ( !manifest.exists() || !manifest.isFile() )
+    {
+        System.err.println( "Manifest is missing!");
+        return false;
+    }
+    
+
+    FileInputStream fis = new FileInputStream ( manifest );
+    String manifestContent = IOUtil.toString ( fis );
+    
+    int indexOf = manifestContent.indexOf("Manifest-Version: 1.0" );
+    if ( indexOf < 0)
+    {
+    	System.err.println( "Manifest-Version header not found" );
+    	return false;
+    }
+
+	indexOf = manifestContent.indexOf("Bundle-Name: Dummy Bundle" );
+    if ( indexOf < 0)
+    {
+    	System.err.println( "Bundle-Name header not found" );
+    	return false;
+    }
+
+	indexOf = manifestContent.indexOf("Bundle-SymbolicName: dummy.bundle" );
+    if ( indexOf < 0)
+    {
+    	System.err.println( "Bundle-SymbolicName: 2" );
+    	return false;
+    }
+
+	indexOf = manifestContent.indexOf("Bundle-Version: 1.0.0.SNAPSHOT" );
+    if ( indexOf < 0)
+    {
+    	System.err.println( "Bundle-Version header not found" );
+    	return false;
+    }
+    
+}
+catch( Throwable e )
+{
+    e.printStackTrace();
+    result = false;
+}
+
+return result;

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java?rev=1650354&r1=1650353&r2=1650354&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
(original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
Thu Jan  8 18:58:02 2015
@@ -35,6 +35,7 @@ import org.apache.maven.plugin.MojoExecu
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.war.overlay.OverlayManager;
+import org.apache.maven.plugin.war.packaging.CopyUserManifestTask;
 import org.apache.maven.plugin.war.packaging.DependenciesAnalysisPackagingTask;
 import org.apache.maven.plugin.war.packaging.OverlayPackagingTask;
 import org.apache.maven.plugin.war.packaging.SaveWebappStructurePostPackagingTask;
@@ -457,7 +458,8 @@ public abstract class AbstractWarMojo
         getLog().info( "Assembling webapp [" + mavenProject.getArtifactId() + "] in [" +
webapplicationDirectory + "]" );
 
         final OverlayManager overlayManager =
-            new OverlayManager( overlays, mavenProject, dependentWarIncludes, dependentWarExcludes,
currentProjectOverlay );
+            new OverlayManager( overlays, mavenProject, dependentWarIncludes, dependentWarExcludes,
+                                currentProjectOverlay );
         final List<WarPackagingTask> packagingTasks = getPackagingTasks( overlayManager
);
         // CHECKSTYLE_ON: LineLength
         List<FileUtils.FilterWrapper> defaultFilterWrappers;
@@ -517,9 +519,13 @@ public abstract class AbstractWarMojo
         throws MojoExecutionException
     {
         final List<WarPackagingTask> packagingTasks = new ArrayList<WarPackagingTask>();
+
+        packagingTasks.add( new CopyUserManifestTask() );
+
         if ( useCache )
         {
             packagingTasks.add( new DependenciesAnalysisPackagingTask() );
+
         }
 
         final List<Overlay> resolvedOverlays = overlayManager.getOverlays();

Added: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/CopyUserManifestTask.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/CopyUserManifestTask.java?rev=1650354&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/CopyUserManifestTask.java
(added)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/CopyUserManifestTask.java
Thu Jan  8 18:58:02 2015
@@ -0,0 +1,77 @@
+package org.apache.maven.plugin.war.packaging;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugin.logging.SystemStreamLog;
+
+/**
+ * @author Haikal Saadh
+ *
+ */
+public class CopyUserManifestTask
+    extends AbstractWarPackagingTask
+{
+
+    /** Instance logger */
+    private Log log;
+
+    public Log getLog()
+    {
+        if ( log == null )
+        {
+            log = new SystemStreamLog();
+        }
+        return log;
+    }
+
+    public void setLog( Log log )
+    {
+        this.log = log;
+    }
+
+    public void performPackaging( WarPackagingContext context )
+        throws MojoExecutionException, MojoFailureException
+    {
+        File userManifest = context.getArchive().getManifestFile();
+        if ( userManifest != null )
+        {
+
+            try
+            {
+                getLog().info( "Copying manifest..." );
+                File metainfDir = new File( context.getWebappDirectory(), META_INF_PATH );
+                copyFile( context, userManifest, new File( metainfDir, "MANIFEST.MF" ), "META-INF/MANIFEST.MF",
true );
+
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Error copying user manifest", e );
+            }
+        }
+
+    }
+
+}



Mime
View raw message