I am attempting to use profiles in my project pom.xml file to control deployment of my war file to a particular server. As an example, I have a local profile, and a development server profile. Here is how I have my profiles set up
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>target</name>
<value>local</value>
</property>
</activation>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://10.16.21.60:8080/manager/text</url>
<server>localTomcat</server>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>dev</id>
<activation>
<property>
<name>target</name>
<value>dev</value>
</property>
</activation>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://devserverurl:8080/manager/text</url>
<server>devTomcat</server>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</profile>
I am calling
mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy
When I try this, I can see that instead of trying to connect to the IP address provided in my configuration 10.16.21.60, it is instead attempting to connect to localhost. I have both devTomcat and localTomcat defined in my local settings.xml file with username and password.
If I then add the -X option for more info I can see in the debug output for the plugin (emphasis added)
[DEBUG] Configuring mojo org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy from plugin realm ClassRealm[plugin>org.apache.tomcat.maven:tomcat7-maven-plugin:2.2, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[DEBUG] Configuring mojo 'org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy' with basic configurator -->
[DEBUG] (f) charset = ISO-8859-1
[DEBUG] (f) contextFile = ....
[DEBUG] (f) ignorePackaging = false
[DEBUG] (f) mode = war
[DEBUG] (f) packaging = war
[DEBUG] (f) path = ...
[DEBUG] (f) update = false
[DEBUG] (f) url = http://localhost:8080/manager/text
[DEBUG] (f) version = 2.2
[DEBUG] (f) warFile = ...
[DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@61874b9d
[DEBUG] -- end configuration --
[INFO] Deploying war to http://localhost:8080/...
[DEBUG] No server specified for authentication - using defaults
It does not appear that my configuration settings are being adhered to! The way I thought this would work is that since the local profile is activated, it would use that configuration.
I did also try simply having the plugin defined in my <build> section, without the profiles, with the same effect. It always attempts to connect to http://localhost:8080 with no authentication.
It probably is worth noting that I am also using the gwt-maven-plugin for this project, and I don't know if this could be interfering with the tomcat plugin configuration.
Ok, turns out I was using the wrong
groupIDfor the plugin. It isn'tit is
Works like a champ now!