mvn install依赖项会忽略destFileName:复制依赖项

时间:2019-09-30 18:52:09

标签: java maven

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

destFileName似乎被maven忽略。尽管outputDirectory确实将其正确放置在该目录中,但jar名称没有更改-它与存储库中的名称相同。我要完全更改复制下来的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>

1 个答案:

答案 0 :(得分:1)

好吧,我认为我的答案可能是复制依赖关系,似乎没有destFileName

copy-dependencies

但目标副本具有

copy

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

希望有帮助