缺少Maven程序集插件依赖项jar

时间:2017-10-09 06:11:14

标签: maven maven-3 maven-plugin

在尝试创建可分发的存档时,我遇到使用maven程序集插件的问题。一切都是 除了存档lib目录中缺少一些依赖项jar之外,工作正常。例如,hamcrest-core.jar,xnio-nio-3.3.6.Final.jar,objenesis-2.5.jar和其他几个罐子都没有添加。是否有任何理由不被包括在内? maven-dependency-plugin包含target / lib中的所有依赖jar并且没问题。

这是我在pom.xml中的内容

  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.0.1</version>
    <executions>
        <execution>
            <id>copy</id>
            <phase>install</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>
                    ${project.build.directory}/lib
                </outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <groupId>org.apache.maven.plugins</groupId>
    <version>3.1.0</version>
    <executions>
      <execution>
        <id>online-store</id>
        <phase>package</phase>
        <goals>
            <goal>single</goal>
        </goals>
        <configuration>
            <archive>
                <manifest>
                    <addClasspath>true</addClasspath>
                    <classpathPrefix>lib/</classpathPrefix>
                    <mainClass>com.online.store.Main</mainClass>
                </manifest>
            </archive>
            <appendAssemblyId>false</appendAssemblyId>
            <descriptors>
                <descriptor>src/assembly/assembly.xml</descriptor>
            </descriptors>
        </configuration>
      </execution>
    </executions>
</plugin>

这就是我在assembly.xml中的内容

    <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
   <id>online-store</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <!-- some file sets -->
    </fileSets>    
    <dependencySets>
        <dependencySet>
        <scope>compile</scope>  
        <includes>
                    <include>*:jar:*</include>
            </includes>
        <outputDirectory>/online-store/lib</outputDirectory>
    </dependencySet>
    </dependencySets>
</assembly>

1 个答案:

答案 0 :(得分:0)

您可以在范围测试中包含另一个dependencySet。

例如:

?