3 Replies Latest reply on Sep 13, 2012 10:24 AM by ssadeghi

    Package a WAR inside an .esb folder

    rpelisse

      Hi all,

       

      I've been trying for most of the day to have maven add a WAR at the root of my .esb project, without any succes. A quick googling lead me to use the maven-dependency-plugin, and had me half way there. I'm indeed able to add the WAR to the exploded package built in my tagert, but not in my .esb archive.

       

      Let's first do a quick configuration overview of my pom.xml:

       

      ...

      <packaging>jboss-esb</packaging>

      ...

        <dependencies>

          ...

       

          <dependency>

            <groupId>com.systematic.kombit</groupId>

            <artifactId>ws-to-esb</artifactId>

            <version>1.0-SNAPSHOT</version>

            <type>war</type>

          </dependency>

         </dependencies>

      ...

       

            <!-- Packaging plugin for creating .esb artifacts -->

            <plugin>

              <groupId>org.codehaus.mojo</groupId>

              <artifactId>jboss-packaging-maven-plugin</artifactId>

              <version>2.2</version>

              <extensions>true</extensions>

              <executions>

                <execution>

                  <id>build-esb</id>

                  <goals>

                    <goal>esb</goal>

                  </goals>

                </execution>

              </executions>

            </plugin>

      ...

            <plugin>

              <groupId>org.apache.maven.plugins</groupId>

              <artifactId>maven-dependency-plugin</artifactId>

              <version>2.5.1</version>

              <executions>

                <execution>

                  <id>copy</id>

                  <phase>package</phase>

                  <goals>

                    <goal>copy</goal>

                  </goals>

                  <configuration>

                    <artifactItems>

                      <artifactItem>

                        <groupId>com.systematic.kombit</groupId>

                        <artifactId>ws-to-esb</artifactId>

                        <version>1.0-SNAPSHOT</version>

                        <type>war</type>

                        <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>

                      </artifactItem>

                    </artifactItems>

                    <overWriteSnapshots>true</overWriteSnapshots>

                  </configuration>

                </execution>

              </executions>

            </plugin>

       

       

      Important note: As I'm using a newer version of the maven-dependency-plugin than the one used in the example provided in the link below, I cannot use the "prepare-package" phase (otherwise the build failed screaming that I must use the package phase). I think this the root core of my issue, as, when mvn reach 'package' phase, it is already "too late", the .esb archive has been created.

       

      Here is the result of the mvn package execution:

       

      $ ls -1 target/

      classes

      com.systematic.kombit.ws-to-esb.1.0-SNAPSHOT

      com.systematic.kombit.ws-to-esb.1.0-SNAPSHOT.esb

      generated-sources

      maven-archiver

      $ ls -1 target/com.systematic.kombit.ws-to-esb.1.0-SNAPSHOT/

      com

      META-INF

      ws-to-esb-1.0-SNAPSHOT.war

      $ unzip -t target/com.systematic.kombit.ws-to-esb.1.0-SNAPSHOT.esb

      Archive:  target/com.systematic.kombit.ws-to-esb.1.0-SNAPSHOT.esb

          testing: META-INF/                OK

          testing: META-INF/MANIFEST.MF     OK

          testing: com/                     OK

          testing: com/systematic/          OK

          testing: com/systematic/kombit/   OK

          testing: META-INF/jboss-esb.xml   OK

          testing: com/systematic/kombit/MyAction.class   OK

          testing: META-INF/maven/          OK

          testing: META-INF/maven/com.systematic.kombit/   OK

          testing: META-INF/maven/com.systematic.kombit/ws-to-esb/   OK

          testing: META-INF/maven/com.systematic.kombit/ws-to-esb/pom.xml   OK

          testing: META-INF/maven/com.systematic.kombit/ws-to-esb/pom.properties   OK

      No errors detected in compressed data of target/com.systematic.kombit.ws-to-esb.1.0-SNAPSHOT.esb

       

       

      Any clue on how I could fix this ?

        • 1. Re: Package a WAR inside an .esb folder
          tcunning

          I think you should be able to do this without use of the maven-dependency-plugin.      The docs for the jboss-packaging-plugin (http://mojo.codehaus.org/jboss-packaging-maven-plugin/esb-mojo.html) seem to suggest that dependencies will be added to the .esb archive unless you explicitly exclude them - maybe try adding

           

          <dependency>

                            <groupId>com.systematic.kombit</groupId>

                            <artifactId>ws-to-esb</artifactId>

                            <version>1.0-SNAPSHOT</version>

                            <type>war</type>

          </dependency>

           

          to your <dependencies/> and see if it gets picked up?     Worth a try.

           

          If the jboss packaging plugin doesn't work out, another option would be for you to use just default JAR packaging and use the maven assembly plugin and an assembly.xml to put this all together.       You would have to rename your .jar to the .esb extension later, but that would give you the artifact contents you're looking for.

          • 2. Re: Package a WAR inside an .esb folder
            rpelisse

            Hi Tom,

             

            Sorry, I failed to mention, that I started by that. I just added the dependency, and nothing happened (ie - no war in my ESB package). Then, I added the dependency-plugin, based on my googling. I also just checked, I'm using the lastest release from this plugin (2.2)....

            • 3. Re: Package a WAR inside an .esb folder
              ssadeghi

              Hi Romain,

               

              The assembly plugin would be the way as Tom has mentioned. Here is a sample pom.xml:

               

              <build>

              <plugins>

              <plugin>

              <groupId>org.apache.maven.plugins</groupId>

              <artifactId>maven-assembly-plugin</artifactId>

              <version>2.2</version>

              <executions>

              <execution>

              <id>with-war</id>

              <goals>

              <goal>single</goal>

              </goals>

              <phase>package</phase>

              <configuration>

              <descriptors>

              <descriptor>src/assembly/esb.xml</descriptor>

              </descriptors>

              </configuration>

              </execution>

              </executions>

              <dependencies>

              <dependency>

              <groupId>org.codehaus.mojo</groupId>

              <artifactId>jboss-packaging-maven-plugin</artifactId>

              <version>2.2</version>

              </dependency>

              </dependencies>

              </plugin>

              <plugin>

              <groupId>org.codehaus.mojo</groupId>

              <artifactId>jboss-packaging-maven-plugin</artifactId>

              <version>2.2</version>

              <extensions>true</extensions>

              </plugin>

              </plugins>

              </build>

               

               

              An the esb.xml describing the assembly looks like this:

               

              <assembly>

              <id>with-war</id>

              <formats>

              <format>esb</format>

              </formats>

              <includeBaseDirectory>false</includeBaseDirectory>

              <fileSets>

              <fileSet>

              <directory>target/classes</directory>

              <outputDirectory>/</outputDirectory>

              </fileSet>

              </fileSets>

              <dependencySets>

              <dependencySet>

              <includes>

              <include>com.jboss.sample:colorapp</include>

              </includes>

              <outputDirectory>/</outputDirectory>

              </dependencySet>

              </dependencySets>

              </assembly>

               

               

              I have attached the sample project.