maven-war-plugin vs. "Unexpected end of ZLIB input stream" - deployment

im using maven-war-plugin and sometimes i get Unexpected end of ZLIB input stream when deploying to jboss, its because file is made in jboss directory and not moved/copied there, is there any way to fix it(using maven)?
my configuration:
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<outputDirectory>${jbossDeploy}</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>

Most likely what you have said is correct.
Maven is probably still building the war when jboss starts to deploy it, so as jboss is reading it, it sees an invalid zip format. You could try using the exploded option, or deploy separately after everything is built.

I made ant script for it that can be used in maven
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<property name="packageName" value="${project.build.finalName}.${project.packaging}" />
<property name="outputDir" value="c:/jboss-4.2.1.GA/server/default/deploy" />
<property name="file" value="${project.build.directory}\${packageName}" />
<property name="tofile" value="${outputDir}/${packageName}" />
<echo message="Moving ${file} to ${tofile}" />
<move file="${file}" tofile="${tofile}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Related

Maven (m2e) is not executing ant task

I have a POM file (to be executed by Eclipse) where I want to execute a ANT task during the generate-sources phase. Based on m2e documentation, in How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds, Maven: execute antrun task during package and Where should be placed maven-compiler-plugin declaration: in <plugins> or <pluginManagement>?, I wrote my POM file in this way:
<?xml version="1.0" encoding="UTF-8"?>
<project>
...
<build>
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.8,)</versionRange>
<goals>
<goal>generate-sources</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<!-- Plugin 1 -->
</plugin>
<plugin>
<!-- Plugin to be executed during generate-sources phase. -->
</plugin>
<plugin>
<!-- Should be in the generate-sources phase after the plugin above. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>ant-test</id>
<configuration>
<task>
<echo message="ANT TEST" />
</task>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
What I understood from my reading, is that I am asking telling to Maven the following: First ask to Eclipse plugin for Maven (m2e) to allow the maven-antrun-plugin (version 1.8 or above) to be executed during generate-sources. Next, in the generate-sources phase and after the execution of the first plugin, call the ant plugin to run the task which echo my message.
However, the messagem is not being showed. Neither when I execute just the generate-sources goal nor when I execute the install goal.
I if follow this sugestion here, and add the <phase> element inside <execution>, like here:
<executions>
<execution>
<id>ant-test</id>
*<phase>generate-sources</phase>*
<configuration>
<task>
<echo message="ANT TEST" />
</task>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
I have a Eclipse error message: Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.8:run (execution: ant-test, phase: generate-sources). Here shows a example where there is no a specific <pluginManagement> for ant plugin. But also I had no success.
So What is missing here?
Thanks,
Rafael Afonso
Actually, I discovered that the error message Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-antrun-plugin:1.8:run (execution: ant-test, phase: generate-sources) has no effect in the Maven execution. The message is shown with no problems. To speak the truth, I had to change the task to target, but the message continues to be displayed. May be it is just a kind m2e's bug which the only effect is annoys us.
Actually, I did the structure below, and it worked:
<build>
<plugins>
<plugin>
....
</plugin>
<plugin>
...
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-antrun-plugin
</artifactId>
<versionRange>
[1.8,)
</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

Execute a task in Maven before packaging

