将库及其所有依赖项打包到一个文件夹,但在单独的文件夹中包含其他依赖项

tur*_*off 6 java zip dependencies maven maven-assembly-plugin

我是maven项目.我使用maven-assembly-plugin创建包含所有模块依赖项的zip文件.需要创建具有以下结构的zip:

/my-libs
/other-libs
Run Code Online (Sandbox Code Playgroud)

my-libs需要包装从依赖my-libdepenency +所有的传递依赖.TO other-libs需要收拾所有其他从目前的Maven的模块依赖.

基本上我需要有条件地选择目标文件夹:

if (dependency in transitive-dependencies(my-lib))
   copy to /my-libs
else
   copy to /other-libs
Run Code Online (Sandbox Code Playgroud)

有可能maven-assembly-plugin吗?有没有替代maven插件这样做?

isa*_*iro 3

您需要dependencySet在程序集 XML 文件中定义两个

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    ...                                                                                                                        
    <dependencySets>                                                                                                                         
        <dependencySet>                                                                                                                      
            <useProjectArtifact>false</useProjectArtifact>                                                                                   
            <useTransitiveFiltering>false</useTransitiveFiltering>                                                                            
            <includes>                                                                                                                       
                <include>com.example:dependency1:jar</include>                                                                       
                <include>com.example:dependency2:jar</include>                                                                       
                ...
            </includes>                                                                                                                      
            <outputDirectory>/my-libs</outputDirectory>                                                                                             
        </dependencySet>                                                                                                                     
        <dependencySet>                                                                                                                      
            <useProjectArtifact>false</useProjectArtifact>                                                                                   
            <useTransitiveFiltering>false</useTransitiveFiltering>                                                                            
            <includes>                                                                                                                       
                <include>com.example:other1:jar</include>                                                                       
                <include>com.example:other2:jar</include>                                                                       
                ...
            </includes>                                                                                                                      
            <outputDirectory>/other-libs</outputDirectory>                                                                                             
        </dependencySet>                                                                                                                     
    </dependencySets>         
    ...                                                                                                               
</assembly>   
Run Code Online (Sandbox Code Playgroud)

文件:

http://maven.apache.org/plugins/maven-assemble-plugin/usage.html

http://maven.apache.org/plugins/maven- assembly-plugin/ assembly.html