Author: snicoll Date: Sun Feb 22 15:44:32 2009 New Revision: 746740 URL: http://svn.apache.org/viewvc?rev=746740&view=rev Log: MEAR-81: it is now possible to disable the generation of application.xml if version is set to 5.
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-054/ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-054/pom.xml Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java 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/AbstractEarPluginIT.java 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/AbstractEarMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java?rev=746740&r1=746739&r2=746740&view=diff ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java (original) +++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java Sun Feb 22 15:44:32 2009 @@ -45,6 +45,12 @@ extends AbstractMojo { + public static final String VERSION_1_3 = "1.3"; + + public static final String VERSION_1_4 = "1.4"; + + public static final String VERSION_5 = "5"; + public static final String APPLICATION_XML_URI = "META-INF/application.xml"; public static final String META_INF = "META-INF"; @@ -52,6 +58,14 @@ public static final String UTF_8 = "UTF-8"; /** + * The version of the application.xml to generate. Valid values + * are 1.3, 1.4 and 5. + * + * @parameter default-value="1.3" + */ + protected String version; + + /** * Character encoding for the auto-generated deployment file(s). * * @parameter default-value="UTF-8" Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java?rev=746740&r1=746739&r2=746740&view=diff ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java (original) +++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java Sun Feb 22 15:44:32 2009 @@ -380,7 +380,7 @@ // Check if deployment descriptor is there File ddFile = new File( getWorkDirectory(), APPLICATION_XML_URI ); - if ( !ddFile.exists() ) + if ( !ddFile.exists() && !version.equals(VERSION_5 ) ) { throw new MojoExecutionException( "Deployment descriptor: " + ddFile.getAbsolutePath() + " does not exist." ); 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=746740&r1=746739&r2=746740&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 Sun Feb 22 15:44:32 2009 @@ -43,11 +43,7 @@ extends AbstractEarMojo { - public static final String VERSION_1_3 = "1.3"; - public static final String VERSION_1_4 = "1.4"; - - public static final String VERSION_5 = "5"; /** * Whether the application.xml should be generated or not. @@ -57,14 +53,6 @@ private Boolean generateApplicationXml = Boolean.TRUE; /** - * The version of the application.xml to generate. Valid values - * are 1.3, 1.4 and 5. - * - * @parameter default-value="1.3" - */ - private String version; - - /** * Display name of the application to be used when application.xml * file is autogenerated. * 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=746740&r1=746739&r2=746740&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 Sun Feb 22 15:44:32 2009 @@ -136,4 +136,6 @@ * project-053: builds an EAR with a Jboss 5 configuration containing only the loader repo configuration + * project-054: builds an EAR with deployment descriptor configuration for Java EE 5 and no application.xml + \ No newline at end of file Modified: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/AbstractEarPluginIT.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/AbstractEarPluginIT.java?rev=746740&r1=746739&r2=746740&view=diff ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/AbstractEarPluginIT.java (original) +++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/AbstractEarPluginIT.java Sun Feb 22 15:44:32 2009 @@ -20,12 +20,12 @@ */ import junit.framework.TestCase; -import org.apache.maven.it.Verifier; import org.apache.maven.it.VerificationException; +import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import org.codehaus.plexus.util.ReaderFactory; -import org.custommonkey.xmlunit.XMLAssert; import org.custommonkey.xmlunit.Diff; +import org.custommonkey.xmlunit.XMLAssert; import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; import java.io.File; @@ -368,51 +368,53 @@ else { assertNotNull( "Missing deployment descriptor", actualDeploymentDescriptors ); - } - // Make sure we have the same number of files - assertEquals( "Number of Deployment descriptor(s) mismatch", expectedDeploymentDescriptors.length, - actualDeploymentDescriptors.length ); - // Sort the files so that we have the same behavior here - Arrays.sort( expectedDeploymentDescriptors ); - Arrays.sort( actualDeploymentDescriptors ); + // Make sure we have the same number of files + assertEquals( "Number of Deployment descriptor(s) mismatch", expectedDeploymentDescriptors.length, + actualDeploymentDescriptors.length ); + + // Sort the files so that we have the same behavior here + Arrays.sort( expectedDeploymentDescriptors ); + Arrays.sort( actualDeploymentDescriptors ); - for ( int i = 0; i < expectedDeploymentDescriptors.length; i++ ) - { - File expectedDeploymentDescriptor = expectedDeploymentDescriptors[i]; - File actualDeploymentDescriptor = actualDeploymentDescriptors[i]; + for ( int i = 0; i < expectedDeploymentDescriptors.length; i++ ) + { + File expectedDeploymentDescriptor = expectedDeploymentDescriptors[i]; + File actualDeploymentDescriptor = actualDeploymentDescriptors[i]; - assertEquals( "File name mismatch", expectedDeploymentDescriptor.getName(), - actualDeploymentDescriptor.getName() ); + assertEquals( "File name mismatch", expectedDeploymentDescriptor.getName(), + actualDeploymentDescriptor.getName() ); - Reader expected = null; - Reader actual = null; - try - { - expected = ReaderFactory.newXmlReader( expectedDeploymentDescriptor ); - actual = ReaderFactory.newXmlReader( actualDeploymentDescriptor ); + Reader expected = null; + Reader actual = null; + try + { + expected = ReaderFactory.newXmlReader( expectedDeploymentDescriptor ); + actual = ReaderFactory.newXmlReader( actualDeploymentDescriptor ); - // Make sure that it matches even if the elements are not in - // the exact same order - final Diff myDiff = new Diff(expected, actual); - myDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier()); - XMLAssert.assertXMLEqual( - "Wrong deployment descriptor generated for[" + expectedDeploymentDescriptor.getName() + "]", - myDiff, true); } - catch ( Exception e ) - { - e.printStackTrace(); - fail( "Could not assert deployment descriptor " + e.getMessage() ); - } - finally - { - if ( expected != null ) + // Make sure that it matches even if the elements are not in + // the exact same order + final Diff myDiff = new Diff( expected, actual ); + myDiff.overrideElementQualifier( new RecursiveElementNameAndTextQualifier() ); + XMLAssert.assertXMLEqual( + "Wrong deployment descriptor generated for[" + expectedDeploymentDescriptor.getName() + "]", + myDiff, true ); + } + catch ( Exception e ) { - expected.close(); + e.printStackTrace(); + fail( "Could not assert deployment descriptor " + e.getMessage() ); } - if ( actual != null ) + finally { - actual.close(); + if ( expected != null ) + { + expected.close(); + } + if ( actual != null ) + { + actual.close(); + } } } } 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=746740&r1=746739&r2=746740&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 Sun Feb 22 15:44:32 2009 @@ -239,9 +239,10 @@ public void testProject021() throws Exception { - doTestProject( "project-021", new String[]{"ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar", - "sar-sample-one-1.0.sar", "jar-sample-one-1.0.jar", "jar-sample-two-1.0.jar"}, - new boolean[]{false, true, false, false, true} ); + doTestProject( "project-021", + new String[]{"ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar", "sar-sample-one-1.0.sar", + "jar-sample-one-1.0.jar", "jar-sample-two-1.0.jar"}, + new boolean[]{false, true, false, false, true} ); } /** @@ -358,8 +359,9 @@ public void testProject033() throws Exception { - doTestProject( "project-033", new String[]{"ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar", - "sar-sample-one-1.0.sar", "har-sample-one-1.0.har"} ); + doTestProject( "project-033", + new String[]{"ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar", "sar-sample-one-1.0.sar", + "har-sample-one-1.0.har"} ); } /** @@ -377,9 +379,10 @@ public void testProject035() throws Exception { - doTestProject( "project-035", new String[]{"foo/eartest-ejb-sample-one-1.0.jar", - "eartest-ejb-sample-two-1.0.jar", "libs/eartest-jar-sample-one-1.0.jar", - "libs/eartest-jar-sample-two-1.0.jar", "sar-sample-one.sar"} ); + doTestProject( "project-035", + new String[]{"foo/eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar", + "libs/eartest-jar-sample-one-1.0.jar", "libs/eartest-jar-sample-two-1.0.jar", + "sar-sample-one.sar"} ); } /** @@ -388,10 +391,11 @@ public void testProject036() throws Exception { - doTestProject( "project-036", new String[]{"foo/eartest-ejb-sample-one-1.0.jar", - "eartest-ejb-sample-two-1.0.jar", "com-foo-bar-ejb-sample-one-1.0.jar", - "com-foo-bar-ejb-sample-two-1.0.jar", "libs/eartest-jar-sample-one-1.0.jar", - "libs/eartest-jar-sample-two-1.0.jar", "sar-sample-one.sar"} ); + doTestProject( "project-036", + new String[]{"foo/eartest-ejb-sample-one-1.0.jar", "eartest-ejb-sample-two-1.0.jar", + "com-foo-bar-ejb-sample-one-1.0.jar", "com-foo-bar-ejb-sample-two-1.0.jar", + "libs/eartest-jar-sample-one-1.0.jar", "libs/eartest-jar-sample-two-1.0.jar", + "sar-sample-one.sar"} ); } /** @@ -457,12 +461,12 @@ * Builds an EAR with a custom descriptor location (generatedDescriptorLocation setting). */ public void testProject043() - throws Exception + throws Exception { - final File baseDir = doTestProject("project-043", new String[]{"ejb-sample-one-1.0.jar"}); - final File expectedApplicationXml = new File(baseDir, "target/custom-descriptor-dir/application.xml"); - assertTrue("Application.xml file not found", expectedApplicationXml.exists()); - assertFalse("Application.xml file should not be empty", expectedApplicationXml.length() == 0); + final File baseDir = doTestProject( "project-043", new String[]{"ejb-sample-one-1.0.jar"} ); + final File expectedApplicationXml = new File( baseDir, "target/custom-descriptor-dir/application.xml" ); + assertTrue( "Application.xml file not found", expectedApplicationXml.exists() ); + assertFalse( "Application.xml file should not be empty", expectedApplicationXml.length() == 0 ); } /** @@ -483,10 +487,9 @@ final File baseDir = doTestProject( "project-045", new String[]{"README.txt", "ejb-sample-one-1.0.jar"} ); final File actualReadme = new File( getEarDirectory( baseDir, "project-045" ), "README.txt" ); final String content = IOUtil.toString( ReaderFactory.newReader( actualReadme, "UTF-8" ) ); - assertTrue("application name and version was not filtered properly", - content.indexOf("my-app 99.0") != -1); - assertTrue("Escaping did not work properly", - content.indexOf("will not be filtered ${application.name}.") != -1); + assertTrue( "application name and version was not filtered properly", content.indexOf( "my-app 99.0" ) != -1 ); + assertTrue( "Escaping did not work properly", + content.indexOf( "will not be filtered ${application.name}." ) != -1 ); } /** @@ -499,12 +502,10 @@ final File baseDir = doTestProject( "project-046", new String[]{"README.txt", "ejb-sample-one-1.0.jar"} ); final File actualReadme = new File( getEarDirectory( baseDir, "project-046" ), "README.txt" ); final String content = IOUtil.toString( ReaderFactory.newReader( actualReadme, "UTF-8" ) ); - assertTrue("application name and version was not filtered properly", - content.indexOf("my-app 99.0") != -1); - assertTrue("application build was not filtered properly", - content.indexOf("(Build 2)") != -1); - assertTrue("Unknown property should not have been filtered", - content.indexOf("will not be filtered ${application.unknown}.") != -1); + assertTrue( "application name and version was not filtered properly", content.indexOf( "my-app 99.0" ) != -1 ); + assertTrue( "application build was not filtered properly", content.indexOf( "(Build 2)" ) != -1 ); + assertTrue( "Unknown property should not have been filtered", + content.indexOf( "will not be filtered ${application.unknown}." ) != -1 ); } /** @@ -516,10 +517,10 @@ final File baseDir = doTestProject( "project-047", new String[]{"README.txt", "ejb-sample-one-1.0.jar"} ); final File actualReadme = new File( getEarDirectory( baseDir, "project-047" ), "README.txt" ); final String content = IOUtil.toString( ReaderFactory.newReader( actualReadme, "UTF-8" ) ); - assertTrue("application name and version should not have been filtered", - content.indexOf("my-app 99.0") == -1); - assertTrue("orignial properties not found", - content.indexOf("${application.name} ${project.version}") != -1); + assertTrue( "application name and version should not have been filtered", + content.indexOf( "my-app 99.0" ) == -1 ); + assertTrue( "orignial properties not found", + content.indexOf( "${application.name} ${project.version}" ) != -1 ); } /** @@ -575,4 +576,13 @@ { doTestProject( "project-053", new String[]{"ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar"} ); } + + /** + * Builds an EAR with deployment descriptor configuration for Java EE 5 and no application.xml + */ + public void testProject054() + throws Exception + { + doTestProject( "project-054", new String[]{"ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar"} ); + } } Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-054/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-054/pom.xml?rev=746740&view=auto ============================================================================== --- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-054/pom.xml (added) +++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-054/pom.xml Sun Feb 22 15:44:32 2009 @@ -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-054</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>ejb-sample-two</artifactId> + <version>1.0</version> + <type>ejb</type> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-ear-plugin</artifactId> + <configuration> + <version>5</version> + <generateApplicationXml>false</generateApplicationXml> + </configuration> + </plugin> + </plugins> + </build> + +</project>