Author: snicoll Date: Mon Aug 27 20:08:01 2012 New Revision: 1377814 URL: http://svn.apache.org/viewvc?rev=1377814&view=rev Log: MEAR-146: add an option to tune the way the library-directory element is generated in the application.xml. Based on patch provided by Alex Halovanic. Also fixes MEAR-151.
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/expected-META-INF/ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/expected-META-INF/application.xml (with props) maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/pom.xml - copied, changed from r1377212, maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/pom.xml maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/expected-META-INF/ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/expected-META-INF/application.xml (with props) maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/pom.xml (with props) maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/expected-META-INF/ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/expected-META-INF/application.xml (with props) maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/pom.xml (with props) Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java?rev=1377814&r1=1377813&r2=1377814&view=diff ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java (original) +++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java Mon Aug 27 20:08:01 2012 @@ -33,6 +33,7 @@ import org.codehaus.plexus.util.FileUtil import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -47,6 +48,11 @@ public class GenerateApplicationXmlMojo extends AbstractEarMojo { + public static final String DEFAULT = "DEFAULT"; + + public static final String EMPTY = "EMPTY"; + + public static final String NONE = "NONE"; /** * Whether the application.xml should be generated or not. @@ -82,6 +88,24 @@ public class GenerateApplicationXmlMojo private String description; /** + * Defines how the <tt>library-directory</tt> element should be written in the application.xml file. + * <p/> + * Three special values can be set: + * <ul> + * <li><code>DEFAULT</code> (default) generates a <tt>library-directory</tt> element with + * the value of the <tt>defaultLibBundleDir</tt> parameter</li> + * <li><code>EMPTY</code> generates an empty <tt>library-directory</tt> element. Per spec, this disables + * the scanning of jar files in the <tt>lib</tt> directory of the ear file</li> + * <li><code>NONE</code> does not write the library-directory element at all. A corner case that can + * be used in Oracle Weblogic to delegate the classloading to the container</li> + * </ul> + * <p/> + * Since JavaEE5. + */ + @Parameter( defaultValue = DEFAULT ) + private String libraryDirectoryMode; + + /** * Defines the value of the initialize in order element to be used when * the application.xml file is auto-generated. When set to true, modules * must be initialized in the order they're listed in this deployment descriptor, @@ -192,7 +216,7 @@ public class GenerateApplicationXmlMojo final ApplicationXmlWriter writer = new ApplicationXmlWriter( javaEEVersion, encoding, generateModuleId ); final ApplicationXmlWriterContext context = new ApplicationXmlWriterContext( descriptor, getModules(), buildSecurityRoles(), buildEnvEntries(), - displayName, description, defaultLibBundleDir, applicationName, + displayName, description, getActualLibraryDirectory(), applicationName, initializeInOrder ); writer.write( context ); } @@ -304,4 +328,32 @@ public class GenerateApplicationXmlMojo } } + + /** + * Returns the value to use for the <tt>library-directory</tt> element, based on the library directory mode. + */ + private String getActualLibraryDirectory() + throws EarPluginException + { + final String mode = libraryDirectoryMode == null ? DEFAULT : libraryDirectoryMode.toUpperCase(); + + if ( DEFAULT.equals( mode ) ) + { + return defaultLibBundleDir; + } + else if ( EMPTY.equals( mode ) ) + { + return ""; + } + else if ( NONE.equals( mode ) ) + { + return null; + } + else + { + throw new EarPluginException( + "Unsupported library directory mode [" + libraryDirectoryMode + "] Supported modes " + + ( Arrays.asList( DEFAULT, EMPTY, NONE ) ) ); + } + } } \ No newline at end of file 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=1377814&r1=1377813&r2=1377814&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 Mon Aug 27 20:08:01 2012 @@ -185,3 +185,9 @@ EAR Plugin Tests * project-077: builds an EAR with custom env entries settings and JavaEE 6 * project-078: builds an EAR with the no version for ejb file name mapping + + * project-079: builds an EAR with the 'default' library directory mode. Uses the value of the defaultLibBundleDir + + * project-080: builds an EAR with the 'empty' library directory mode. Generate an empty library-directory element + + * project-081: builds an EAR with the 'none' library directory mode. Does not generate an library-directory element 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=1377814&r1=1377813&r2=1377814&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 Mon Aug 27 20:08:01 2012 @@ -822,4 +822,31 @@ public class EarMojoIT new String[]{ "ejb-sample-one.jar", "war-sample-one-1.0.war", "jar-sample-two-1.0.jar" } ); } + /** + * Builds an EAR with the 'default' library directory mode. Uses the value of the defaultLibBundleDir. + */ + public void testProject079() + throws Exception + { + doTestProject( "project-079", new String[]{ "ejb-sample-one-1.0.jar", "myLibs/jar-sample-one-1.0.jar" } ); + } + + /** + * Builds an EAR with the 'empty' library directory mode. Generate an empty library-directory element. + */ + public void testProject080() + throws Exception + { + doTestProject( "project-080", new String[]{ "ejb-sample-one-1.0.jar", "myLibs/jar-sample-one-1.0.jar" } ); + } + + /** + * Builds an EAR with the 'none' library directory mode. Does not generate an library-directory element. + */ + public void testProject081() + throws Exception + { + doTestProject( "project-081", new String[]{ "ejb-sample-one-1.0.jar", "myLibs/jar-sample-one-1.0.jar" } ); + } + } Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/expected-META-INF/application.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/expected-META-INF/application.xml?rev=1377814&view=auto ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/expected-META-INF/application.xml (added) +++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/expected-META-INF/application.xml Mon Aug 27 20:08:01 2012 @@ -0,0 +1,26 @@ +<?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. +--> +<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6"> + <display-name>maven-ear-plugin-test-project-079</display-name> + <module> + <ejb>ejb-sample-one-1.0.jar</ejb> + </module> + <library-directory>myLibs</library-directory> +</application> Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/expected-META-INF/application.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/expected-META-INF/application.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Rev URL Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/expected-META-INF/application.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Copied: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/pom.xml (from r1377212, maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/pom.xml) URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/pom.xml?p2=maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/pom.xml&p1=maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/pom.xml&r1=1377212&r2=1377814&rev=1377814&view=diff ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-069/pom.xml (original) +++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-079/pom.xml Mon Aug 27 20:08:01 2012 @@ -22,7 +22,7 @@ under the License. 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-069</artifactId> + <artifactId>maven-ear-plugin-test-project-079</artifactId> <version>99.0</version> <name>Maven</name> <packaging>ear</packaging> @@ -47,7 +47,8 @@ under the License. <version>@project.version@</version> <configuration> <version>6</version> - <defaultLibBundleDir>myLibs</defaultLibBundleDir> + <defaultLibBundleDir>myLibs</defaultLibBundleDir> + <libraryDirectoryMode>default</libraryDirectoryMode> </configuration> </plugin> </plugins> Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/expected-META-INF/application.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/expected-META-INF/application.xml?rev=1377814&view=auto ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/expected-META-INF/application.xml (added) +++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/expected-META-INF/application.xml Mon Aug 27 20:08:01 2012 @@ -0,0 +1,26 @@ +<?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. +--> +<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6"> + <display-name>maven-ear-plugin-test-project-080</display-name> + <module> + <ejb>ejb-sample-one-1.0.jar</ejb> + </module> + <library-directory/> +</application> Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/expected-META-INF/application.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/expected-META-INF/application.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Rev URL Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/expected-META-INF/application.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/pom.xml?rev=1377814&view=auto ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/pom.xml (added) +++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/pom.xml Mon Aug 27 20:08:01 2012 @@ -0,0 +1,56 @@ +<?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-080</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-one</artifactId> + <version>1.0</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-ear-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <version>6</version> + <defaultLibBundleDir>myLibs</defaultLibBundleDir> + <libraryDirectoryMode>empty</libraryDirectoryMode> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Rev URL Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-080/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/expected-META-INF/application.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/expected-META-INF/application.xml?rev=1377814&view=auto ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/expected-META-INF/application.xml (added) +++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/expected-META-INF/application.xml Mon Aug 27 20:08:01 2012 @@ -0,0 +1,25 @@ +<?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. +--> +<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6"> + <display-name>maven-ear-plugin-test-project-081</display-name> + <module> + <ejb>ejb-sample-one-1.0.jar</ejb> + </module> +</application> Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/expected-META-INF/application.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/expected-META-INF/application.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Rev URL Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/expected-META-INF/application.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/pom.xml?rev=1377814&view=auto ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/pom.xml (added) +++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/pom.xml Mon Aug 27 20:08:01 2012 @@ -0,0 +1,56 @@ +<?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-081</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-one</artifactId> + <version>1.0</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-ear-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <version>6</version> + <defaultLibBundleDir>myLibs</defaultLibBundleDir> + <libraryDirectoryMode>none</libraryDirectoryMode> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Rev URL Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-081/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml