MPEAR-7: application.xml is now generated at maven.build.dir

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@116234 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
felipeal
2004-11-16 05:04:56 +00:00
parent f3cd6013d4
commit 7b4ec0e95e
13 changed files with 252 additions and 16 deletions

View File

@@ -48,21 +48,30 @@
<ant:mkdir dir="${maven.build.dir}" />
<j:set var="isGenerateAppXML"
value="${context.getVariable('maven.ear.appxml.generate')}"/>
<j:if test="${isGenerateAppXML == 'true'}">
<!-- make sure that target directory exists -->
<ant:mkdir dir="${maven.ear.descriptordir}"/>
<attainGoal name="ear:generate-ear-descriptor"/>
</j:if >
<j:set var="finalAppxml" value="${maven.ear.descriptordir}/application.xml"/>
<j:set var="isGenerateAppXML"
value="${context.getVariable('maven.ear.appxml.generate')}"/>
<!-- make sure that target directory exists -->
<ant:mkdir dir="${maven.ear.descriptordir}"/>
<j:choose>
<j:when test="${isGenerateAppXML == 'true'}">
<attainGoal name="ear:generate-ear-descriptor"/>
</j:when>
<j:otherwise>
<util:available file="${maven.ear.src}/META-INF/application.xml">
<ant:copy file="${maven.ear.appxml}" tofile="${finalAppxml}"/>
</util:available>
</j:otherwise>
</j:choose>
<ant:echo>Building EAR ${maven.final.name} with appxml "${maven.ear.appxml}"</ant:echo>
<ant:echo>Building EAR ${maven.final.name} with appxml "${finalAppxml}"</ant:echo>
<ant:available property="maven.ear.manifest.available"
file="${maven.ear.manifest}"/>
<ant:ear destfile="${maven.build.dir}/${maven.final.name}.ear"
appxml="${maven.ear.appxml}">
appxml="${finalAppxml}">
<!-- include files from maven.ear.src if available -->
<util:available file="${maven.ear.src}">
@@ -161,9 +170,9 @@
<!--==================================================================-->
<goal name="ear:generate-ear-descriptor" description="Generates the ear descriptor">
<ant:echo>Generating appxml file:"${maven.ear.appxml} version ${maven.ear.appxml.version} encoding: ${maven.ear.appxml.encoding}"</ant:echo>
<ant:echo>Generating appxml file:"${finalAppxml} version ${maven.ear.appxml.version} encoding: ${maven.ear.appxml.encoding}"</ant:echo>
<j:file name="${maven.ear.appxml}"
<j:file name="${finalAppxml}"
outputMode="xml"
prettyPrint="true"
encoding="${maven.ear.appxml.encoding}"

View File

@@ -24,9 +24,9 @@
maven.ear.src=${maven.src.dir}/application
# Location of xml configs and manifest files
maven.ear.descriptordir=${maven.ear.src}/META-INF
maven.ear.appxml=${maven.ear.descriptordir}/application.xml
maven.ear.manifest=${maven.ear.descriptordir}/MANIFEST.MF
maven.ear.descriptordir=${maven.build.dir}
maven.ear.appxml=${maven.ear.src}/META-INF/application.xml
maven.ear.manifest=${maven.ear.src}/META-INF/MANIFEST.MF
maven.ear.appxml.generate=false
maven.ear.displayname=${pom.artifactId}
maven.ear.appxml.version=1.3

View File

@@ -0,0 +1,53 @@
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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:assert="assert"
xmlns:util="jelly:util"
xmlns:j="jelly:core"
xmlns:ant="jelly:ant"
default="testPlugin">
<goal name="testPlugin" prereqs="test-ear">
<attainGoal name="clean"/>
</goal>
<goal name="test-ear" prereqs="ear:init">
<!-- makes sure application.xml didn't exist before -->
<util:available file="${maven.ear.src}/META-INF/application.xml">
<ant:fail>Testcase should not have file ${maven.ear.src}/META-INF/application.xml. Please remove it first.</ant:fail>
</util:available>
<attainGoal name="ear"/>
<!-- makes sure application.xml wasn't added -->
<util:available file="${maven.ear.src}/META-INF/application.xml">
<ant:fail>Plugin should not have created file ${maven.ear.src}/META-INF/application.xml.</ant:fail>
</util:available>
<!-- tests that the ear is generated -->
<assert:assertFileExists file="${maven.build.dir}/${maven.final.name}.ear"/>
<!-- extracts the EAR -->
<j:set var="tmpEarDir" value="${maven.build.dir}/extractedEar"/>
<ant:unzip src="${maven.build.dir}/${maven.final.name}.ear" dest="${tmpEarDir}"/>
<!-- asserts the application.xml is there -->
<assert:assertFileExists file="${tmpEarDir}/META-INF/application.xml"/>
</goal>
</project>

View File

