views:

500

answers:

4

Hello all,

I'm want to have the war file deployed in the server deploy directory (or any directory of my choice) along with the one deployed in the repository. Also, can I control the name of the war file deployed like, I don't want the war file to be projectname-1.0.war I just want the name of the war file be projectname.war.

Thanks,

Ravi

+1  A: 

'Deployment' may sound very technical but its just copying file to the deployment directory. In some cases you may have to restart the server.

AJ
right now I'm copying the war file from my repository to the deploy dir (after the build). I don't want to repeat this task again and again. When I do the build, a copy of the newly created war file is copied in the server deploy dir.
Ravi
+1  A: 

To change what it deploys the file as, use the tag in the build section of your pom.xml to specify the package name.

http://maven.apache.org/plugins/maven-jar-plugin/sign-mojo.html

BZ
+1  A: 

Thanks guys,

I got it working. here is what I did.

I added this in my pom.xml file

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <warName>mavenproject1</warName>
            <outputDirectory>C:\jboss-5.1.0.GA\server\default\deploy</outputDirectory>
        </configuration>
    </plugin>

</plugins>

This solved both my naming and placing the war file.

Ravi

Ravi
+1  A: 

A first option would be to use the JBoss Maven Plugin that allows to start/stop JBoss and deploy/undeploy applications via JMX.

Your configuration must set the location to your JBoss Home directory. This can be done by setting the home directory with the jbossHome tag in the plugin configuration:

<project>
  ...
  <build>
    <defaultGoal>package</defaultGoal>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jboss-maven-plugin</artifactId>
        <configuration>
          <jbossHome>C:/jboss-5.1.0.GA</jbossHome>
        </configuration>
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>

Then, just use one of the goal defined here, like:

$ mvn jboss:deploy


Another option would be to use the Cargo Maven Plugin. Below an example of plugin configuration that you could add to your war project:

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <configuration>
    <wait>false</wait>
    <container>
      <containerId>jboss5x</containerId>
      <home>C:/jboss-5.1.0.GA</home>
    </container>

    <configuration>
      <type>existing</type>
      <properties>
        ...
      </properties>
    </configuration>
  </configuration>
<plugin>

Then, to deploy a "deployable" (here, your war) to a running container:

$ mvn cargo:deploy
Pascal Thivent