0

There are 2 plugin tomcat7-maven-plugin and maven-t7-plugin both have good number of goals, but all of them build war and run tomcat "on the fly" while I need to run tomcat from folder. E. g. there is already downloaded tomcat which is needed to be run. Is there a way to run it simply without building war, download tomcat etc?

The question is not provide an answer because it downloads a tomcat, put a war into it, while it is needed to run already existing tomcat without building war and download tomcat again. May be there is a way to configure tomcat folder for that plugin? But I have not found any property for that.

Community
  • 1
  • 1
Cherry
  • 31,309
  • 66
  • 224
  • 364
  • Possible duplicate of [How to run Tomcat 7 using Maven 2 Tomcat plugin?](http://stackoverflow.com/questions/7801155/how-to-run-tomcat-7-using-maven-2-tomcat-plugin) – Prabhat Jul 18 '16 at 08:19

4 Answers4

2

You can try maven-exec-plugin

<plugin>  
    <groupId>org.codehaus.mojo</groupId>  
    <artifactId>exec-maven-plugin</artifactId>  
    <version>1.1</version>  
    <executions>  
      <execution>  
        <id>stop-tomcat</id>  
        <phase>pre-clean</phase>  
        <goals>  
          <goal>exec</goal>  
        </goals>  
        <configuration>  
        <executable>${tomcat.stop.path}</executable>  
        </configuration>  
      </execution>  
      <execution>  
        <id>start-tomcat</id>  
        <phase>deploy</phase>  
        <goals>  
          <goal>exec</goal>  
        </goals>  
        <configuration>  
        <executable>${tomcat.start.path}</executable>    
        </configuration>  
      </execution>  
    </executions>  
  </plugin>  
sidgate
  • 14,650
  • 11
  • 68
  • 119
2

tomcat7-maven-plugin is not for that purpose.

if you want your normal tomcat instance to run when building... you will simply have to start it before building, or find another way to run it.. maybe the maven-exec, like mentioned, will do

tomcat7-maven-plugin deploys your build to a test instance of tomcat that will be terminated after the test are done.

Master Azazel
  • 612
  • 1
  • 12
  • 32
1

You can use exec-maven-plugin (http://www.mojohaus.org/exec-maven-plugin/index.html) to execute a command line from maven.

Ha Doan
  • 135
  • 1
  • 11
0

Use cargo plugin

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <version>1.6.6</version>
  <configuration>
    <container>
      <containerId>tomcat7x</containerId>
      <zipUrlInstaller>
        <url>https://archive.apache.org/dist/tomcat/tomcat-7/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip</url>
      </zipUrlInstaller>
    </container>
    <configuration>
      <type>standalone</type>
      <properties>
        <cargo.servlet.port>${cargo.servlet.port}</cargo.servlet.port>
        <cargo.jvmargs>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${cargo.debug.address}</cargo.jvmargs>
      </properties>
    </configuration>
  </configuration>
</plugin>

Activate via profile:

<profile>
    <id>cargo</id>
    <properties>
        <tomcat.version>7.0.42</tomcat.version>
        <cargo.servlet.port>6280</cargo.servlet.port>
        <cargo.debug.address>8000</cargo.debug.address>
    </properties>
    <build>
        <defaultGoal>cargo:run</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</profile>
Jakub Bochenski
  • 3,113
  • 4
  • 33
  • 61