【问题标题】:maven-dependency-plugin: exclude .jar filesmaven-dependency-plugin:排除 .jar 文件
【发布时间】:2016-01-17 14:48:51
【问题描述】:

我正在使用 maven-dependency-plugin。我只需要下载一个 ZIP 文件并排除所有 jar 文件。

插件配置如下所示。

<execution>
    <id>copy-dependencies</id>
    <phase>package</phase>
    <goals>
        <goal>copy-dependencies</goal>
    </goals>
    <configuration>
        <!-- <outputDirectory>${project.build.directory}</outputDirectory> -->
        <overWriteReleases>false</overWriteReleases>
        <overWriteSnapshots>false</overWriteSnapshots>
        <overWriteIfNewer>true</overWriteIfNewer>
        <excludes>**/*.jar</excludes>
        <includes>**/*.zip</includes>
    </configuration>
</execution>

该插件仍会下载所有内容:所有 jar。

【问题讨论】:

    标签: maven continuous-integration maven-dependency-plugin


    【解决方案1】:

    maven-dependency-plugincopy-dependencies 目标不支持includesexcludes 属性。

    但是,您可以使用excludeTypes 属性来排除特定的types of dependencies

    要排除的类型的逗号分隔列表。空字符串表示不排除任何内容(默认)。

    以下将排除所有jar 依赖项:

    <execution>
        <id>copy-dependencies</id>
        <phase>package</phase>
        <goals>
            <goal>copy-dependencies</goal>
        </goals>
        <configuration>
            <!-- <outputDirectory>${project.build.directory}</outputDirectory> -->
            <overWriteReleases>false</overWriteReleases>
            <overWriteSnapshots>false</overWriteSnapshots>
            <overWriteIfNewer>true</overWriteIfNewer>
            <excludeTypes>jar</excludeTypes>
        </configuration>
    </execution>
    

    【讨论】:

    • 它仍然复制所有依赖项。我运行的maven命令是“clean package dependency:copy-dependencies -PdownloadIosAgents,x64 -X”
    • @Michael 问题是因为您正在显式调用dependency:copy-dependencies,但我们配置了特定的执行。长话短说:clean package -PdownloadIosAgents,x64 -X 是你应该执行的 :)
    • 最重要的是,除了一个“util-master-SNAPSHOT-tests.jar”之外,所有 JAR 都被排除在外。我不知道为什么。
    • @Michael 嗯,那是你的项目生成的吗?您能否在启用调试的情况下为您的 Maven 日志提供一个要点(或其他)-X
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-07
    • 2014-11-22
    • 2012-01-26
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 2017-05-30
    相关资源
    最近更新 更多