Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add runfiles library to release archive #242

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ filegroup(
"//java/common:srcs",
"//java/private:srcs",
"//java/proto:srcs",
"//java/runfiles:srcs",
"//java/toolchains:srcs",
],
visibility = ["//:__pkg__"],
Expand Down
8 changes: 8 additions & 0 deletions java/runfiles/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ alias(
actual = "//java/runfiles/src/main/java/com/google/devtools/build/runfiles",
visibility = ["//visibility:public"],
)

filegroup(
name = "srcs",
srcs = glob(["**"]) + [
"//java/runfiles/src/main/java/com/google/devtools/build/runfiles:srcs",
],
visibility = ["//java:__pkg__"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ java_plugin(
srcs = ["AutoBazelRepositoryProcessor.java"],
processor_class = "com.google.devtools.build.runfiles.AutoBazelRepositoryProcessor",
)

filegroup(
name = "srcs",
srcs = glob(["**"]),
visibility = ["//java/runfiles:__pkg__"],
)
8 changes: 7 additions & 1 deletion test/repo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ java_binary(
java_test(
name = "MyTest",
srcs = ["src/MyTest.java"],
deps = ["@my_jar//jar"],
data = [
"src/data.txt",
],
deps = [
"@my_jar//jar",
"@rules_java//java/runfiles",
],
)

default_java_toolchain(
Expand Down
2 changes: 1 addition & 1 deletion test/repo/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module(name = "fake_repo_for_testing")
module(name = "integration_test_repo")

bazel_dep(name = "rules_java", version = "7.5.0")
archive_override(
Expand Down
Empty file modified test/repo/setup.sh
100644 → 100755
Empty file.
17 changes: 16 additions & 1 deletion test/repo/src/MyTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import com.google.devtools.build.runfiles.AutoBazelRepository;
import com.google.devtools.build.runfiles.Runfiles;
import java.beans.Transient;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import mypackage.MyLib;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
@AutoBazelRepository
public class MyTest {
@Test
public void main() {
assertEquals(MyLib.myStr(), "my_string");
}
}

@Transient
fmeum marked this conversation as resolved.
Show resolved Hide resolved
public void runfiles() throws IOException {
Runfiles runfiles = Runfiles.preload().withSourceRepository(AutoBazelRepository_MyTest.NAME);
Path path = Paths.get(runfiles.rlocation("integration_test_repo/src/data.txt"));
assertTrue(Files.exists(path));
}
}
Empty file added test/repo/src/data.txt
Empty file.