Spring Cloud Contract远程工件下载与本地冲突,如何使其临时? [英] Spring Cloud Contract remote artifact download clashes with local, how to make it temporary?

查看:100
本文介绍了Spring Cloud Contract远程工件下载与本地冲突,如何使其临时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Spring Cloud Contracts 2.0.0.M6时遇到问题,或者对于如何正确配置存根运行器测试有些误解.

I am having an issue with Spring Cloud Contracts 2.0.0.M6, or there is something I must be misunderstanding about how to properly configure the stub runner tests.

我想始终远程下载工件,因此我已将stubsMode设置为REMOTE.

I want to always download the artifact remotely, so I have set stubsMode to REMOTE.

当我在.m2目录中有工件的本地运行测试时,它失败.很好,我可以理解其中一位作者的观点此处.

When I run the test locally where I have the artifact in my .m2 directory, it fails. That's fine, and I can understand points made by one of the authors here.

我遇到的问题是,当我删除本地存根jar并运行测试用例时,将下载工件并再次将其放置在.m2目录中.实际上,这仅允许我运行存根运行程序一次,然后失败,因为我在本地拥有文件.每次测试运行后,我都必须从.m2中删除该工件.

The issue I have is that when I delete the local stub jars, and run the test case, the artifacts are downloaded and placed inside my .m2 directory again. Effectively this only allows me to run a stub runner once, then it fails because I have files locally. I have to keep deleting the artifact from .m2 after each test run.

我通过配置以下方法来解决此问题:

I have worked around this by configuring:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <systemPropertyVariables>
            <maven.repo.local>
                ${project.build.directory}/repo/${maven.build.timestamp}
            </maven.repo.local>
        </systemPropertyVariables>
    </configuration>
</plugin>

这意味着,每当存根运行程序运行时,它将检查并下载到新的随机"目录/target/repo/<date>.

Which means that for every time the stub runner runs, it will check and download to a new "random" directory /target/repo/<date>.

执行此操作的正确方法是什么?

What is the proper way of doing this?

推荐答案

当您拥有共享的.m2时,CI系统中可能会(并非总是发生)此问题.在下一个版本(1.2.x和2.0.0)中,感谢此问题的结束

This problem might (it doesn't always happen) occur in CI systems when you have a shared .m2. In the next release (1.2.x and 2.0.0), thanks to closing of this issue https://github.com/spring-cloud/spring-cloud-contract/issues/545 , you'll be able to pass stubrunner.snapshot-check-skip system property or STUBRUNNER_SNAPSHOT_CHECK_SKIP environment variable or set the plugin property (for 2.0.0 only) to disable the check.

这篇关于Spring Cloud Contract远程工件下载与本地冲突,如何使其临时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