I don't understand how to run a task in Maven, before packaging.
<build>
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<echo message="****** TEST *****" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
When I run mvn clean package, it doesn't get executed. How can I have this task executed? I'm using maven 3.0.5, if it matters.
** UPDATE: **
Adding id and goal as suggested, solved the problem from the command line.
<id>my-generate-sources</id>
<goals>
<goal>run</goal>
</goals>
To fix Eclipse error, I've configured lifecyleMappingMetadata, within the build section:
<build>
...
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.7,)</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
You need to add the <goals> tag (and adding an <id> tag is also strongly encouraged though not required if you only have one <execution> for the plugin), e.g.
...
<execution>
<id>print-something</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="****** TEST *****" />
</tasks>
</configuration>
</execution>
...
Try adding an execution id:
<execution>
<phase>generate-sources</phase>
<id>my-generate-sources</id>
<configuration>
<tasks>
<echo message="****** TEST *****" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
UPDATE
I forgot the run goal, as Guillame said. Eclipse maven integration is one of the worse things I have ever seen. The way we were running it is exclusivley via maven command line, and that is what I would recommend. You can still run it from eclipse like this:
create a new empty project
create mvn-clean-package.launch file in it
The file should look like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${resource}"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
</listAttribute>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="/usr/bin/mvn"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="clean package -DskipTests=true -U"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${selected_resource_loc}"/>
</launchConfiguration>
As long as this project is opened in your workspace, you can select any other project folder that contains pom.xml and select your mvn-clean-package command from the external tools button:
This will run:
mvn clean package -DskipTests=true -U
from the selected folder. You can see the output in Eclipse console window.
The external tools are also accessible also from the Run menu. I suppose that there is method to achieve this through Eclipse UI, but I didn't use Eclipse long enough to find that out.

Code coverage of JBoss AS 7 testsuite, using JaCoCo - no data in jacoco.exec files

