Create a WAR file from pom.xml for an existing Maven project

I am creating a web project and I was told that it should be inside the resources directory of an existing maven project

Here is the project structure

MavenProject
  |-- src
  |   |-- main
  |   `-- resources
  |       `-- My-Web-Project
  |           |-- META-INF
  |           |    `-- MANIFEST.MF
  |           |-- src
  |           |   |-- classes
  |           |   |   |-- com
  |           |   |   |   `-- example
  |           |   |   |       `-- projects
  |           |   |   |           `-- SampleAction.class
  |           `-- web
  |               |-- css
  |               |-- css
  |               |-- img
  |               |-- js
  |               |-- WEB-INF
  |               |   `-- web.xml 
  |               |-- index.jsp
  |               `-- secondary.jsp
  |-- test
  `-- pom.xml

As you can see, there is already a pom.xml file for MavenProject. I want to be able to deploy my WAR web project using the current pom.xml.

I want to know if this can be done and how I can start creating the Maven plugin.

I read this article, but I do not know if this applies to my situation http://maven.apache.org/plugins/maven-war-plugin/usage.html

EDIT:

I am using tomcat application server.

As mentioned earlier, my project "My-Web-Project" must be under "resources"

+4
2

, , .

Maven,

( )

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.4</version>
    <configuration>
      <webResources>
        <resource>
          <!-- this is relative to the pom.xml directory -->
          <directory>src/main/resources/My-Web-Project/web</directory>
        </resource>
      </webResources>
    </configuration>
  </plugin>

, target .


Maven -

, (-) maven

, - !

Maven Convention over Configuration.

- - . , . , " ".

.

:

MavenProject
   |-- src
   |   |-- main
   |   |   `-- java
   |   |       `-- com
   |   |           `-- example
   |   |               `-- projects
   |   |                   `-- SampleAction.java
   |   `-- resources
   |   |   `-- META-INF
   |   |       `-- MANIFEST.MF
   |   `-- webapp
   |        |-- css
   |        |-- img
   |        |-- js
   |        |-- WEB-INF
   |        |   `-- web.xml
   |        |-- index.jsp
   |        `-- secondary.jsp
   |-- test
   |-- target  // this is generated by maven!
   |   |-- classes
   |   |   `-- com
   |   |       `-- example
   |   |           `-- projects
   |   |               `-- SampleAction.class
   `-- pom.xml

:

+7

? maven, , : jboss-maven-plugin, tomcat-maven-plugin.

maven. , , maven .

+3

All Articles