Skip to content

Commit

Permalink
Revert "Revert "Fix repositories to use 'BUILD.bazel' as the name for…
Browse files Browse the repository at this point in the history
… the symlinked/new build file, which has less changes of causing conflicts. Fixes #2226.""

This reverts commit fa3f55a.

--
Change-Id: Ife393ebf4966cfaf2a487c80c67a781ca7ee69b0
Reviewed-on: https://cr.bazel.build/8051
PiperOrigin-RevId: 142555911
MOS_MIGRATED_REVID=142555911
  • Loading branch information
katre authored and aehlig committed Dec 21, 2016
1 parent 05fd076 commit b9c65d1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ protected JarDecompressor() {
/**
* The .jar can be used compressed, so this just exposes it in a way Bazel can use.
*
* <p>It moves the jar from some-name/x/y/z/foo.jar to some-name/jar/foo.jar and creates a BUILD
* file containing one entry: the .jar.
* <p>It moves the jar from some-name/x/y/z/foo.jar to some-name/jar/foo.jar and creates a
* BUILD.bazel file containing one entry: the .jar.
*/
@Override
@Nullable
Expand All @@ -60,12 +60,12 @@ public Path decompress(DecompressorDescriptor descriptor) throws RepositoryFunct
if (!jarSymlink.exists()) {
jarSymlink.createSymbolicLink(descriptor.archivePath());
}
// external/some-name/repository/jar/BUILD defines the //jar target.
Path buildFile = jarDirectory.getRelative("BUILD");
// external/some-name/repository/jar/BUILD.bazel defines the //jar target.
Path buildFile = jarDirectory.getRelative("BUILD.bazel");
FileSystemUtils.writeLinesAs(
buildFile,
Charset.forName("UTF-8"),
"# DO NOT EDIT: automatically generated BUILD file for "
"# DO NOT EDIT: automatically generated BUILD.bazel file for "
+ descriptor.targetKind()
+ " rule "
+ descriptor.targetName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public boolean prepareBuildFile(Rule rule, Environment env)
*/
public void finishBuildFile(Path outputDirectory) throws RepositoryFunctionException {
if (buildFileValue != null) {
// Link x/BUILD to <build_root>/x.BUILD.
// Link x/BUILD to <build_root>/x.BUILD.bazel.
symlinkBuildFile(buildFileValue, outputDirectory);
} else if (buildFileContent != null) {
RepositoryFunction.writeBuildFile(outputDirectory, buildFileContent);
Expand Down Expand Up @@ -204,7 +204,7 @@ private FileValue getBuildFileValue(Rule rule, Environment env)
*/
private void symlinkBuildFile(
FileValue buildFileValue, Path outputDirectory) throws RepositoryFunctionException {
Path buildFilePath = outputDirectory.getRelative("BUILD");
Path buildFilePath = outputDirectory.getRelative("BUILD.bazel");
RepositoryFunction.createSymbolicLink(buildFilePath, buildFileValue.realRootedPath().asPath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static void createWorkspaceFile(

protected static RepositoryDirectoryValue writeBuildFile(
Path repositoryDirectory, String contents) throws RepositoryFunctionException {
Path buildFilePath = repositoryDirectory.getRelative("BUILD");
Path buildFilePath = repositoryDirectory.getRelative("BUILD.bazel");
try {
// The repository could have an existing BUILD file that's either a regular file (for remote
// repositories) or a symlink (for local repositories). Either way, we want to remove it and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testTargets() throws Exception {
Path outputDir = DecompressorValue.decompress(descriptorBuilder.build());
assertThat(outputDir.exists()).isTrue();
String buildContent =
new String(FileSystemUtils.readContentAsLatin1(outputDir.getRelative("jar/BUILD")));
new String(FileSystemUtils.readContentAsLatin1(outputDir.getRelative("jar/BUILD.bazel")));
assertThat(buildContent).contains("java_import");
assertThat(buildContent).contains("filegroup");
}
Expand All @@ -66,5 +66,4 @@ public void testWorkspaceGen() throws Exception {
FileSystemUtils.readContentAsLatin1(outputDir.getRelative("WORKSPACE")));
assertThat(workspaceContent).contains("workspace(name = \"tester\")");
}

}

0 comments on commit b9c65d1

Please sign in to comment.