【问题标题】:How to copy unversioned test resources during release:perform?如何在发布期间复制未版本化的测试资源:执行?
【发布时间】:2013-12-11 09:40:58
【问题描述】:

我的问题与“Maven doesn't copy untracked resources while releasing”非常相似。我有不受版本控制的 test 资源。因为测试是 release:perform 的一部分,没有这些资源就会失败。

如何告诉 Maven 将那些未版本化的测试资源复制到 target/checkout/target/test-classes/。我真的不想跳过测试。这些测试资源不会进入公共 vcs,因为它们具有 Web 服务的凭据。

【问题讨论】:

    标签: maven maven-release-plugin


    【解决方案1】:

    似乎有很多方法可以实现这一点。一种方法是使用maven-resources-plugin 和个人资料。发布插件在release:perform 配置文件release-plugin 期间设置。您只需将 maven-resources-plugin 添加到该配置文件(或由<releaseProfiles> 激活的自定义配置文件)。

    <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
            <execution>
                <id>copy-resources</id>
                <phase>validate</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
                <configuration>
                    <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
                    <resources>
                        <resource>
                            <directory>${basedir}/../../src/test/resources/</directory>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    使用 org.sonatype.oss:oss-parent 有点不同,因为父 disables &lt;useReleaseProfile&gt; 但使用 sonatype-oss-release

    【讨论】:

      【解决方案2】:

      作为快速回复:

      您不应包含未版本控制的资源。这不是 Maven 哲学……确实,您必须不是 :)。

      旨在提供可重复的构建。如果您依赖未版本控制的资源,比如说不受控制的资源,您无法确保您的构建将始终提供相同的结果。

      为了以后的目的,凭据可以很容易地加密:

      【讨论】:

      • 所以我会将我的凭据加密存储在 VCS 中,并且在构建期间我可以解密它们。好的,其他开发人员如何使用他们的凭据?
      猜你喜欢
      • 2023-03-24
      • 2020-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多