maven-dependency-plugin: exclude .jar files

青春壹個敷衍的年華 提交于 2021-02-08 07:39:49

问题


I am using maven-dependency-plugin. I need to download only a ZIP file and exclude all jar files.

Plugin configuration looks the following way.

<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>

The plugin still downloads everything: all jars.


回答1:


The copy-dependencies goal of the maven-dependency-plugin does not support includes and excludes attributes.

However, you can use the excludeTypes attributes to exclude specific types of dependencies.

Comma Separated list of Types to exclude. Empty String indicates don't exclude anything (default).

The following will exclude all the jar dependencies:

<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>


来源:https://stackoverflow.com/questions/34839656/maven-dependency-plugin-exclude-jar-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!