diff --git a/src/main/java/org/apache/maven/plugins/ear/AbstractXmlWriter.java b/src/main/java/org/apache/maven/plugins/ear/AbstractXmlWriter.java
index fe3603b7..c22bc692 100644
--- a/src/main/java/org/apache/maven/plugins/ear/AbstractXmlWriter.java
+++ b/src/main/java/org/apache/maven/plugins/ear/AbstractXmlWriter.java
@@ -37,16 +37,12 @@ abstract class AbstractXmlWriter
private final String encoding;
- protected static final String MODULE_ELEMENT = "module";
-
- protected static final String SERVICE_ELEMENT = "service";
-
AbstractXmlWriter( String encoding )
{
this.encoding = encoding;
}
- protected Writer initializeWriter( final File destinationFile )
+ Writer initializeWriter( final File destinationFile )
throws EarPluginException
{
try
@@ -55,36 +51,13 @@ protected Writer initializeWriter( final File destinationFile )
}
catch ( IOException ex )
{
- // CHECKSTYLE_OFF: LineLength
- throw new EarPluginException( "Exception while opening file[" + destinationFile.getAbsolutePath() + "]", ex );
- // CHECKSTYLE_ON: LineLength
+ throw new EarPluginException(
+ "Exception while opening file[" + destinationFile.getAbsolutePath() + "]", ex );
}
}
- protected XMLWriter initializeXmlWriter( final Writer writer, final String docType )
+ XMLWriter initializeXmlWriter( final Writer writer, final String docType )
{
return new PrettyPrintXMLWriter( writer, encoding, docType );
}
-
- protected void close( Writer closeable )
- {
- if ( closeable == null )
- {
- return;
- }
-
- try
- {
- closeable.close();
- }
- catch ( Exception e )
- {
- // TODO: warn
- }
- }
-
- public String getEncoding()
- {
- return encoding;
- }
}
diff --git a/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java b/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java
index c8058af3..7b2a8b4f 100644
--- a/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java
+++ b/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java
@@ -19,13 +19,14 @@
* under the License.
*/
+import java.io.IOException;
import java.io.Writer;
import org.apache.maven.plugins.ear.util.JavaEEVersion;
import org.codehaus.plexus.util.xml.XMLWriter;
/**
- * An XmlWriter based implementation used to generate an application.xml file
+ * An XmlWriter
based implementation used to generate an application.xml file.
*
* @author Stephane Nicoll
*/
@@ -51,103 +52,106 @@ final class ApplicationXmlWriter
this.generateModuleId = generateModuleId;
}
- public void write( ApplicationXmlWriterContext context )
+ void write( ApplicationXmlWriterContext context )
throws EarPluginException
{
- Writer w = initializeWriter( context.getDestinationFile() );
-
- XMLWriter writer = null;
- if ( JavaEEVersion.ONE_DOT_THREE.eq( version ) )
- {
- writer = initializeRootElementOneDotThree( w );
- }
- else if ( JavaEEVersion.ONE_DOT_FOUR.eq( version ) )
- {
- writer = initializeRootElementOneDotFour( w );
- }
- else if ( JavaEEVersion.FIVE.eq( version ) )
- {
- writer = initializeRootElementFive( w );
- }
- else if ( JavaEEVersion.SIX.eq( version ) )
- {
- writer = initializeRootElementSix( w );
- }
- else if ( JavaEEVersion.SEVEN.eq( version ) )
- {
- writer = initializeRootElementSeven( w );
- }
- else if ( JavaEEVersion.EIGHT.eq( version ) )
- {
- writer = initializeRootElementEight( w );
- }
-
- // writer is still on root element, so we can still add this attribute
- if ( context.getApplicationId() != null )
- {
- writer.addAttribute( "id", context.getApplicationId() );
- }
-
- // As from JavaEE6
- if ( version.ge( JavaEEVersion.SIX ) )
- {
- writeApplicationName( context.getApplicationName(), writer );
- }
-
- // IMPORTANT: the order of the description and display-name elements was
- // reversed between J2EE 1.3 and J2EE 1.4.
- if ( version.eq( JavaEEVersion.ONE_DOT_THREE ) )
- {
- writeDisplayName( context.getDisplayName(), writer );
- writeDescription( context.getDescription(), writer );
- }
- else
- {
- writeDescription( context.getDescription(), writer );
- writeDisplayName( context.getDisplayName(), writer );
- }
-
- // As from JavaEE6
- if ( version.ge( JavaEEVersion.SIX ) )
- {
- writeInitializeInOrder( context.getInitializeInOrder(), writer );
- }
-
- // Do not change this unless you really know what you're doing :)
- for ( EarModule module : context.getEarModules() )
- {
- module.appendModule( writer, version.getVersion(), generateModuleId );
- }
-
- for ( SecurityRole securityRole : context.getSecurityRoles() )
- {
- securityRole.appendSecurityRole( writer );
- }
-
- if ( version.ge( JavaEEVersion.FIVE ) )
+ try ( Writer w = initializeWriter( context.getDestinationFile() ) )
{
- writeLibraryDirectory( context.getLibraryDirectory(), writer );
- }
-
- if ( version.ge( JavaEEVersion.SIX ) )
- {
- for ( EnvEntry envEntry : context.getEnvEntries() )
+ XMLWriter writer = null;
+ if ( JavaEEVersion.ONE_DOT_THREE.eq( version ) )
{
- envEntry.appendEnvEntry( writer );
+ writer = initializeRootElementOneDotThree( w );
}
- for ( EjbRef ejbEntry : context.getEjbEntries() )
+ else if ( JavaEEVersion.ONE_DOT_FOUR.eq( version ) )
{
- ejbEntry.appendEjbRefEntry( writer );
+ writer = initializeRootElementOneDotFour( w );
}
- for ( ResourceRef resourceEntry : context.getResourceRefs() )
+ else if ( JavaEEVersion.FIVE.eq( version ) )
{
- resourceEntry.appendResourceRefEntry( writer );
+ writer = initializeRootElementFive( w );
}
+ else if ( JavaEEVersion.SIX.eq( version ) )
+ {
+ writer = initializeRootElementSix( w );
+ }
+ else if ( JavaEEVersion.SEVEN.eq( version ) )
+ {
+ writer = initializeRootElementSeven( w );
+ }
+ else if ( JavaEEVersion.EIGHT.eq( version ) )
+ {
+ writer = initializeRootElementEight( w );
+ }
+
+ // writer is still on root element, so we can still add this attribute
+ if ( context.getApplicationId() != null )
+ {
+ writer.addAttribute( "id", context.getApplicationId() );
+ }
+
+ // As from JavaEE6
+ if ( version.ge( JavaEEVersion.SIX ) )
+ {
+ writeApplicationName( context.getApplicationName(), writer );
+ }
+
+ // IMPORTANT: the order of the description and display-name elements was
+ // reversed between J2EE 1.3 and J2EE 1.4.
+ if ( version.eq( JavaEEVersion.ONE_DOT_THREE ) )
+ {
+ writeDisplayName( context.getDisplayName(), writer );
+ writeDescription( context.getDescription(), writer );
+ }
+ else
+ {
+ writeDescription( context.getDescription(), writer );
+ writeDisplayName( context.getDisplayName(), writer );
+ }
+
+ // As from JavaEE6
+ if ( version.ge( JavaEEVersion.SIX ) )
+ {
+ writeInitializeInOrder( context.getInitializeInOrder(), writer );
+ }
+
+ // Do not change this unless you really know what you're doing :)
+ for ( EarModule module : context.getEarModules() )
+ {
+ module.appendModule( writer, version.getVersion(), generateModuleId );
+ }
+
+ for ( SecurityRole securityRole : context.getSecurityRoles() )
+ {
+ securityRole.appendSecurityRole( writer );
+ }
+
+ if ( version.ge( JavaEEVersion.FIVE ) )
+ {
+ writeLibraryDirectory( context.getLibraryDirectory(), writer );
+ }
+
+ if ( version.ge( JavaEEVersion.SIX ) )
+ {
+ for ( EnvEntry envEntry : context.getEnvEntries() )
+ {
+ envEntry.appendEnvEntry( writer );
+ }
+ for ( EjbRef ejbEntry : context.getEjbEntries() )
+ {
+ ejbEntry.appendEjbRefEntry( writer );
+ }
+ for ( ResourceRef resourceEntry : context.getResourceRefs() )
+ {
+ resourceEntry.appendResourceRefEntry( writer );
+ }
+ }
+
+ writer.endElement();
+ }
+ catch ( IOException ex )
+ {
+ // ignore
}
-
- writer.endElement();
-
- close( w );
}
private void writeApplicationName( String applicationName, XMLWriter writer )
@@ -249,10 +253,8 @@ private XMLWriter initializeRootElementSeven( Writer w )
writer.startElement( APPLICATION_ELEMENT );
writer.addAttribute( "xmlns", "http://xmlns.jcp.org/xml/ns/javaee" );
writer.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
- // CHECKSTYLE_OFF: LineLength
writer.addAttribute( "xsi:schemaLocation",
- "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" );
- // CHECKSTYLE_ON: LineLength
+ "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" );
writer.addAttribute( "version", "7" );
return writer;
}
@@ -263,10 +265,8 @@ private XMLWriter initializeRootElementEight( Writer w )
writer.startElement( APPLICATION_ELEMENT );
writer.addAttribute( "xmlns", "http://xmlns.jcp.org/xml/ns/javaee" );
writer.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
- // CHECKSTYLE_OFF: LineLength
writer.addAttribute( "xsi:schemaLocation",
- "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_8.xsd" );
- // CHECKSTYLE_ON: LineLength
+ "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_8.xsd" );
writer.addAttribute( "version", "8" );
return writer;
}
diff --git a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
index e7476384..cd0007e0 100644
--- a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
@@ -754,13 +754,19 @@ private void changeManifestClasspath( EarModule module, File original, JavaEEVer
// Create a temporary work directory
// MEAR-167 use uri as directory to prevent merging of artifacts with the same artifactId
workDirectory = new File( new File( getTempFolder(), "temp" ), module.getUri() );
- workDirectory.mkdirs();
- getLog().debug( "Created a temporary work directory: " + workDirectory.getAbsolutePath() );
-
- // Unpack the archive to a temporary work directory
- zipUnArchiver.setSourceFile( original );
- zipUnArchiver.setDestDirectory( workDirectory );
- zipUnArchiver.extract();
+ if ( workDirectory.mkdirs() )
+ {
+ getLog().debug( "Created a temporary work directory: " + workDirectory.getAbsolutePath() );
+
+ // Unpack the archive to a temporary work directory
+ zipUnArchiver.setSourceFile( original );
+ zipUnArchiver.setDestDirectory( workDirectory );
+ zipUnArchiver.extract();
+ }
+ else
+ {
+ throw new MojoFailureException( "Failed to create directory " + workDirectory );
+ }
}
else
{
@@ -772,21 +778,18 @@ private void changeManifestClasspath( EarModule module, File original, JavaEEVer
boolean newMetaInfCreated = metaInfDirectory.mkdirs();
if ( newMetaInfCreated )
{
- // CHECKSTYLE_OFF: LineLength
- getLog().debug( "This project did not have a META-INF directory before, so a new directory was created." );
- // CHECKSTYLE_ON: LineLength
+ getLog().debug(
+ "This project did not have a META-INF directory before, so a new directory was created." );
}
- File newCreatedManifestFile = new File( metaInfDirectory, "MANIFEST.MF" );
- boolean newManifestCreated = newCreatedManifestFile.createNewFile();
+ File manifestFile = new File( metaInfDirectory, "MANIFEST.MF" );
+ boolean newManifestCreated = manifestFile.createNewFile();
if ( newManifestCreated )
{
- // CHECKSTYLE_OFF: LineLength
- getLog().debug( "This project did not have a META-INF/MANIFEST.MF file before, so a new file was created." );
- // CHECKSTYLE_ON: LineLength
+ getLog().debug(
+ "This project did not have a META-INF/MANIFEST.MF file before, so a new file was created." );
}
- // Read the manifest from disk
- Manifest mf = new Manifest( new FileInputStream( newCreatedManifestFile ) );
+ Manifest mf = readManifest( manifestFile );
Attribute classPath = mf.getMainSection().getAttribute( "Class-Path" );
List classPathElements = new ArrayList();
@@ -808,10 +811,8 @@ private void changeManifestClasspath( EarModule module, File original, JavaEEVer
// We use the original name, cause in case of outputFileNameMapping
// we could not not delete it and it will end up in the resulting EAR and the WAR
// will not be cleaned up.
- // CHECKSTYLE_OFF: LineLength
File artifact = new File( new File( workDirectory, module.getLibDir() ),
module.getArtifact().getFile().getName() );
- // CHECKSTYLE_ON: LineLength
// MEAR-217
// If WAR contains files with timestamps, but EAR strips them away (useBaseVersion=true)
@@ -873,7 +874,7 @@ private void changeManifestClasspath( EarModule module, File original, JavaEEVer
mf.getMainSection().addConfiguredAttribute( classPath );
// Write the manifest to disk
- try ( FileOutputStream out = new FileOutputStream( newCreatedManifestFile );
+ try ( FileOutputStream out = new FileOutputStream( manifestFile );
OutputStreamWriter writer = new OutputStreamWriter( out, StandardCharsets.UTF_8 ) )
{
mf.write( writer );
@@ -898,4 +899,15 @@ private void changeManifestClasspath( EarModule module, File original, JavaEEVer
throw new MojoFailureException( e.getMessage(), e );
}
}
+
+ private static Manifest readManifest( File manifestFile )
+ throws IOException
+ {
+ // Read the manifest from disk
+ try ( FileInputStream in = new FileInputStream( manifestFile ) )
+ {
+ Manifest manifest = new Manifest( in );
+ return manifest;
+ }
+ }
}
diff --git a/src/main/java/org/apache/maven/plugins/ear/JbossAppXmlWriter.java b/src/main/java/org/apache/maven/plugins/ear/JbossAppXmlWriter.java
index 9825cf9d..e3dd73ff 100644
--- a/src/main/java/org/apache/maven/plugins/ear/JbossAppXmlWriter.java
+++ b/src/main/java/org/apache/maven/plugins/ear/JbossAppXmlWriter.java
@@ -20,6 +20,7 @@
*/
import java.io.File;
+import java.io.IOException;
import java.io.Writer;
import java.util.List;
@@ -47,6 +48,10 @@ final class JbossAppXmlWriter
+ "\t\"http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd\"";
private static final String JBOSS_APP_ELEMENT = "jboss-app";
+
+ private static final String MODULE_ELEMENT = "module";
+
+ private static final String SERVICE_ELEMENT = "service";
JbossAppXmlWriter( String encoding )
{
@@ -56,135 +61,138 @@ final class JbossAppXmlWriter
public void write( File destinationFile, JbossConfiguration jbossConfiguration, List earModules )
throws EarPluginException
{
- final Writer w = initializeWriter( destinationFile );
-
- XMLWriter writer;
- if ( jbossConfiguration.isJbossThreeDotTwo() )
+ try ( Writer w = initializeWriter( destinationFile ) )
{
- writer = initializeXmlWriter( w, DOCTYPE_3_2 );
- }
- else if ( jbossConfiguration.isJbossFour() )
- {
- writer = initializeXmlWriter( w, DOCTYPE_4 );
- }
- else if ( jbossConfiguration.isJbossFourDotTwo() )
- {
- writer = initializeXmlWriter( w, DOCTYPE_4_2 );
- }
- else
- {
- writer = initializeXmlWriter( w, DOCTYPE_5 );
- }
- writer.startElement( JBOSS_APP_ELEMENT );
-
- // Make sure to write the things in the right order so that the DTD validates
-
- // module-order (only available as from 4.2)
- if ( jbossConfiguration.isJbossFourDotTwoOrHigher() && jbossConfiguration.getModuleOrder() != null )
- {
- writer.startElement( JbossConfiguration.MODULE_ORDER );
- writer.writeText( jbossConfiguration.getModuleOrder() );
- writer.endElement();
- }
-
- // If JBoss 4, write the jboss4 specific stuff
- if ( jbossConfiguration.isJbossFourOrHigher() )
- {
- if ( jbossConfiguration.getSecurityDomain() != null )
+ XMLWriter writer;
+ if ( jbossConfiguration.isJbossThreeDotTwo() )
{
- writer.startElement( JbossConfiguration.SECURITY_DOMAIN );
- writer.writeText( jbossConfiguration.getSecurityDomain() );
- writer.endElement();
+ writer = initializeXmlWriter( w, DOCTYPE_3_2 );
}
- if ( jbossConfiguration.getUnauthenticatedPrincipal() != null )
+ else if ( jbossConfiguration.isJbossFour() )
{
- writer.startElement( JbossConfiguration.UNAUHTHENTICTED_PRINCIPAL );
- writer.writeText( jbossConfiguration.getUnauthenticatedPrincipal() );
- writer.endElement();
+ writer = initializeXmlWriter( w, DOCTYPE_4 );
}
- }
-
- // classloader repository
- // CHECKSTYLE_OFF: LineLength
- if ( jbossConfiguration.getLoaderRepository() != null || jbossConfiguration.getLoaderRepositoryConfig() != null )
- // CHECKSTYLE_ON: LineLength
- {
- writer.startElement( JbossConfiguration.LOADER_REPOSITORY );
-
- // classloader repository class
- if ( jbossConfiguration.getLoaderRepositoryClass() != null )
+ else if ( jbossConfiguration.isJbossFourDotTwo() )
{
- writer.addAttribute( JbossConfiguration.LOADER_REPOSITORY_CLASS_ATTRIBUTE,
- jbossConfiguration.getLoaderRepositoryClass() );
+ writer = initializeXmlWriter( w, DOCTYPE_4_2 );
}
-
- // we don't need to write any text if only the loader repo configuration is changed
- if ( jbossConfiguration.getLoaderRepository() != null )
+ else
{
- writer.writeText( jbossConfiguration.getLoaderRepository() );
+ writer = initializeXmlWriter( w, DOCTYPE_5 );
}
-
- // classloader configuration
- if ( jbossConfiguration.getLoaderRepositoryConfig() != null )
+ writer.startElement( JBOSS_APP_ELEMENT );
+
+ // Make sure to write the things in the right order so that the DTD validates
+
+ // module-order (only available as from 4.2)
+ if ( jbossConfiguration.isJbossFourDotTwoOrHigher() && jbossConfiguration.getModuleOrder() != null )
{
- writer.startElement( JbossConfiguration.LOADER_REPOSITORY_CONFIG );
-
- // classloader configuration parser
- if ( jbossConfiguration.getConfigParserClass() != null )
+ writer.startElement( JbossConfiguration.MODULE_ORDER );
+ writer.writeText( jbossConfiguration.getModuleOrder() );
+ writer.endElement();
+ }
+
+ // If JBoss 4, write the jboss4 specific stuff
+ if ( jbossConfiguration.isJbossFourOrHigher() )
+ {
+ if ( jbossConfiguration.getSecurityDomain() != null )
+ {
+ writer.startElement( JbossConfiguration.SECURITY_DOMAIN );
+ writer.writeText( jbossConfiguration.getSecurityDomain() );
+ writer.endElement();
+ }
+ if ( jbossConfiguration.getUnauthenticatedPrincipal() != null )
+ {
+ writer.startElement( JbossConfiguration.UNAUHTHENTICTED_PRINCIPAL );
+ writer.writeText( jbossConfiguration.getUnauthenticatedPrincipal() );
+ writer.endElement();
+ }
+ }
+
+ // classloader repository
+ if ( jbossConfiguration.getLoaderRepository() != null
+ || jbossConfiguration.getLoaderRepositoryConfig() != null )
+ {
+ writer.startElement( JbossConfiguration.LOADER_REPOSITORY );
+
+ // classloader repository class
+ if ( jbossConfiguration.getLoaderRepositoryClass() != null )
{
- writer.addAttribute( JbossConfiguration.CONFIG_PARSER_CLASS_ATTRIBUTE,
- jbossConfiguration.getConfigParserClass() );
+ writer.addAttribute( JbossConfiguration.LOADER_REPOSITORY_CLASS_ATTRIBUTE,
+ jbossConfiguration.getLoaderRepositoryClass() );
}
- writer.writeText( jbossConfiguration.getLoaderRepositoryConfig() );
+
+ // we don't need to write any text if only the loader repo configuration is changed
+ if ( jbossConfiguration.getLoaderRepository() != null )
+ {
+ writer.writeText( jbossConfiguration.getLoaderRepository() );
+ }
+
+ // classloader configuration
+ if ( jbossConfiguration.getLoaderRepositoryConfig() != null )
+ {
+ writer.startElement( JbossConfiguration.LOADER_REPOSITORY_CONFIG );
+
+ // classloader configuration parser
+ if ( jbossConfiguration.getConfigParserClass() != null )
+ {
+ writer.addAttribute( JbossConfiguration.CONFIG_PARSER_CLASS_ATTRIBUTE,
+ jbossConfiguration.getConfigParserClass() );
+ }
+ writer.writeText( jbossConfiguration.getLoaderRepositoryConfig() );
+ writer.endElement();
+ }
+
writer.endElement();
}
-
- writer.endElement();
- }
-
- // jmx name
- if ( jbossConfiguration.getJmxName() != null )
- {
- writer.startElement( JbossConfiguration.JMX_NAME );
- writer.writeText( jbossConfiguration.getJmxName() );
- writer.endElement();
- }
-
- // library-directory (only available as from 4.2)
- if ( jbossConfiguration.isJbossFourDotTwoOrHigher() && jbossConfiguration.getLibraryDirectory() != null )
- {
- writer.startElement( JbossConfiguration.LIBRARY_DIRECTORY );
- writer.writeText( jbossConfiguration.getLibraryDirectory() );
- writer.endElement();
- }
-
- // Modules
-
- List dataSources = jbossConfiguration.getDataSources();
- // Write out data source modules first
- if ( dataSources != null )
- {
- for ( String dsPath : dataSources )
+
+ // jmx name
+ if ( jbossConfiguration.getJmxName() != null )
{
- writer.startElement( MODULE_ELEMENT );
- writer.startElement( SERVICE_ELEMENT );
- writer.writeText( dsPath );
+ writer.startElement( JbossConfiguration.JMX_NAME );
+ writer.writeText( jbossConfiguration.getJmxName() );
writer.endElement();
+ }
+
+ // library-directory (only available as from 4.2)
+ if ( jbossConfiguration.isJbossFourDotTwoOrHigher() && jbossConfiguration.getLibraryDirectory() != null )
+ {
+ writer.startElement( JbossConfiguration.LIBRARY_DIRECTORY );
+ writer.writeText( jbossConfiguration.getLibraryDirectory() );
writer.endElement();
}
- }
-
- // Write the JBoss specific modules
- for ( EarModule earModule : earModules )
- {
- if ( JbossEarModule.class.isInstance( earModule ) )
+
+ // Modules
+
+ List dataSources = jbossConfiguration.getDataSources();
+ // Write out data source modules first
+ if ( dataSources != null )
{
- JbossEarModule jbossEarModule = (JbossEarModule) earModule;
- jbossEarModule.appendJbossModule( writer, jbossConfiguration.getVersion() );
+ for ( String dsPath : dataSources )
+ {
+ writer.startElement( MODULE_ELEMENT );
+ writer.startElement( SERVICE_ELEMENT );
+ writer.writeText( dsPath );
+ writer.endElement();
+ writer.endElement();
+ }
}
- }
- writer.endElement();
+
+ // Write the JBoss specific modules
+ for ( EarModule earModule : earModules )
+ {
+ if ( JbossEarModule.class.isInstance( earModule ) )
+ {
+ JbossEarModule jbossEarModule = (JbossEarModule) earModule;
+ jbossEarModule.appendJbossModule( writer, jbossConfiguration.getVersion() );
+ }
+ }
+ writer.endElement();
- close( w );
+ }
+ catch ( IOException ex )
+ {
+ throw new EarPluginException( ex );
+ }
}
}
\ No newline at end of file
diff --git a/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java b/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
index a9dcb447..61207926 100644
--- a/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
+++ b/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.util.Properties;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
@@ -208,14 +209,14 @@ public void testProject016()
final File sourceManifestFile = new File( baseDir, "src/main/ear/MANIFEST.MF" );
- JarFile jarFile = new JarFile( createdEarFile );
- Manifest manifestFromCreatedEARFile = jarFile.getManifest();
- jarFile.close();
-
- Manifest sourceManifest = new Manifest( new FileInputStream( sourceManifestFile ) );
-
- assertTrue( "There are differences in the manifest.", sourceManifest.equals( manifestFromCreatedEARFile ) );
- }
+ try ( JarFile jarFile = new JarFile( createdEarFile );
+ FileInputStream in = new FileInputStream( sourceManifestFile ) )
+ {
+ Manifest manifestFromCreatedEARFile = jarFile.getManifest();
+ Manifest sourceManifest = new Manifest( in );
+ assertEquals( "There are differences in the manifest.", sourceManifest, manifestFromCreatedEARFile );
+ }
+ }
/**
* Builds an EAR and make sure that custom application.xml is taken into account.