【问题标题】:.gitignore file is not copied to archetype JAR - Workarounds?.gitignore 文件未复制到原型 JAR - 解决方法?
【发布时间】:2015-09-15 07:33:18
【问题描述】:

目前在 maven-resources-plugin 中存在一个错误,即 .gitignore 文件未复制到原型 JAR。看到这个bug report

简短而简单的问题:是否有在原型中获取文件的解决方法?

编辑:将 maven-resources-plugin 版本设置为 2.6 并不能解决我的问题(就像提到的 here

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

【问题讨论】:

标签: maven gitignore maven-archetype maven-resources-plugin


【解决方案1】:

该错误现已在 maven-resources-plugin 中修复。

要包含 .gitignore 文件,maven-resources-plugin 插件应在原型pom.xml 文件中显式设置,配置值addDefaultExcludes 设置为false

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <version>3.0.2</version>
  <configuration>
    <addDefaultExcludes>false</addDefaultExcludes>
  </configuration>
</plugin>

【讨论】:

【解决方案2】:

正如@amanteaux 所说,将addDefaultExcludesfalse 添加可确保maven-resources-plugin 将.gitignore 文件复制到target/classes,但是,maven-jar-plugin (> 2.4) 不会复制.gitignore 到生成的 jar。请参阅this stackoverflow comment 了解更多信息。因此,一种解决方法是,除了上面的 maven-resources-plugin 标志之外,将 maven-jar-plugin 回滚到 2.4。

【讨论】:

    猜你喜欢
    • 2022-07-20
    • 2010-09-10
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 2022-01-17
    • 2014-07-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多