I'm trying to get coverage of JBoss AS 7. Here's my branch:
https://github.com/OndraZizka/jboss-as/tree/TS-jacoco
When I run mvn clean install -rf testsuite -DallTests -Dcoverage -fae I get (almost) empty jacoco.exec files - just some metadata (size is few bytes).
The JVM arg line used is:
-javaagent:${jbossas.ts.dir}/target/jacoco-jars/agent/jacocoagent.jar=destfile=${basedir}/target/jacoco.exec,includes=${jboss.home}/modules/**/*,excludes=${basedir}/target/classes/**/*,append=true,output=file
This line is passed to Arquillian to use to start JBoss AS 7.
The testsuite runs, the argument is passed (it appears in AS7's boot.log), but the resulting jacoco.exec file is only few bytes in size. The report of course shows no coverage.
What am I doing wrong?
Resolved - the "includes" and "excludes" parameters of the agent refer to class names, not files.
Correct JVM agent argument for my case is:
-javaagent:${jbossas.ts.dir}/target/jacoco-jars/agent/jacocoagent.jar=destfile=${basedir}/target/jacoco.exec,includes=*,excludes=org.jboss.as.test.*,append=true,output=file
My aproach was to configure the maven jacoco plugin to get the argument, and then hard-coded the property into pom.xml since the property generated by the plugin is not passed to the Surefire plugin.
<profile>
<id>ts.jacoco.profile</id>
<activation><property><name>coverage</name></property></activation>
<properties>
<jvm.args.jacoco>-javaagent:${jbossas.ts.dir}/target/jacoco-jars/agent/jacocoagent.jar=destfile=${basedir}/target/jacoco.exec,includes=*,excludes=org.jboss.as.test.*,append=true,output=file</jvm.args.jacoco>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${version.jacoco.plugin}</version>
<executions>
<execution><id>ts.jacoco-prepare</id>
<phase>process-test-classes</phase>
<goals><goal>prepare-agent</goal></goals>
<configuration>
<append>true</append>
<destFile>target/jacoco.exec</destFile>
<includes>
<include>*</include>
</includes>
<excludes>
<exclude>org.jboss.as.test.*</exclude>
</excludes>
<output>file</output>
<propertyName>jvm.args.jacoco</propertyName>
</configuration>
</execution>
<!-- Doesn't work currently - waiting for JaCoCo to fix this. Moved to the Ant plugin execution. -->
<execution><id>ts.jacoco.report</id>
<phase>none</phase> <!-- post-integration-test -->
<goals><goal>report</goal></goals>
<configuration>
<dataFile>target/jacoco.exec</dataFile>
<outputDirectory>target/coverageReport</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- Copy JaCoCo jars to have them for the Ant plugin. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!-- Copy the ant tasks jar. Needed for ts.jacoco.report-ant . -->
<execution> <id>ts.jacoco.dep.ant</id> <goals><goal>copy</goal></goals> <phase>process-test-resources</phase> <inherited>false</inherited>
<configuration>
<artifactItems>
<artifactItem><groupId>org.jacoco</groupId><artifactId>org.jacoco.ant</artifactId><version>${version.jacoco.plugin}</version></artifactItem>
</artifactItems>
<stripVersion>true</stripVersion>
<outputDirectory>${basedir}/target/jacoco-jars</outputDirectory>
</configuration>
</execution>
<!-- Copy the agent jar. Needed for ${jvm.args.jacoco} to have this jar on known path.
If the ts.jacoco-prepare worked and really put the value into the property, this might go away. -->
<execution> <id>ts.jacoco.dep.agent</id> <goals><goal>unpack</goal></goals> <phase>process-test-resources</phase> <inherited>false</inherited>
<configuration>
<artifactItems>
<artifactItem><groupId>org.jacoco</groupId><artifactId>org.jacoco.agent</artifactId><version>${version.jacoco.plugin}</version></artifactItem>
</artifactItems>
<stripVersion>true</stripVersion>
<outputDirectory>${basedir}/target/jacoco-jars/agent</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- Ant plugin. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<!-- DEBUG -->
<execution>
<id>ts.jacoco.debug</id>
<phase>post-integration-test</phase>
<goals><goal>run</goal></goals>
<inherited>false</inherited>
<configuration>
<target>
<echo>Jacoco argline: ${jvm.args.jacoco}</echo>
<echo>Jacoco jar: ${basedir}/target/jacoco-jars/org.jacoco.ant.jar</echo>
</target>
</configuration>
</execution>
<!-- Must be run using Ant due to https://sourceforge.net/tracker/?func=detail&aid=3474708&group_id=177969&atid=883354 -->
<execution>
<id>ts.jacoco.report-ant</id>
<phase>site</phase> <!-- post-integration-test -->
<goals><goal>run</goal></goals>
<inherited>false</inherited>
<configuration>
<target>
<taskdef name="report" classname="org.jacoco.ant.ReportTask">
<classpath path="${basedir}/target/jacoco-jars/org.jacoco.ant.jar"/>
</taskdef>
<echo>Creating JaCoCo test coverage reports...</echo>
<mkdir dir="${basedir}/target/coverage-report"/>
<report>
<executiondata>
<fileset dir="${basedir}">
<include name="**/target/jacoco.exec"/>
</fileset>
</executiondata>
<structure name="AS 7 project">
<classfiles>
<fileset dir="${jboss.dist}/modules">
<include name="**/*.jar"/>
<!-- We have 2.x in main. -->
<exclude name="com/sun/jsf-impl/1.*/**/*"/>
<!-- AS7-3383 - com/sun/codemodel vs. /1.0/com/sun/codemodel -->
<exclude name="com/sun/xml/**/*"/>
<exclude name="javax/faces/api/1.2/**/*"/>
<!-- AS7-3390 -->
<exclude name="org/apache/commons/beanutils/**/*"/>
<!-- AS7-3389 -->
<exclude name="org/python/jython/standalone/**/*"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${jbossas.project.dir}">
<include name="**/*.java"/>
<exclude name="testsuite/**/*.java"/>
</fileset>
</sourcefiles>
</structure>
<html destdir ="${basedir}/target/coverage-report/html"/>
<xml destfile="${basedir}/target/coverage-report/coverage-report.xml"/>
<csv destfile="${basedir}/target/coverage-report/coverage-report.csv"/>
</report>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.ant</artifactId>
<version>${version.jacoco.plugin}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>

Maven : How to generate project's war file in two folders

I want that when I run the mvn install, a war can be generated in the /target and an other war in the c:....tomcat 6\deploy directory.
I'm using maven2, Eclipse and m2eclipse. How to do this ??
Thnx :)
You could try to use the maven-antrun-plugin to copy your war to the tomcat deploy directory like this:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<copy file="{project.build.directory}/${project.actifactId}-${project.version}.war" tofile="<your tomcat path>/${project.actifactId}-${project.version}.war" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Maybe you don't need to copy the war file if you try the Maven Jetty Plugin. This plugin is for running a web application directly from Maven.
Try the cargo-maven2-plugin. Probably something like this would work:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
<execution>
<id>deploy-local</id>
<phase>install</phase>
<goals>
<goal>deployer-deploy</goal>
<goals>
</execution>
</executions>
<configuration>
<container>
<containerId>tomcat6x</containerId>
</container>
<configuration>
<type>existing</type>
<home>/your/tomcat/dir</home> <!-- replace as needed -->
</configuration>
</configuration>
</plugin>
... slap that into a profile or the top-level <build><plugins> section and see if it works for you ...

