Well, I think the following can do what you need. The disadvantage of this approach is that there will be a gap between each deployment, as subsequent assembly is performed. It is acceptable?
Define a profile in each project with the same name (say, "publish"). Inside this profile, you can define the configuration for using the antrun-plugin to deliver files from FTP (see below).
In the parent project, you will have a module element that defines each project as a module. If you run mvn install -P publish , each project will be built in turn with the publishing profile turned on, and the final artifact will be published to the landing page at the installation stage. If you need to deploy additional files, modify the include element accordingly.
Please note that the parameters for the FTP task are set as properties, this allows you to override them from the command line and / or inherit 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 can use the dependency plugin to load each dependency, except that the parent cannot have a dependency on the child, and it will be created before the child. It was supposed to be another project. You also need to have information on where to deploy them. At the moment, you have targeted information in individual projects, so it is not available in the deployment project.
Using this approach, you can define several profiles in a new project, one for each artifact. Each profile defines a dependency: performing a copy to get a jar and performing antrun for one of the projects. The usual configuration (such as dependencies for the antrun plugin) can be pulled out of profiles. Also keep in mind that the properties will be merged if you define multiple profiles, so you may need to qualify them with an 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> <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>
Rich Seller Sep 10 '09 at 16:41 2009-09-10 16:41
source share