首页 > 解决方案 > destFileName 被 mvn install dependency:copy-dependencies 忽略

问题描述

使用此命令复制依赖项时,我尝试更改本地文件夹和 jar 名称mvn install dependency:copy-dependencies

destFileName 似乎被 maven 忽略了。尽管 outputDirectory 确实将它正确地放在了该目录中,但 jar 名称并没有改变——它与 repo 中的名称相同。我想在复制下来时完全更改jar的名称

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <!-- required by not used -->
  <groupId>aaaa</groupId>
  <artifactId>aaaaa</artifactId>
  <version>5</version>

  <repositories>
    <repository>
      <id>my-repo</id>
      <name>repo</name>
      <url>https://my-repo</url>
    </repository>
  </repositories>

  <!-- require uber-jar -->
  <dependencies>
    <dependency>
      <groupId>com.mycompany.app</groupId>
      <artifactId>my-app</artifactId>
      <version>1.0-SNAPSHOT</version>
      <classifier>uber-jar</classifier>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-sources</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>Jars</outputDirectory>
          <artifactItems>
            <artifactItem>
              <groupId>com.mycompany.app</groupId>
              <artifactId>my-app</artifactId>
              <classifier>uber-jar</classifier>
              <overWrite>true</overWrite>


              <!-- THIS IS IGNORED -->
              <destFileName>zzzzzz.jar</destFileName>


            </artifactItem>
          </artifactItems>
          <overWriteReleases>true</overWriteReleases>
          <overWriteSnapshots>true</overWriteSnapshots>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

标签: javamaven

解决方案


好的,我想我可能有答案 copy-dependencies 似乎没有 destFileName

复制依赖

但目标副本有

复制

我遇到了类似的问题,您可以尝试使用<stripVersion>复制依赖项中的选项

希望能帮助到你


推荐阅读