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 2011/11/29 13:29:49 UTC
svn commit: r1207848 - in /maven/plugins/trunk/maven-war-plugin/src:
it/MWAR-240/ it/MWAR-240/src/ it/MWAR-240/src/main/
it/MWAR-240/src/main/java/ it/MWAR-240/src/main/java/org/
it/MWAR-240/src/main/java/org/apache/ it/MWAR-240/src/main/java/org/apach...
Author: aheritier
Date: Tue Nov 29 12:29:48 2011
New Revision: 1207848
URL: http://svn.apache.org/viewvc?rev=1207848&view=rev
Log:
MWAR-240 : Using archiveClasses with attachClasses deploys an empty attached jar
Added:
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/goals.txt (with props)
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/pom.xml (with props)
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/war/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/war/it/
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/war/it/Dummy.java (with props)
maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/verify.bsh (with props)
Modified:
maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/goals.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/goals.txt?rev=1207848&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/goals.txt (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/goals.txt Tue Nov 29 12:29:48 2011
@@ -0,0 +1 @@
+clean package
\ No newline at end of file
Propchange: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/goals.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/goals.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/pom.xml?rev=1207848&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/pom.xml (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/pom.xml Tue Nov 29 12:29:48 2011
@@ -0,0 +1,43 @@
+<!--
+ 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="http://maven.apache.org/POM/4.0.0"
+ 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">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>mwar-240-test-case</artifactId>
+ <version>1.0</version>
+ <name>MWAR-240 Test case</name>
+ <packaging>war</packaging>
+ <description>Test project for reproducing an issue with classes packaging: http://jira.codehaus.org/browse/MWAR-240</description>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ <archiveClasses>true</archiveClasses>
+ <attachClasses>true</attachClasses>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Propchange: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/war/it/Dummy.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/war/it/Dummy.java?rev=1207848&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/war/it/Dummy.java (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/war/it/Dummy.java Tue Nov 29 12:29:48 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+package org.apache.maven.plugin.war.it;
+
+/**
+ * A dummy class to show the problem with classes packaging.
+ *
+ * @author Sergiy Shyrkov
+ */
+public class Dummy {
+
+}
Propchange: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/war/it/Dummy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/src/main/java/org/apache/maven/plugin/war/it/Dummy.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/verify.bsh?rev=1207848&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/verify.bsh (added)
+++ maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/verify.bsh Tue Nov 29 12:29:48 2011
@@ -0,0 +1,59 @@
+
+/*
+ * 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 java.util.*;
+import java.util.jar.*;
+import java.util.regex.*;
+
+try
+{
+ File jarFile = new File( basedir, "target/mwar-240-test-case-1.0-classes.jar" );
+ System.out.println( "Checking for existence of " + jarFile );
+ if ( !jarFile.isFile() )
+ {
+ System.out.println( "FAILURE!" );
+ return false;
+ }
+
+ JarFile jar = new JarFile( jarFile );
+
+ String[] includedEntries = {
+ "org/apache/maven/plugin/war/it/Dummy.class",
+ };
+ for ( String included : includedEntries )
+ {
+ System.out.println( "Checking for existence of " + included );
+ if ( jar.getEntry( included ) == null )
+ {
+ System.out.println( "FAILURE!" );
+ return false;
+ }
+ }
+
+ jar.close();
+}
+catch( Throwable t )
+{
+ t.printStackTrace();
+ return false;
+}
+
+return true;
Propchange: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/verify.bsh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-war-plugin/src/it/MWAR-240/verify.bsh
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java?rev=1207848&r1=1207847&r2=1207848&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java Tue Nov 29 12:29:48 2011
@@ -29,6 +29,7 @@ import org.apache.maven.project.MavenPro
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.jar.ManifestException;
import org.codehaus.plexus.archiver.war.WarArchiver;
+import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
@@ -231,14 +232,24 @@ public class WarMojo
// create the classes to be attached if necessary
if ( isAttachClasses() )
{
- ClassesPackager packager = new ClassesPackager();
- final File classesDirectory = packager.getClassesDirectory( getWebappDirectory() );
- if ( classesDirectory.exists() )
+ if ( isArchiveClasses() && getJarArchiver().getDestFile() != null )
{
- getLog().info( "Packaging classes" );
- packager.packageClasses( classesDirectory, getTargetClassesFile(), getJarArchiver(), getProject(),
- getArchive() );
- projectHelper.attachArtifact( getProject(), "jar", getClassesClassifier(), getTargetClassesFile() );
+ // special handling in case of archived classes: MWAR-240
+ File targetClassesFile = getTargetClassesFile();
+ FileUtils.copyFile(getJarArchiver().getDestFile(), targetClassesFile);
+ projectHelper.attachArtifact( getProject(), "jar", getClassesClassifier(), targetClassesFile );
+ }
+ else
+ {
+ ClassesPackager packager = new ClassesPackager();
+ final File classesDirectory = packager.getClassesDirectory( getWebappDirectory() );
+ if ( classesDirectory.exists() )
+ {
+ getLog().info( "Packaging classes" );
+ packager.packageClasses( classesDirectory, getTargetClassesFile(), getJarArchiver(), getProject(),
+ getArchive() );
+ projectHelper.attachArtifact( getProject(), "jar", getClassesClassifier(), getTargetClassesFile() );
+ }
}
}