0

How can we create a single war file for multiple or diif application code and deoply on single aws enviornment?

2 Answers2

1

Add this to your pom.xml to create war file later to be deployed anywhere!

 <plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
    </configuration>
  </plugin>
  <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-5</version>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
      <appendAssemblyId>false</appendAssemblyId>
    </configuration>
    <executions>
      <execution>
        <id>make-my-jar-with-dependencies</id>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
papaya
  • 1,505
  • 1
  • 13
  • 26
0

The accepted answer explains in general terms how to create a WAR file in Maven.

However you are asking how to create a WAR file for "multiple or diff[erent] application code". The answer depends on what you mean.

  • If you mean a single webapp that has multiple components and / or dependencies, then the accepted answer should work.

  • If you mean a multiple webapps ... there is a problem. A WAR contains a single webapp. There is only one WEB-INFO tree and only one web.xml file in a WAR file. So your options are:

    • Create and deploy multiple WAR files.
    • Try to integrate the separate webapps into a single webapp. This could be as simple as rewriting the web.xml files and combining the WEB-INFO trees. Or it could be more complicated. Then create the WAR for the combined webapp.
    • If your web container supports this, you could create and deploy an EAR file containing multiple webapps; see .war vs .ear file
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216