maven-dependency-plugin: 排除 .jar 文件

maven-dependency-plugin: exclude .jar files

我正在使用 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-dependency-plugincopy-dependencies 目标不支持 includesexcludes 属性。

不过,您可以使用excludeTypes attributes to exclude specific types of dependencies

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

以下将排除所有 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>