|
MavenSeamHotdeployPluginUsage
How to use the Seam hotdeploy Maven plugin
Seam Hotdeploy Maven Plugin UsageThe Seam Hotdeploy plugin allows you to build a Maven WAR project directly into a JBoss installation. This includes copying config files as well as XHTML/JSPs, and taking care about copying hot deployable classes into WEB-INF/dev instead of WEB-INF/classes. Tested with:
Seam Project SetupWe propose following Maven setup for your Seam WAR project: src
|-- main
|-- java (Your entities, JSF classes, custom Identity component, ...)
|-- hot (Your hot deploy components)
|-- resources (Your config files, META-INF/persistence.xml, META-INF/components.xml, seam.properties etc.)
|-- webapp (Your XHTMLs, WEB-INF/faces-config.xml, WEB-INF/pages.xml, ...)
|-- test
|-- java (Your test classes)
|-- resources (Your test config files, components.properties, seam.properties, ...)
|-- bootstrap (Embeddable JBoss config files)UPDATE: For embedding the WAR inside an EAR, see further descriptions here. Project POM ConfigurationAdd the following plugin repositories to your POM: <pluginRepositories>
<pluginRepository>
<id>ctpjava</id>
<name>CTP Public Repository</name>
<url>http://ctpjava.googlecode.com/svn/trunk/repository</url>
</pluginRepository>
<pluginRepository>
<id>repository.jboss.org</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2</url>
</pluginRepository>
</pluginRepositories>Use the build helper plugin to add the hot source folder to your Maven build, and integrate the CLI plugin for much more build convenience: <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/src/main/hot</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>maven-cli-plugin</artifactId>
<configuration>
<userAliases>
<hot>hotdeploy:exploded -o -Pdevelopment</hot>
<cln>clean -o -Pdevelopment</cln>
</userAliases>
</configuration>
</plugin>Add the additional test resource folders to your build: <testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/test/bootstrap</directory>
</testResource>
<testResource>
<directory>src/main/webapp</directory>
</testResource>
</testResources>Plugin ConfigurationNow for the plugin configuration. Create a dedicated build profile in your POM. We will change the behavior of the clean plugin there as well: <profile>
<id>development</id>
<build>
<defaultGoal>hotdeploy:exploded</defaultGoal>
...Add the following plugins to the profile build: <plugin>
<groupId>com.ctp.seam.maven</groupId>
<artifactId>maven-hotdeploy-plugin</artifactId>
<version>0.2.1</version>
<configuration>
<source>${java.source.version}</source>
<target>${java.source.version}</target>
<sourceDirectory>src/main/hot</sourceDirectory>
<deployDirectory>
${directory.deploy.jboss}/${build.finalName}.${project.packaging}
</deployDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.2</version>
<configuration>
<filesets>
<fileset>
<directory>${directory.deploy.jboss}</directory>
<includes>
<include>**/${build.finalName}.${project.packaging}*</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>Add appropriate values in the POMs properties section. Values to replace are:
You can also overwrite the WAR file name if you want to get rid of the version number. Add this to your build config or to your development profile. <finalName>${project.artifactId}</finalName>For a complete POM example see the sample POM Wiki page. Run the PluginOn the command line, first type mvn cli:execute-phase which starts a 'Maven shell' from the CLI plugin, speeding up reexecutions. From here, start the build with the alias maven2> hot (which stands for mvn hotdeploy:exploded -P development). This will deploy your WAR file into the JBoss deploy folder. If you need to clean out your running application first, use maven2> cln hot If you have a multi-module project, make sure this is only run on the web module. |
Sign in to add a comment
Hi Thomas,
Nice plugin it was working fine last week but it doesnt work anymore. When I do mvn clean hotdeploy:exploded it fails with: INFO? The plugin 'org.apache.maven.plugins:maven-hotdeploy-plugin' does not exist or no valid version could be found
I have to do the following command to bypass this error message:
mvn clean com.ctp.seam.maven:maven-hotdeploy-plugin:0.2.1:exploded
unfortunately property interpolation doesn't seem to work when calling the plugin that way.
A maven dev is telling me that such plugin setup is not recommended read below:
"The plugin groupId Maven is looking for is org.apache.maven.plugins. The groupId of your plugin must be something different.
I bet you're doing "mvn hotdeploy" and hoping it will just work. Try "mvn (groupId):maven-hotdeploy-plugin:(version):hotdeploy", assuming "hotdeploy" is the name of your Mojo. Also, you should not use the artifactId maven--plugin since that is reserved for official Maven plugins."
Hi,
I created a Seam project with the "JBoss Seam Maven Archetype - WAR only Project". Everything works great, and it seems that it is already configured with maven-hotdeploy-plugin and maven-cli-plugin.
If I run mvn cli:execute-phase and the hot I get this: maven2> hot INFO? Scanning for projects... INFO? Reactor build order: INFO? myproject? INFO? :: JBoss Configuration? INFO? :: Web Application? INFO? ------------------------------------------------------------------------ ERROR? BUILD FAILURE INFO? ------------------------------------------------------------------------ INFO? Invalid task 'hot': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupI d:pluginArtifactId:pluginVersion:goal INFO? ------------------------------------------------------------------------ INFO? Trace org.apache.maven.BuildFailureException?: Invalid task 'hot': you must specify a valid lifecycle phase, or a goal in the f ormat plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
r.java:446) a:371)If I go inside the web module and run the same thing, I get this:
maven2> hot INFO? NOTE: Maven is executing in offline mode. Any artifacts not already in your local repository will be inaccessible.
INFO? Scanning for projects... INFO? ------------------------------------------------------------------------ ERROR? BUILD ERROR INFO? ------------------------------------------------------------------------ INFO? Internal error in the plugin manager getting plugin 'com.ctp.seam.maven:maven-hotdeploy-plugin': Plugin 'com.ctp. seam.maven:maven-hotdeploy-plugin:0.3.1' has an invalid descriptor: 1) Plugin's descriptor contains the wrong group ID: org.twdata.maven 2) Plugin's descriptor contains the wrong artifact ID: maven-cli-plugin 3) Plugin's descriptor contains the wrong version: 0.6.4 INFO? ------------------------------------------------------------------------ INFO? Trace org.apache.maven.lifecycle.LifecycleExecutionException?: Internal error in the plugin manager getting plugin 'com.ctp.sea m.maven:maven-hotdeploy-plugin': Plugin 'com.ctp.seam.maven:maven-hotdeploy-plugin:0.3.1' has an invalid descriptor: 1) Plugin's descriptor contains the wrong group ID: org.twdata.maven 2) Plugin's descriptor contains the wrong artifact ID: maven-cli-plugin 3) Plugin's descriptor contains the wrong version: 0.6.4
r.java:446) a:371) Caused by: org.apache.maven.plugin.PluginManagerException?: Plugin 'com.ctp.seam.maven:maven-hotdeploy-plugin:0.3.1' has an invalid descriptor: 1) Plugin's descriptor contains the wrong group ID: org.twdata.maven 2) Plugin's descriptor contains the wrong artifact ID: maven-cli-plugin 3) Plugin's descriptor contains the wrong version: 0.6.4 INFO? ------------------------------------------------------------------------ INFO? Total time: < 1 second INFO? Finished at: Thu Jul 23 16:56:19 CDT 2009 INFO? Final Memory: 10M/127M INFO? ------------------------------------------------------------------------ ERROR? Failed to execute 'hotdeploy:exploded?' on 'myproject-webapp' INFO? Execution time: 125 msI am using maven 2.2.0 and JDK 1.6.0_12
Thank you,
Lucian
I upgraded to cli 0.6.6 and added the configuration of this plugin to the main pom file and it worked nice.
Thank you,
Lucian