简体   繁体   English

从Maven迁移到Bazel

[英]Migrating from maven to bazel

Hi I am trying to migrate my project from maven to bazel. 嗨,我正在尝试将我的项目从Maven迁移到bazel。 One of the challenge I am facing is migrating test configuration. 我面临的挑战之一是迁移测试配置。

While initializing the test, code writes some config properties to properties file. 初始化测试时,代码会将一些配置属性写入属性文件。 In one of the test configuration, it tries to create this properties file in "/target" location which maven creates by default. 在一种测试配置中,它尝试在maven默认创建的“ / target”位置中创建此属性文件。

But after migrating those tests to run with bazel, it doesnt find the folder named target and hence fail the tests. 但是在将这些测试迁移到以bazel运行之后,它没有找到名为target的文件夹,因此测试失败。

Changing each and every test with the different folder will be huge task. 使用不同的文件夹更改每个测试都是一项艰巨的任务。 Is there a way in bazel to create maven like folder structure ? 在bazel中有没有办法创建类似于Maven的文件夹结构?

Bazel runs tests in a directory denoted by the environment variable $TEST_SRCDIR and has access to a temp directory $TEST_TMPDIR during the test. Bazel在由环境变量$TEST_SRCDIR表示的目录中运行测试,并且在测试期间可以访问临时目录$TEST_TMPDIR I believe the only approach here would be the augment every test to either not write to target/ , or write to $TEST_TMPDIR instead of target/ . 我相信这里唯一的方法将是增加每个测试以要么不写到target/ ,要么写到$TEST_TMPDIR而不是target/

Also, unlike Maven, Bazel does not allow your tests to write to your sources' directory. 此外,与Maven不同,Bazel不允许您的测试写入源的目录。 This is to ensure reproducibility and hermeticity, and is the reason why Bazel runs tests in a separate clean room environment created independently for each test. 这是为了确保重现性和气密性,也是Bazel在针对每个测试独立创建的独立洁净室环境中运行测试的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM