You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sn...@apache.org on 2012/08/02 21:28:24 UTC
svn commit: r1368659 - in /maven/plugins/trunk/maven-ear-plugin/src:
main/java/org/apache/maven/plugin/ear/output/ site/apt/
test/java/org/apache/maven/plugin/ear/it/
test/java/org/apache/maven/plugin/ear/output/
test/resources/m2repo/eartest/war-sampl...
Author: snicoll
Date: Thu Aug 2 19:28:23 2012
New Revision: 1368659
URL: http://svn.apache.org/viewvc?rev=1368659&view=rev
Log:
MEAR-150: Support for no version for ejb file name mapping. Patch submitted by Philippe Marschall
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMapping.java (with props)
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMappingTest.java (with props)
maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/
maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/
maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/war-sample-one-1.0.pom
maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/war-sample-one-1.0.war (with props)
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/expected-META-INF/
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/expected-META-INF/application.xml (with props)
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/pom.xml (with props)
Modified:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/FileNameMappingFactory.java
maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt
maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt.vm
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/FileNameMappingFactoryTest.java
Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/FileNameMappingFactory.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/FileNameMappingFactory.java?rev=1368659&r1=1368658&r2=1368659&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/FileNameMappingFactory.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/FileNameMappingFactory.java Thu Aug 2 19:28:23 2012
@@ -39,6 +39,7 @@ public class FileNameMappingFactory
static final String NO_VERSION_FILE_NAME_MAPPING = "no-version";
+ static final String NO_VERSION_FOR_EJB_FILE_NAME_MAPPING = "no-version-for-ejb";
private FileNameMappingFactory()
{
@@ -72,6 +73,10 @@ public class FileNameMappingFactory
{
return new NoVersionFileNameMapping();
}
+ if ( NO_VERSION_FOR_EJB_FILE_NAME_MAPPING.equals( nameOrClass ) )
+ {
+ return new NoVersionForEjbFileNameMapping();
+ }
try
{
final Class<?> c = Class.forName( nameOrClass );
@@ -98,4 +103,4 @@ public class FileNameMappingFactory
"Specified class[" + nameOrClass + "] does not implement[" + FileNameMapping.class.getName() + "]" );
}
}
-}
\ No newline at end of file
+}
Added: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMapping.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMapping.java?rev=1368659&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMapping.java (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMapping.java Thu Aug 2 19:28:23 2012
@@ -0,0 +1,40 @@
+package org.apache.maven.plugin.ear.output;
+
+/*
+ * 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 org.apache.maven.artifact.Artifact;
+
+/**
+ * A more sophisticated file name mapping which retains the version only for
+ * library jars and leaves it out for for ejb-jars.
+ *
+ * @author <a href="mailto:philippe.marschall@gmail.com">Philippe Marschall</a>
+ */
+public class NoVersionForEjbFileNameMapping
+ extends AbstractFileNameMapping
+{
+
+ public String mapFileName( Artifact a )
+ {
+ boolean isEjb = "ejb".equals( a.getType() );
+ return generateFileName( a, !isEjb );
+ }
+
+}
Propchange: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMapping.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMapping.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt?rev=1368659&r1=1368658&r2=1368659&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt Thu Aug 2 19:28:23 2012
@@ -175,3 +175,5 @@ EAR Plugin Tests
* project-072: builds an EAR with an application client module (app-client)
* project-073: builds an EAR with an application client module (app-client) and a default bundle directory for _java_ modules
+
+ * project-078: builds an EAR with the no version for ejb file name mapping
Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt.vm?rev=1368659&r1=1368658&r2=1368659&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt.vm (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt.vm Thu Aug 2 19:28:23 2012
@@ -116,11 +116,13 @@ mvn package
The file name mapping to use for artifacts stored in the EAR can be specified
using the <<<fileNameMapping>>> parameter. Valid values for this parameter
- are <<<standard>>> (default), <<<full>>> and <<<no-version>>>. By specifying
- <<<full>>> as file name mapping, artifacts are prefixed by the <<<groupId>>>
- where dots have been replaced by dashes. <<<no-version>>> can be used as a
- replacement of the default mapping; the only difference is that the version
- is omitted.
+ are <<<standard>>> (default), <<<full>>>, <<<no-version>>> and
+ <<<no-version-for-ejb>>>. By specifying <<<full>>> as file name mapping,
+ artifacts are prefixed by the <<<groupId>>> where dots have been replaced by
+ dashes. <<<no-version>>> can be used as a replacement of the default mapping;
+ the only difference is that the version is omitted. <<<no-version-for-ejb>>>
+ is a specialization that omits the version only for ejb-jars and keeps it for
+ others ear modules.
For more information on EAR modules, please see the
{{{./modules.html}modules configuration}} page.
Modified: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java?rev=1368659&r1=1368658&r2=1368659&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java Thu Aug 2 19:28:23 2012
@@ -374,7 +374,7 @@ public class EarMojoIT
}
/**
- * Builds an EAR with a full filename mapping and make sure that custom locations are not overriden.
+ * Builds an EAR with a full filename mapping and make sure that custom locations are not overridden.
*/
public void testProject035()
throws Exception
@@ -773,4 +773,14 @@ public class EarMojoIT
"APP-INF/lib/jar-sample-one-1.0.jar", "APP-INF/lib/jar-sample-two-1.0.jar" } );
}
+ /**
+ * Builds an EAR with the no version for ejb file name mapping.
+ */
+ public void testProject078()
+ throws Exception
+ {
+ doTestProject( "project-078",
+ new String[]{ "ejb-sample-one.jar", "war-sample-one-1.0.war", "jar-sample-two-1.0.jar" } );
+ }
+
}
Modified: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/FileNameMappingFactoryTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/FileNameMappingFactoryTest.java?rev=1368659&r1=1368658&r2=1368659&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/FileNameMappingFactoryTest.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/FileNameMappingFactoryTest.java Thu Aug 2 19:28:23 2012
@@ -60,6 +60,14 @@ public class FileNameMappingFactoryTest
assertEquals( NoVersionFileNameMapping.class, actual.getClass() );
}
+ public void testGetFileNameMappingByName4()
+ {
+ final FileNameMapping actual =
+ FileNameMappingFactory.getFileNameMapping( FileNameMappingFactory.NO_VERSION_FOR_EJB_FILE_NAME_MAPPING );
+ assertNotNull( actual );
+ assertEquals( NoVersionForEjbFileNameMapping.class, actual.getClass() );
+ }
+
public void testGetFileNameMappingByClass()
{
final FileNameMapping actual =
Added: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMappingTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMappingTest.java?rev=1368659&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMappingTest.java (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMappingTest.java Thu Aug 2 19:28:23 2012
@@ -0,0 +1,39 @@
+package org.apache.maven.plugin.ear.output;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author Philippe Marschall
+ */
+public class NoVersionForEjbFileNameMappingTest
+ extends AbstractFileNameMappingTest
+{
+ private final NoVersionForEjbFileNameMapping instance = new NoVersionForEjbFileNameMapping();
+
+ public void testJarArtifact()
+ {
+ assertEquals( "foo-1.0-SNAPSHOT.jar", instance.mapFileName( createArtifact( "foo", "1.0-SNAPSHOT", "jar" ) ) );
+ }
+
+ public void testEjbArtifact()
+ {
+ assertEquals( "foo.jar", instance.mapFileName( createArtifact( "foo", "1.0-SNAPSHOT", "ejb" ) ) );
+ }
+}
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMappingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMappingTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/output/NoVersionForEjbFileNameMappingTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/war-sample-one-1.0.pom
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/war-sample-one-1.0.pom?rev=1368659&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/war-sample-one-1.0.pom (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/war-sample-one-1.0.pom Thu Aug 2 19:28:23 2012
@@ -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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>eartest</groupId>
+ <artifactId>war-sample-one</artifactId>
+ <packaging>war</packaging>
+ <version>1.0</version>
+ <distributionManagement>
+ <status>verified</status>
+ </distributionManagement>
+</project>
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/war-sample-one-1.0.war
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/war-sample-one-1.0.war?rev=1368659&view=auto
==============================================================================
Binary file - no diff available.
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/war-sample-one/1.0/war-sample-one-1.0.war
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/expected-META-INF/application.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/expected-META-INF/application.xml?rev=1368659&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/expected-META-INF/application.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/expected-META-INF/application.xml Thu Aug 2 19:28:23 2012
@@ -0,0 +1,35 @@
+<?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.
+-->
+
+<!DOCTYPE application PUBLIC
+ "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+ "http://java.sun.com/dtd/application_1_3.dtd">
+<application>
+ <display-name>maven-ear-plugin-test-project-078</display-name>
+ <module>
+ <ejb>ejb-sample-one.jar</ejb>
+ </module>
+ <module>
+ <web>
+ <web-uri>war-sample-one-1.0.war</web-uri>
+ <context-root>/war-sample-one</context-root>
+ </web>
+ </module>
+</application>
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/expected-META-INF/application.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/expected-META-INF/application.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/expected-META-INF/application.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/pom.xml?rev=1368659&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/pom.xml Thu Aug 2 19:28:23 2012
@@ -0,0 +1,60 @@
+<?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="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>ear</groupId>
+ <artifactId>maven-ear-plugin-test-project-078</artifactId>
+ <version>99.0</version>
+ <name>Maven</name>
+ <packaging>ear</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>ejb-sample-one</artifactId>
+ <version>1.0</version>
+ <type>ejb</type>
+ </dependency>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>jar-sample-two</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>war-sample-one</artifactId>
+ <version>1.0</version>
+ <type>war</type>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ear-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <fileNameMapping>no-version-for-ejb</fileNameMapping>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-078/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml