You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/20 09:33:20 UTC

[maven-ear-plugin] 03/45: Move maven-ear-plugin to maven-plugins

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to annotated tag maven-ear-plugin-2.0
in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git

commit 794551f092b78271da057a9a43dfb7030e82299e
Author: Emmanuel Venisse <ev...@apache.org>
AuthorDate: Mon Jul 4 14:09:46 2005 +0000

    Move maven-ear-plugin to maven-plugins
    
    git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk/maven-plugins/maven-ear-plugin@209082 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 10 ++---
 .../apache/maven/plugin/ear/AbstractEarMojo.java   |  3 +-
 .../maven/plugin/ear/ApplicationXmlWriter.java     | 43 +++++++++++++++++++---
 .../java/org/apache/maven/plugin/ear/EarMojo.java  |  4 +-
 .../plugin/ear/GenerateApplicationXmlMojo.java     | 23 +++++++-----
 5 files changed, 61 insertions(+), 22 deletions(-)

diff --git a/pom.xml b/pom.xml
index c73ccc9..3f7ac99 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,28 +2,28 @@
   <parent>
     <artifactId>maven-plugin-parent</artifactId>
     <groupId>org.apache.maven.plugins</groupId>
-    <version>2.0-alpha-2</version>
+    <version>2.0-beta-1-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <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>
       <artifactId>maven-project</artifactId>
-      <version>2.0-alpha-2</version>
+      <version>2.0-beta-1-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>1.0-alpha-3</version>
+      <version>1.0.1-SNAPSHOT</version>
     </dependency>
   </dependencies>
 </model>
diff --git a/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java b/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
index 7b36e06..12450e5 100644
--- a/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
+++ b/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
@@ -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 );
diff --git a/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriter.java b/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriter.java
index 8f1e05d..050c583 100644
--- a/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriter.java
+++ b/src/main/java/org/apache/maven/plugin/ear/ApplicationXmlWriter.java
@@ -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;
+    }
 }
diff --git a/src/main/java/org/apache/maven/plugin/ear/EarMojo.java b/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
index 85e74e0..8f4ca10 100644
--- a/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
+++ b/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
@@ -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 $
@@ -77,7 +77,7 @@ public class EarMojo
      *
      * @parameter alias="earName" expression="${project.build.finalName}"
      * @required
-     * @readonly
+     * @readonly     
      */
     private String finalName;
 
diff --git a/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java b/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java
index 7e70118..a9c7a5d 100644
--- a/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java
+++ b/src/main/java/org/apache/maven/plugin/ear/GenerateApplicationXmlMojo.java
@@ -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 );

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.