lunes, 2 de marzo de 2015

¿Como armar un EAR con Maven?

Para armar un EAR con Maven podemos utilizar este POM de ejemplo:

Observar que elegimos tener el war expandido:
<unpack>true</unpack>

Hay que previamente instalar en Maven el WAR:

    mvn install:install-file
         -Dfile=c:\javaen\desa\myApiRest\target\myApp-1.0.war 
         -DgroupId=com.mycompany.myApp_war
         -DartifactId=myApp 
         -Dversion=1.0
         -Dpackaging=war





Luego el siguiente pom.xml es valido


<?xml version="1.0" encoding="UTF-8"?>
<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>com.mycompany</groupId>
   <artifactId>myApp.ear</artifactId>
   <packaging>ear</packaging>
   <version>1.0</version>
   <name>myApp Maven Webapp</name>
   <url>http://maven.apache.org</url>
   <properties>
      <spring-security.version>3.2.1.RELEASE</spring-security.version>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <spring.version>4.1.6.RELEASE</spring.version>
      <jdk.version>1.6</jdk.version>
      <java-version>1.6</java-version>
   </properties>
   <dependencies>
      <dependency>
         <groupId>com.mycompany.myApp_war</groupId>
         <artifactId>myApp</artifactId>
         <version>1.0</version>
         <type>war</type>
      </dependency>
   </dependencies>
   <build>
      <finalName>myApp</finalName>
      <plugins>
         <!-- Plugin Para armar un ear ... -->
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.10</version>
            <configuration>
               <modules>
                  <webModule>
                     <groupId>com.mycompany.myApp_war</groupId>
                     <artifactId>myApp</artifactId>
                     <uri>myApp.war</uri>
                     <bundleFileName>myApp.war</bundleFileName>
                     <contextRoot>/myApp</contextRoot>
                     <unpack>true</unpack>
                  </webModule>
               </modules>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>





Apache®, Apache Maven® logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries.

0 comentarios:

Publicar un comentario