@@ -0,0 +1,16 @@
# -------------------------------------------------------------------
# Copyright 2001-2004 The Apache Software Foundation.
#
# Licensed 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.
# -------------------------------------------------------------------
maven.ear.appxml.generate=true

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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>
<pomVersion>3</pomVersion>
<name>Test project for Maven Ear Plugin 03</name>
<artifactId>test-maven-ear-plugin-03</artifactId>
<inceptionYear>2004</inceptionYear>
<shortDescription>Tests that application.xml is not generated at maven.ear.src</shortDescription>
<shortDescription>Tests that application.xml is not generated at maven.ear.src (see issue MPEAR-7)</shortDescription>
<url/>
<developers>
<developer>
<name>Felipe Leme</name>
<id>felipeal</id>
<role>Jelly Developer</role>
</developer>
</developers>
</project>

View File

@@ -0,0 +1,55 @@
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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:assert="assert"
xmlns:util="jelly:util"
xmlns:j="jelly:core"
xmlns:ant="jelly:ant"
default="testPlugin">
<goal name="testPlugin" prereqs="test-ear">
<attainGoal name="clean"/>
</goal>
<goal name="test-ear" prereqs="ear:init">
<echo>SRC: ${maven.ear.src}</echo>
<!-- makes sure application.xml existed before -->
<assert:assertFileExists file="${maven.ear.src}/META-INF/application.xml"/>
<attainGoal name="ear"/>
<!-- makes sure application.xml existed after -->
<assert:assertFileExists file="${maven.ear.src}/META-INF/application.xml"/>
<!-- tests that the ear is generated -->
<assert:assertFileExists file="${maven.build.dir}/${maven.final.name}.ear"/>
<!-- extracts the EAR -->
<j:set var="tmpEarDir" value="${maven.build.dir}/extractedEar"/>
<ant:unzip src="${maven.build.dir}/${maven.final.name}.ear" dest="${tmpEarDir}"/>
<!-- asserts the application.xml is there -->
<assert:assertFileExists file="${tmpEarDir}/META-INF/application.xml"/>
<!-- asserts the application.xml content is the same as before -->
<util:loadText var="newAppXml" file="${tmpEarDir}/META-INF/application.xml"/>
<util:loadText var="oldAppXml" file="${maven.ear.src}/META-INF/application.xml"/>
<assert:assertEquals expected="${oldAppXml}" value="${newAppXml}"/>
</goal>
</project>

View File

@@ -0,0 +1,16 @@
# -------------------------------------------------------------------
# Copyright 2001-2004 The Apache Software Foundation.
#
# Licensed 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.
# -------------------------------------------------------------------
maven.ear.appxml.generate=false

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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>
<pomVersion>3</pomVersion>
<name>Test project for Maven Ear Plugin 04</name>
<artifactId>test-maven-ear-plugin-04</artifactId>
<inceptionYear>2004</inceptionYear>
<shortDescription>Tests that application.xml is correctly bundled</shortDescription>
<shortDescription>Tests that application.xml is correctly bundled when it is not generated (see issue MPEAR-7)</shortDescription>
<url/>
<developers>
<developer>
<name>Felipe Leme</name>
<id>felipeal</id>
<role>Jelly Developer</role>
</developer>
</developers>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>My Display</display-name>
</application>

View File

@@ -25,6 +25,7 @@
</properties>
<body>
<release version="1.6-SNAPSHOT" date="in CVS">
<action dev="felipeal" type="fix" issue="MPEAR-7"><code>application.xml</code> is now generated at <code>maven.build.dir</code></action>
<action dev="felipeal" type="add" issue="MPEAR-26">Add new property dependency (<code>ear.bundle.name</code>) to define the name a dependency should have the EAR.</action>
<action dev="felipeal" type="fix" issue="MPEAR-20">Changed the default value of <code>maven.ear.displayname</code>.</action>
<action dev="felipeal" type="add" issue="MPEAR-23" due-to="Wiley Fuller">Add new property dependency(<code>ear.bundle.dir</code>) to define where a dependency should be added in the EAR.</action>

View File

@@ -35,7 +35,7 @@
Location of the manifest file to be used within the ear file.
</td>
<td>
${maven.src.dir}/application/META-INF/MANIFEST.MF
${maven.ear.src}/META-INF/MANIFEST.MF
</td>
</tr>
<tr>
@@ -46,7 +46,7 @@
to be used within the ear file.
</td>
<td>
${maven.src.dir}/application/META-INF/application.xml
${maven.ear.src}/META-INF/application.xml
</td>
</tr>
<tr>
@@ -111,6 +111,16 @@
UTF-8
</td>
</tr>
<tr>
<td>maven.ear.descriptordir</td>
<td>Yes</td>
<td>
Directory where the <code>application.xml</code> file will be auto-generated (only if <code>maven.ear.appxml.generate</code> is true).
</td>
<td>
${maven.build.dir}
</td>
</tr>
</table>
</section>
<section name="other settings">