0

I was using maven's tomcat plugin for deploying my web application to tomcat server. now i need the same war file in a different location(not directly deploy to tomcat server.). So that i can manually copy my war file to another machine's and deploy it.

My current pom.xml configuration is

      <profiles>
    <profile>
        <id>staging</id>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.apache.tomcat.maven</groupId>
                        <artifactId>tomcat7-maven-plugin</artifactId>
                        <version>2.2</version>
                        <configuration>
                             <url>http://localhost:8080/manager/text</url>
                            <server>mytomcat</server>
                            <path>/project1</path>
                                <username>xxxxxxx</username>
                            <password>xxxxxxxx</password>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </profile>
Shamseer PC
  • 787
  • 2
  • 9
  • 20

2 Answers2

1

You can use profiles.

<profiles>
    <profile>
        <id>otherOutputDir</id>
        <build>
            <directory>yourDirectory</directory>
        </build>
    </profile>
</profiles>

Refer

Maven: How to change path to target directory from command line? and

Maven: specify the outputDirectory only for packaging a jar?

Alien
  • 15,141
  • 6
  • 37
  • 57
0

The easiest way would be to add the Spring Boot Maven Plugin to your project's pom.xml (with Maven 3.2 or later) as shown below:

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.0.5.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

along with the type of artifact that you need, ie jar or war within the project tag of your pom as shown below:

<packaging>war</packaging>

Next whenever you run the package phase of maven (with mvn package command for eg), the artifact would be generated within the target folder. More info on the same is provided in the Spring documentation here.

For other ways of generating the war/jar artifact, please refer to this Baeldung article.

Madhu Bhat
  • 13,559
  • 2
  • 38
  • 54