Using Maven for deployment

I have this task for the project with 4 nested subprojects using Maven:
For each child: jar-up resource directory including project dependencies
Move up to the parent project
With a single command extract all created archives into various remote destinations (full install), that may include http server, app server, file server, etc. (mostly *NIX). Destination is provided on subproject level
It should also be possible to unzip/copy from the individual subproject (partial install)
Files are not Java - mostly various scripts and HTML
I'm looking at the various plugins to help with the task: assembly, dependency, antrun, unzip. Dependency looks promising but I need to unzip not only dependency jars but the (sub)project content as well. Also since I can't really tight the operation to the Maven lifecycle how would I trigger remote install? mvn dependency:unpack? That's not very descriptive or intuitive. Is is possible to create a custom goal (e.g. project:install) without writing a plugin?
Using Maven is company standard so please do not offer alternatives - I'm pretty much stuck with what I have
Ok, I think the following might do what you need. The drawback of this approach is that there will be an interval between each deployment as the subsequent build is executed. Is this acceptable?
Define a profile in each project with the same name (say "publish"). Within that profile you can define a configuration to use the antrun-plugin to deliver the files with FTP (see below).
In the parent project you'll have a modules element, defining each project as a module. If you run mvn install -P publish, each project will be built in turn with the publish profile enabled, and the final artifact published to the target during the install phase. If you need to deploy additional files, modify the include element accordingly.
Note the parameters for the FTP task have been set as properties, this allows them to be overridden from the command-line and/or inherited from the parent POM.
<profiles>
<profile>
<id>publish</id>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>ftp</id>
<phase>install</phase>
<configuration>
<tasks>
<ftp action="send"
server="${ftp.host}" remotedir="${ftp.remotedir}"
userid="${ftp.userid}" password="${ftp.password}"
depends="${ftp.depends}" verbose="${ftp.verbose}">
<fileset dir="${project.build.directory}">
<include
name="${project.build.finalName}.${project.packaging}"/>
</fileset>
</ftp>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
</plugin>
<properties>
<ftp.host>hostname</ftp.host>
<ftp.remotedir>/opt/path/to/install</ftp.remotedir>
<ftp.userid>user</ftp.userid>
<ftp.password>mypassword</ftp.password>
<ftp.depends>yes</ftp.depends>
<ftp.verbose>no</ftp.verbose>
</properties>
</profile>
</profiles>
Update: based on your comment: You could use the dependency plugin to download each dependency, except that a parent can't have a dependency on a child, and it will be built before the child. It would have to be another project. you also need to have somewhere the information for where to deploy them to. At the moment you have the target information in the individual projects so it isn't accessible in the deployer project.
Taking this approach, you can define multiple profiles in the new project, one for each artifact. Each profile defines a dependency:copy execution to obtain the jar and an antrun execution for one of the projects. Common configuration (such as the dependencies for the antrun plugin) can be pulled out of the profiles. Also be aware that the properties will be merged if you define multiple profiles, so yo may need to qualify them with the artifact name, for example ftp.artifact1.host.
<profiles>
<profile>
<id>deploy-artifact1</id>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependency</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>name.seller.rich</groupId>
<artifactId>artifact1</artifactId>
<version>1.0.0</version>
<type>jar</type>
<overWrite>false</overWrite>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/deploy-staging</outputDirectory>
<overWriteReleases>false</overWriteReleases>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>ftp</id>
<phase>install</phase>
<configuration>
<tasks>
<ftp action="send"
server="${ftp.host}" remotedir="${ftp.remotedir}"
userid="${ftp.userid}" password="${ftp.password}"
depends="${ftp.depends}" verbose="${ftp.verbose}">
<fileset dir="${project.build.directory} includes="deploy-staging/"/>
</ftp>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<properties>
<!--if the properties differ between targets, qualify them with the artifact name-->
<ftp.host>hostname</ftp.host>
<ftp.remotedir>/opt/path/to/install</ftp.remotedir>
<ftp.userid>user</ftp.userid>
<ftp.password>mypassword</ftp.password>
<ftp.depends>yes</ftp.depends>
<ftp.verbose>no</ftp.verbose>
</properties>
</profile>
</profiles>
Below POM will help to copy jar's file from project build directory to remote SFTP/FTP server.
Use command mvn install -Dftp.password=password
Since I want to pass password from command prompt for security reason, I have used -Dftp.password=password
After execution of above command all the jar files from maven project target folder will be deployed in MAVEN folder on server.com
<plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>ftp</id>
<phase>install</phase>
<configuration>
<tasks>
<scp todir="user#server.com:/MAVEN/"
sftp="true" port="22" trust="true" password="${ftp.password}"
failonerror="false" verbose="true" passphrase="">
<fileset dir="${project.build.directory}">
<include name="*.jar" />
</fileset>
</scp>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
</plugin>
Does not work without passphrase.
<profile>
<id>publish</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>scp</id>
<phase>deploy</phase>
<configuration>
<tasks>
<scp todir="user#host:some/remote/dir"
sftp="true"
keyfile="${user.home}/.ssh/devel-deploy.id_dsa"
failonerror="false"
verbose="true"
passphrase="nopass"
>
<fileset dir="${project.build.directory}">
<include
name="${project.build.finalName}.${project.packaging}"/>
</fileset>
</scp>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
However, my favourite is
<profile>
<id>upload-devel</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>upload-devel</id>
<phase>deploy</phase>
<configuration>
<target>
<exec executable="rsync" failonerror="false">
<arg value="-aiz" />
<arg value="${project.build.directory}/${project.artifactId}.${project.packaging}" />
<arg value="user#host:some/remote/dir/." />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
though I don't know how compatible that is over different platforms.
I would look at using the maven-assembly-plugin to do this.
Something like this can be used to grab the files from the child projects and stuff them in output directories.
<assembly>
<id>xyzzy</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>../subproject1/target/</directory>
<outputDirectory>/foo</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>../subproject1/target/html-output/</directory>
<outputDirectory>/foo</outputDirectory>
<includes>
<include>*.html</include>
<include>*.js</include>
<include>*.css</include>
</includes>
</fileSet>
<fileSet>
<directory>../subproject2/target/</directory>
<outputDirectory>/bar</outputDirectory>
<includes>
<include>**/**</include>
</includes>
<excludes>
<exclude>**/*.exclude-this</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
Maven is not really designed to deploy jars to a remote location; its main use is compiling and packaging artifacts. The assembly and dependency targets are primarily used to gather dependencies and files to package into an artifact.
Having said that, maven does have a deploy goal which uses a component called wagon. This is primarily intended to deploy to a maven repository. There is a plugin called Cargo that can be used to deploy artifacts to a remote server, but that doesn't explode the jar contents by itself (it relies on the target app server to do all that). You might be able to extend the Maven Wagon functionality yourself.
Also, it is possible to package a custom lifecycle, but that is getting into some pretty low level maven mojo (pun intended).