Can java_library.data runtime location be changed within bazel?What are the differences between Bazel and Gradle?Bazel: set runtime environment variable and configuration file location for cc_binary/cc_test$location expansion in BazelHow can users get bazel-run.sh?Use a Bazel a bazel query as a build shortcut?Specify “--build_python_zip” flag within Bazel py_binary rulebazel large / enormous test targets in bazel and parallelismBazel working directory differs from Maven. How to migrate?how to build cc_test for android using bazelPass $(location) to Bazel --test_arg

In Avengers 1, why does Thanos need Loki?

Quoting Yourself

Do I really need diodes to receive MIDI?

How can I get a job without pushing my family's income into a higher tax bracket?

How can I support myself financially as a 17 year old with a loan?

Enumerate Derangements

Would glacier 'trees' be plausible?

Is Cola "probably the best-known" Latin word in the world? If not, which might it be?

Unknowingly ran an infinite loop in terminal

If Earth is tilted, why is Polaris always above the same spot?

Identifying my late father's D&D stuff found in the attic

I may be a fraud

What happens to matryoshka Mordenkainen's Magnificent Mansions?

What are the spoon bit of a spoon and fork bit of a fork called?

Does this article imply that Turing-Computability is not the same as "effectively computable"?

Selecting a secure PIN for building access

Besides the up and down quark, what other quarks are present in daily matter around us?

How to reply this mail from potential PhD professor?

What was the state of the German rail system in 1944?

Can Ghost kill White Walkers or Wights?

Identifying a transmission to myself

When and why did journal article titles become descriptive, rather than creatively allusive?

Is Jon mad at Ghost for some reason and is that why he won't acknowledge him?

How would adding a darkvision racial trait to Dragonborn affect balance?



Can java_library.data runtime location be changed within bazel?


What are the differences between Bazel and Gradle?Bazel: set runtime environment variable and configuration file location for cc_binary/cc_test$location expansion in BazelHow can users get bazel-run.sh?Use a Bazel a bazel query as a build shortcut?Specify “--build_python_zip” flag within Bazel py_binary rulebazel large / enormous test targets in bazel and parallelismBazel working directory differs from Maven. How to migrate?how to build cc_test for android using bazelPass $(location) to Bazel --test_arg






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















On my way to migrate an existing build to bazel, i have a submodule mod1 that has some JUnit tests reading files from a "testdata" directory. When trying to load those files, i have to use "mod1/testdata/test.txt" instead of "testdata/test.txt", i.e. the unit tests have to be aware of their corresponding bazel module directory.



(1) Is this the correct behaviour for bazel 0.23.2@debian and 0.23.2-homebrew?



(2) Is there a way to use the .java tests without changes, and to remove the need for a "mod1" prefix in bazel data/ runfiles?



My sample project is here: https://gitlab.com/jhinrichsen/bazel-data-test. I am looking for a way to use the same path "testdata/test.txt" for both root module and submodule. In my example project, bazel test AllTests suceeds, while bazel test mod1/AllTests fails because i need to prepend "mod1/" to "testdata/test.txt".



Not looking for a resources/classpath based solution as i cannot modify the existing test sources.










