mirror of https://github.com/apache/maven.git
Adding supports for encoding doctype/xschema declaration and the new provided scope.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@209016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a6eff8b8ce
commit
e57cac7fc9
|
@ -8,12 +8,12 @@
|
|||
<artifactId>maven-ear-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<name>Maven Ear plugin</name>
|
||||
<version>2.0-alpha-1-SNAPSHOT</version>
|
||||
<version>2.0-beta-1-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-archiver</artifactId>
|
||||
<version>2.0-alpha-2</version>
|
||||
<version>2.0-alpha-3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>1.0-alpha-3</version>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</model>
|
||||
|
|
|
@ -72,7 +72,8 @@ public abstract class AbstractEarMojo
|
|||
for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
if ( !Artifact.SCOPE_TEST.equals( artifact.getScope() ) )
|
||||
if ( !Artifact.SCOPE_TEST.equals( artifact.getScope()) ||
|
||||
!Artifact.SCOPE_PROVIDED.equals( artifact.getScope()) )
|
||||
{
|
||||
EarModule module = EarModuleFactory.newEarModule( artifact );
|
||||
modules.add( module );
|
||||
|
|
|
@ -37,12 +37,21 @@ import java.util.List;
|
|||
*/
|
||||
public final class ApplicationXmlWriter
|
||||
{
|
||||
public static final String DOCTYPE_1_3 = "application PUBLIC\n" +
|
||||
"\t\"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN\"\n" +
|
||||
"\t\"http://java.sun.com/dtd/application_1_3.dtd\"";
|
||||
|
||||
private static final String APPLICATION_ELEMENT = "application";
|
||||
|
||||
|
||||
private final String version;
|
||||
|
||||
public ApplicationXmlWriter( String version )
|
||||
private final String encoding;
|
||||
|
||||
public ApplicationXmlWriter( String version, String encoding )
|
||||
{
|
||||
this.version = version;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public void write( File destinationFile, List earModules, String displayName, String description )
|
||||
|
@ -59,10 +68,15 @@ public final class ApplicationXmlWriter
|
|||
ex );
|
||||
}
|
||||
|
||||
// @todo Add DTD or XSchema reference based on version attribute
|
||||
|
||||
XMLWriter writer = new PrettyPrintXMLWriter( w );
|
||||
writer.startElement( "application" );
|
||||
XMLWriter writer = null;
|
||||
if ( GenerateApplicationXmlMojo.VERSION_1_3.equals( version ) )
|
||||
{
|
||||
writer = initializeRootElementOneDotThree( w );
|
||||
}
|
||||
else if ( GenerateApplicationXmlMojo.VERSION_1_4.equals( version ) )
|
||||
{
|
||||
writer = initializeRootElementOneDotFour( w );
|
||||
}
|
||||
|
||||
if ( displayName != null )
|
||||
{
|
||||
|
@ -105,4 +119,23 @@ public final class ApplicationXmlWriter
|
|||
// TODO: warn
|
||||
}
|
||||
}
|
||||
|
||||
private XMLWriter initializeRootElementOneDotThree( FileWriter w )
|
||||
{
|
||||
XMLWriter writer = new PrettyPrintXMLWriter( w, encoding, DOCTYPE_1_3 );
|
||||
writer.startElement( APPLICATION_ELEMENT );
|
||||
return writer;
|
||||
}
|
||||
|
||||
private XMLWriter initializeRootElementOneDotFour( FileWriter w )
|
||||
{
|
||||
XMLWriter writer = new PrettyPrintXMLWriter( w, encoding, null );
|
||||
writer.startElement( APPLICATION_ELEMENT );
|
||||
writer.addAttribute( "xmlns", "http://java.sun.com/xml/ns/j2ee" );
|
||||
writer.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
|
||||
writer.addAttribute( "xsi:schemaLocation",
|
||||
"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" );
|
||||
writer.addAttribute( "version", "1.4" );
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The Ear Mojo.
|
||||
* Builds J2EE Enteprise Archive (EAR) files.
|
||||
*
|
||||
* @author <a href="stephane.nicoll@gmail.com">Stephane Nicoll</a>
|
||||
* @version $Id $
|
||||
|
|
|
@ -23,8 +23,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A <tt>Mojo</tt> used to build the <tt>application.xml</tt> file
|
||||
* if necessary.
|
||||
* A Mojo used to build the application.xml file.
|
||||
*
|
||||
* @author <a href="stephane.nicoll@gmail.com">Stephane Nicoll</a>
|
||||
* @version $Id $
|
||||
|
@ -44,14 +43,15 @@ public class GenerateApplicationXmlMojo
|
|||
public static final String UTF_8 = "UTF-8";
|
||||
|
||||
/**
|
||||
* Inserts the doctype header depending on the specified version.
|
||||
* The version of the application.xml to generate. Valid values
|
||||
* are 1.3 and 1.4.
|
||||
*
|
||||
* @parameter expression="${maven.ear.appxml.version}"
|
||||
*/
|
||||
private String version = VERSION_1_3;
|
||||
|
||||
/**
|
||||
* Display name of the application to be used when <tt>application.xml</tt>
|
||||
* Display name of the application to be used when application.xml
|
||||
* file is autogenerated.
|
||||
*
|
||||
* @parameter expression="${project.artifactId}"
|
||||
|
@ -59,22 +59,22 @@ public class GenerateApplicationXmlMojo
|
|||
private String displayName = null;
|
||||
|
||||
/**
|
||||
* The description in generated <tt>application.xml</tt>.
|
||||
* Description of the application to be used when application.xml
|
||||
* file is autogenerated.
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String description = null;
|
||||
|
||||
/**
|
||||
* Character encoding for the auto-generated <tt>application.xml</tt> file.
|
||||
* Character encoding for the auto-generated application.xml file.
|
||||
*
|
||||
* @parameter
|
||||
* @TODO handle this field
|
||||
*/
|
||||
private String encoding = UTF_8;
|
||||
|
||||
/**
|
||||
* Directory where the <tt>application.xml</tt> file will be auto-generated.
|
||||
* Directory where the application.xml file will be auto-generated.
|
||||
*
|
||||
* @parameter expression="${project.build.directory}"
|
||||
*/
|
||||
|
@ -90,6 +90,11 @@ public class GenerateApplicationXmlMojo
|
|||
getLog().debug( "encoding[" + encoding + "]" );
|
||||
getLog().debug( "generatedDescriptorLocation[" + generatedDescriptorLocation + "]" );
|
||||
|
||||
if ( !version.equals( VERSION_1_3 ) && version.equals( VERSION_1_4 ) )
|
||||
{
|
||||
throw new MojoExecutionException( "Invalid version[" + version + "]" );
|
||||
}
|
||||
|
||||
// Generate deployment descriptor
|
||||
try
|
||||
{
|
||||
|
@ -124,7 +129,7 @@ public class GenerateApplicationXmlMojo
|
|||
descriptor.createNewFile();
|
||||
}
|
||||
|
||||
ApplicationXmlWriter writer = new ApplicationXmlWriter( version );
|
||||
ApplicationXmlWriter writer = new ApplicationXmlWriter( version, encoding );
|
||||
try
|
||||
{
|
||||
writer.write( descriptor, getModules(), displayName, description );
|
||||
|
|
Loading…
Reference in New Issue