开发者

Including maven built assemblies in another module

开发者 https://www.devze.com 2023-03-14 21:32 出处:网络
I have 2 maven modules. One module builds bunch of zip fil开发者_JAVA百科es using maven-assembly-plugin. Second module needs to include some of the zip files built by the first module in its package.

I have 2 maven modules. One module builds bunch of zip fil开发者_JAVA百科es using maven-assembly-plugin. Second module needs to include some of the zip files built by the first module in its package. What is the way to do this. Thank you.


The easiest thing would be to deploy the zips to a repository. For the local repository use install:install-file and for central repositories use deploy:deploy-file.

You can declare the zips as dependencies in your second module.


So someone else mentioned to deploy it to your repository. If you're already setup to deploy built artifacts to a repository this is easy, if not, check out http://maven.apache.org/plugins/maven-deploy-plugin/

Next, you need to use a plugin to get the zip file checked out of the repository. You could use shade, or the maven-dependency-plugin. Let's assume maven-dependency-plugin http://maven.apache.org/plugins/maven-dependency-plugin/usage.html

So add this to your maven pom file in the plugins section:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>unpack</id>
            <phase>process-sources</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>my.artifact.group.id</groupId>
                        <artifactId>my-artifact</artifactId>
                        <version>My-version</version>
                        <type>zip</type>
                        <overWrite>false</overWrite>
                        <outputDirectory>${project.build.directory}/see</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

Obviously you need to change the specifics of the artifact. That will unzip your zip file into target/see. If you want the actual zip file (which seems like what you were asking for but it's not clear), just change the goal from "unpack" to "copy-dependencies". You might also have to remove the outputDirectory or change some other bit of the configuration. Just play with it to get it where you need it, and see the page on the maven-dependency-plugin I mentioned above for more details.

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号