share|improve this question




























    0















    On my way to migrate an existing build to bazel, i have a submodule mod1 that has some JUnit tests reading files from a "testdata" directory. When trying to load those files, i have to use "mod1/testdata/test.txt" instead of "testdata/test.txt", i.e. the unit tests have to be aware of their corresponding bazel module directory.



    (1) Is this the correct behaviour for bazel 0.23.2@debian and 0.23.2-homebrew?



    (2) Is there a way to use the .java tests without changes, and to remove the need for a "mod1" prefix in bazel data/ runfiles?



    My sample project is here: https://gitlab.com/jhinrichsen/bazel-data-test. I am looking for a way to use the same path "testdata/test.txt" for both root module and submodule. In my example project, bazel test AllTests suceeds, while bazel test mod1/AllTests fails because i need to prepend "mod1/" to "testdata/test.txt".



    Not looking for a resources/classpath based solution as i cannot modify the existing test sources.










    share|improve this question
























      0












      0








      0








      On my way to migrate an existing build to bazel, i have a submodule mod1 that has some JUnit tests reading files from a "testdata" directory. When trying to load those files, i have to use "mod1/testdata/test.txt" instead of "testdata/test.txt", i.e. the unit tests have to be aware of their corresponding bazel module directory.



      (1) Is this the correct behaviour for bazel 0.23.2@debian and 0.23.2-homebrew?



      (2) Is there a way to use the .java tests without changes, and to remove the need for a "mod1" prefix in bazel data/ runfiles?



      My sample project is here: https://gitlab.com/jhinrichsen/bazel-data-test. I am looking for a way to use the same path "testdata/test.txt" for both root module and submodule. In my example project, bazel test AllTests suceeds, while bazel test mod1/AllTests fails because i need to prepend "mod1/" to "testdata/test.txt".



      Not looking for a resources/classpath based solution as i cannot modify the existing test sources.










      share|improve this question














      On my way to migrate an existing build to bazel, i have a submodule mod1 that has some JUnit tests reading files from a "testdata" directory. When trying to load those files, i have to use "mod1/testdata/test.txt" instead of "testdata/test.txt", i.e. the unit tests have to be aware of their corresponding bazel module directory.



      (1) Is this the correct behaviour for bazel 0.23.2@debian and 0.23.2-homebrew?



      (2) Is there a way to use the .java tests without changes, and to remove the need for a "mod1" prefix in bazel data/ runfiles?



      My sample project is here: https://gitlab.com/jhinrichsen/bazel-data-test. I am looking for a way to use the same path "testdata/test.txt" for both root module and submodule. In my example project, bazel test AllTests suceeds, while bazel test mod1/AllTests fails because i need to prepend "mod1/" to "testdata/test.txt".



      Not looking for a resources/classpath based solution as i cannot modify the existing test sources.







      bazel






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 20:58









      JhinrichsenJhinrichsen

      1




      1






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The behavior that you are seeing is indeed the correct behavior, and there is no way to strip the "mod1" prefix with the native Java rules. Anything you include with data will be scoped to its own package in the way you're seeing.



          The reason for this is pretty straightforward. Let's say that your test target, //mod1:AllTests, also depended on a hypothetical //mod2:tests library. And let's say that hypothetical library also had a testdata/test.txt as a data dependency. The multiple test.txt files would conflict unless they were namespaced to their packages.



          If you absolutely cannot modify the test source at all, then you are pretty much stuck. Here's a previous discussion about this:
          https://groups.google.com/forum/#!topic/bazel-discuss/w6TDwSZvN0k



          I would recommend if you're trying to work with Bazel, you accept the concept of runfiles and modify your tests to either work with the runfiles structure, or accept a command-line argument for where to find the test data.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307695%2fcan-java-library-data-runtime-location-be-changed-within-bazel%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The behavior that you are seeing is indeed the correct behavior, and there is no way to strip the "mod1" prefix with the native Java rules. Anything you include with data will be scoped to its own package in the way you're seeing.



            The reason for this is pretty straightforward. Let's say that your test target, //mod1:AllTests, also depended on a hypothetical //mod2:tests library. And let's say that hypothetical library also had a testdata/test.txt as a data dependency. The multiple test.txt files would conflict unless they were namespaced to their packages.



            If you absolutely cannot modify the test source at all, then you are pretty much stuck. Here's a previous discussion about this:
            https://groups.google.com/forum/#!topic/bazel-discuss/w6TDwSZvN0k



            I would recommend if you're trying to work with Bazel, you accept the concept of runfiles and modify your tests to either work with the runfiles structure, or accept a command-line argument for where to find the test data.






            share|improve this answer



























              0














              The behavior that you are seeing is indeed the correct behavior, and there is no way to strip the "mod1" prefix with the native Java rules. Anything you include with data will be scoped to its own package in the way you're seeing.



              The reason for this is pretty straightforward. Let's say that your test target, //mod1:AllTests, also depended on a hypothetical //mod2:tests library. And let's say that hypothetical library also had a testdata/test.txt as a data dependency. The multiple test.txt files would conflict unless they were namespaced to their packages.



              If you absolutely cannot modify the test source at all, then you are pretty much stuck. Here's a previous discussion about this:
              https://groups.google.com/forum/#!topic/bazel-discuss/w6TDwSZvN0k



              I would recommend if you're trying to work with Bazel, you accept the concept of runfiles and modify your tests to either work with the runfiles structure, or accept a command-line argument for where to find the test data.






              share|improve this answer

























                0












                0








                0







                The behavior that you are seeing is indeed the correct behavior, and there is no way to strip the "mod1" prefix with the native Java rules. Anything you include with data will be scoped to its own package in the way you're seeing.



                The reason for this is pretty straightforward. Let's say that your test target, //mod1:AllTests, also depended on a hypothetical //mod2:tests library. And let's say that hypothetical library also had a testdata/test.txt as a data dependency. The multiple test.txt files would conflict unless they were namespaced to their packages.



                If you absolutely cannot modify the test source at all, then you are pretty much stuck. Here's a previous discussion about this:
                https://groups.google.com/forum/#!topic/bazel-discuss/w6TDwSZvN0k



                I would recommend if you're trying to work with Bazel, you accept the concept of runfiles and modify your tests to either work with the runfiles structure, or accept a command-line argument for where to find the test data.






                share|improve this answer













                The behavior that you are seeing is indeed the correct behavior, and there is no way to strip the "mod1" prefix with the native Java rules. Anything you include with data will be scoped to its own package in the way you're seeing.



                The reason for this is pretty straightforward. Let's say that your test target, //mod1:AllTests, also depended on a hypothetical //mod2:tests library. And let's say that hypothetical library also had a testdata/test.txt as a data dependency. The multiple test.txt files would conflict unless they were namespaced to their packages.



                If you absolutely cannot modify the test source at all, then you are pretty much stuck. Here's a previous discussion about this:
                https://groups.google.com/forum/#!topic/bazel-discuss/w6TDwSZvN0k



                I would recommend if you're trying to work with Bazel, you accept the concept of runfiles and modify your tests to either work with the runfiles structure, or accept a command-line argument for where to find the test data.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 19:26









                Rohan SinghRohan Singh

                12.9k13142




                12.9k13142





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307695%2fcan-java-library-data-runtime-location-be-changed-within-bazel%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript