【问题标题】:destFileName is ignored by mvn install dependency:copy-dependenciesdestFileName 被 mvn install dependency:copy-dependencies 忽略
【发布时间】:2019-10-01 05:23:42
【问题描述】:

我尝试在使用此命令复制依赖项时更改本地文件夹和 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>

【问题讨论】:

  • Maven 输出错误吗?
  • 不,它没有

标签: java maven


【解决方案1】:

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

copy-dependencies

但目标副本有它

copy

我遇到了类似的问题,您可以尝试在复制依赖项中使用 &lt;stripVersion&gt; 选项

希望对你有帮助

【讨论】:

  • 嗯,我猜我很困惑。复制和复制依赖之间的区别是什么,你什么时候使用一个而不是另一个。做了一个快速测试,只是从复制依赖切换到复制作品,但是我应该知道有什么重大差异吗?如果它们可以互换,那么为什么会有两个版本的相同目标?
猜你喜欢
  • 2021-02-18
  • 2011-03-09
  • 2011-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-05
  • 2011-08-26
  • 1970-01-01
相关资源
最近更新 更多