Spring Cloud Contract remote artifact download clashes with local, how to make it temporary?

蹲街弑〆低调 提交于 2019-12-11 17:48:06

问题


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.

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

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.

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>

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?


回答1:


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.



来源:https://stackoverflow.com/questions/48926477/spring-cloud-contract-remote-artifact-download-clashes-with-local-how-to-make-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!