简体   繁体   中英

How to zip and deploy a dist artefact after appassembler-maven-plugin:assemble

I have a multi-module Maven project.

In the lastly executed module, I assemble the dist directory using the Appassambler plugin .

Then I'd like to zip it and deploy as a maven artifact.

I'm about to simply zip it somehow and then use deploy:deploy-file .

Are there any more maven-like alternatives?

I've seen the combination of Shade plugin and deploy:deploy , but it seems that shade is quite hard to persuade to zip particular directory.

I'm open to any solution of the whole "assemble, zip and deploy" process.

Although I am quite in favor of Maven, I have to say that all Maven tools for creating an app distribution I've found, aren't satisfying. Either they are buggy, or poorly documented, or user hostile.

I have resorted to the concept I read, where the directory prepared by appassemble plugin is zipped using Ant (assembly-plugin fails at this too) and then added as one of module's artefacts.

Here's my solution, however I'll keep the question opened if someone wants to prove me wrong and provide a solution using standard Maven plugins, thanks.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution> <id>createDistJar</id> 
                    <goals> <goal>run</goal> </goals>  <phase>package</phase>
                    <configuration>
                        <target>
                            <echo message="${project.build.directory}"/>
                            <mkdir dir="${project.build.directory}"/>
                            <zip destfile="${project.build.directory}/JawaBot-${project.version}-dist.zip"
                                basedir="target/" includes="JawaBot-${project.version}-dist-rh/**">
                            </zip>
                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <id>uploadDistJar</id> <goals>  <goal>attach-artifact</goal>  </goals>
                    <phase>package</phase>
                    <configuration>
                        <artifacts>
                            <artifact>
                                <file>${project.build.directory}/JawaBot-${project.version}-dist.zip</file>
                                <type>zip</type>
                            </artifact>
                        </artifacts>
                    </configuration>
                </execution>
            </executions>
        </plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM