Remove rule definitions native htt_archive and git_repository The implementation of these rules was already removed in commit 569a31b45619d2c8d8b20f0799d4609a2858b45a. Change-Id: I91a04d08dcb9cc759597d177fd5b908e62c55a1a PiperOrigin-RevId: 228722271
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java index 28e0b7e..043c341 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
@@ -50,14 +50,8 @@ import com.google.devtools.build.lib.bazel.rules.python.BazelPyRuntimeRule; import com.google.devtools.build.lib.bazel.rules.python.BazelPyTestRule; import com.google.devtools.build.lib.bazel.rules.python.BazelPythonConfiguration; -import com.google.devtools.build.lib.bazel.rules.workspace.GitRepositoryRule; -import com.google.devtools.build.lib.bazel.rules.workspace.HttpArchiveRule; -import com.google.devtools.build.lib.bazel.rules.workspace.HttpFileRule; -import com.google.devtools.build.lib.bazel.rules.workspace.HttpJarRule; import com.google.devtools.build.lib.bazel.rules.workspace.MavenJarRule; import com.google.devtools.build.lib.bazel.rules.workspace.MavenServerRule; -import com.google.devtools.build.lib.bazel.rules.workspace.NewGitRepositoryRule; -import com.google.devtools.build.lib.bazel.rules.workspace.NewHttpArchiveRule; import com.google.devtools.build.lib.cmdline.LabelConstants; import com.google.devtools.build.lib.rules.android.AarImportBaseRule; import com.google.devtools.build.lib.rules.android.AndroidConfiguration; @@ -361,14 +355,8 @@ @Override public void init(ConfiguredRuleClassProvider.Builder builder) { // TODO(ulfjack): Split this up by conceptual units. - builder.addRuleDefinition(new GitRepositoryRule()); - builder.addRuleDefinition(new HttpArchiveRule()); - builder.addRuleDefinition(new HttpJarRule()); - builder.addRuleDefinition(new HttpFileRule()); builder.addRuleDefinition(new MavenJarRule()); builder.addRuleDefinition(new MavenServerRule()); - builder.addRuleDefinition(new NewHttpArchiveRule()); - builder.addRuleDefinition(new NewGitRepositoryRule()); builder.addRuleDefinition(new NewLocalRepositoryRule()); builder.addRuleDefinition(new AndroidSdkRepositoryRule()); builder.addRuleDefinition(new AndroidNdkRepositoryRule());
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/GitRepositoryRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/GitRepositoryRule.java deleted file mode 100644 index 0137060..0000000 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/GitRepositoryRule.java +++ /dev/null
@@ -1,135 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.devtools.build.lib.bazel.rules.workspace; - -import static com.google.devtools.build.lib.packages.Attribute.attr; -import static com.google.devtools.build.lib.syntax.Type.BOOLEAN; -import static com.google.devtools.build.lib.syntax.Type.STRING; - -import com.google.devtools.build.lib.analysis.RuleDefinition; -import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; -import com.google.devtools.build.lib.packages.RuleClass; -import com.google.devtools.build.lib.rules.repository.WorkspaceBaseRule; -import com.google.devtools.build.lib.rules.repository.WorkspaceConfiguredTargetFactory; - -/** - * Rule definition for the git_repository rule. - */ -public class GitRepositoryRule implements RuleDefinition { - public static final String NAME = "git_repository"; - - @Override - public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) { - return builder - /* <!-- #BLAZE_RULE(git_repository).ATTRIBUTE(remote) --> - The URI of the remote Git repository. - - <p>This must be a HTTP URL. There is currently no support for authentication.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("remote", STRING).mandatory()) - /* <!-- #BLAZE_RULE(git_repository).ATTRIBUTE(commit) --> - The commit hash to check out in the repository. - - <p>Note that one of either <code>commit</code> or <code>tag</code> must be defined.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("commit", STRING)) - /* <!-- #BLAZE_RULE(git_repository).ATTRIBUTE(tag) --> - The Git tag to check out in the repository. - - <p>Note that one of either <code>commit</code> or <code>tag</code> must be defined.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("tag", STRING)) - /* <!-- #BLAZE_RULE(git_repository).ATTRIBUTE(init_submodules) --> - Whether to clone submodules in the repository. - - <p>Currently, only cloning the top-level submodules is supported</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("init_submodules", BOOLEAN).value(false)) - /* <!-- #BLAZE_RULE(git_repository).ATTRIBUTE(sha256) --> - The expected SHA-256 hash of the file downloaded. Specifying this forces the repository to - be downloaded as a tarball. Currently, this is only supported for public GitHub - repositories. - - <p>This must match the SHA-256 hash of the file downloaded. <em>It is a security risk to - omit the SHA-256 as remote files can change.</em> At best omitting this field will make - your build non-hermetic. It is optional to make development easier but should be set - before shipping.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("sha256", STRING)) - .setWorkspaceOnly() - .build(); - } - - @Override - public Metadata getMetadata() { - return RuleDefinition.Metadata.builder() - .name(GitRepositoryRule.NAME) - .type(RuleClass.Builder.RuleClassType.WORKSPACE) - .ancestors(WorkspaceBaseRule.class) - .factoryClass(WorkspaceConfiguredTargetFactory.class) - .build(); - } -} - -/*<!-- #BLAZE_RULE (NAME = git_repository, TYPE = OTHER, FAMILY = Workspace)[GENERIC_RULE] --> - -<p><strong>Deprecated. -<code>load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")</code> -for a drop-in replacement.</strong></p> - -<p>Clones a Git repository, checks out the specified tag, or commit, and makes its targets -available for binding.</p> - -<h4 id="git_repository_examples">Examples</h4> - -<p>Suppose the current repository contains the source code for a chat program, rooted at the - directory <i>~/chat-app</i>. It needs to depend on an SSL library which is available in the - remote Git repository <i>http://example.com/openssl/openssl.git</i>. The chat app depends - on version 1.0.2 of the SSL library, which is tagged by the v1.0.2 Git tag.<p> - -<p>This Git repository contains the following directory structure:</p> - -<pre class="code"> -WORKSPACE -src/ - BUILD - openssl.cc - openssl.h -</pre> - -<p><i>src/BUILD</i> contains the following target definition:</p> - -<pre class="code"> -cc_library( - name = "openssl-lib", - srcs = ["openssl.cc"], - hdrs = ["openssl.h"], -) -</pre> - -<p>Targets in the <i>~/chat-app</i> repository can depend on this target if the following lines are - added to <i>~/chat-app/WORKSPACE</i>:</p> - -<pre class="code"> -git_repository( - name = "my_ssl", - remote = "http://example.com/openssl/openssl.git", - tag = "v1.0.2", -) -</pre> - -<p>Then targets would specify <code>@my_ssl//src:openssl-lib</code> as a dependency.</p> - -<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/HttpArchiveRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/HttpArchiveRule.java deleted file mode 100644 index 3fc484a..0000000 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/HttpArchiveRule.java +++ /dev/null
@@ -1,157 +0,0 @@ -// Copyright 2014 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.devtools.build.lib.bazel.rules.workspace; - -import static com.google.devtools.build.lib.packages.Attribute.attr; -import static com.google.devtools.build.lib.syntax.Type.STRING; -import static com.google.devtools.build.lib.syntax.Type.STRING_LIST; - -import com.google.devtools.build.lib.analysis.RuleDefinition; -import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; -import com.google.devtools.build.lib.packages.RuleClass; -import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType; -import com.google.devtools.build.lib.rules.repository.WorkspaceBaseRule; -import com.google.devtools.build.lib.rules.repository.WorkspaceConfiguredTargetFactory; - -/** - * Rule definition for the http_archive rule. - */ -public class HttpArchiveRule implements RuleDefinition { - - public static final String NAME = "http_archive"; - - @Override - public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) { - return builder - /* <!-- #BLAZE_RULE(http_archive).ATTRIBUTE(url) --> - (Deprecated) A URL referencing an archive file containing a Bazel repository. - - <p>This value has the same meaning as a <code>urls</code> list with a single item. This - must not be specified if <code>urls</code> is also specified.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("url", STRING)) - /* <!-- #BLAZE_RULE(http_archive).ATTRIBUTE(urls) --> - List of mirror URLs referencing the same archive file containing a Bazel repository. - - <p>This must be an http, https, or file URL. Archives of type .zip, .jar, .war, .tar.gz, - .tgz, tar.bz2, or tar.xz are supported. There is no support for authentication.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("urls", STRING_LIST)) - /* <!-- #BLAZE_RULE(http_archive).ATTRIBUTE(sha256) --> - The expected SHA-256 hash of the file downloaded. - - <p>This must match the SHA-256 hash of the file downloaded. <em>It is a security risk to - omit the SHA-256 as remote files can change.</em> At best omitting this field will make - your build non-hermetic. It is optional to make development easier but should be set - before shipping.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("sha256", STRING)) - /* <!-- #BLAZE_RULE(http_archive).ATTRIBUTE(type) --> - The archive type of the downloaded file. - - <p>By default, the archive type is determined from the file extension of the URL. If the - file has no extension, you can explicitly specify one of the following: `"zip"`, `"jar"`, - `"war"`, `"tar.gz"`, `"tgz"`, `"tar.xz"`, and `tar.bz2`</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("type", STRING)) - /* <!-- #BLAZE_RULE(http_archive).ATTRIBUTE(strip_prefix) --> - A directory prefix to strip from the extracted files. - - <p>Many archives contain a top-level directory that contains all of the useful files in - archive. Instead of needing to specify this prefix over and over in the - <code>build_file</code>, this field can be used to strip it from all of the extracted - files.</p> - - <p>For example, suppose you are using foo-lib-latest.zip, which contains the directory - foo-lib-1.2.3/ under which there is a WORKSPACE file and are src/, lib/, and test/ - directories that contain the actual code you wish to build. Specify - <code>strip_prefix = "foo-lib-1.2.3"</code> to use the foo-lib-1.2.3 directory as your - top-level directory.</p> - - <p>Note that if there are files outside of this directory, they will be discarded and - inaccessible (e.g., a top-level license file). This includes files/directories that - start with the prefix but are not in the directory (e.g., foo-lib-1.2.3.release-notes). - If the specified prefix does not match a directory in the archive, Bazel will return an - error.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("strip_prefix", STRING)) - .setWorkspaceOnly() - .build(); - } - - @Override - public Metadata getMetadata() { - return RuleDefinition.Metadata.builder() - .name(HttpArchiveRule.NAME) - .type(RuleClassType.WORKSPACE) - .ancestors(WorkspaceBaseRule.class) - .factoryClass(WorkspaceConfiguredTargetFactory.class) - .build(); - } -} - -/*<!-- #BLAZE_RULE (NAME = http_archive, TYPE = OTHER, FAMILY = Workspace)[GENERIC_RULE] --> - -<p><strong>Deprecated. -<code>load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")</code> -for a drop-in replacement.</strong></p> - -<p>Downloads a Bazel repository as a compressed archive file, - decompresses it, and makes its targets available for binding. The - repository should already contain a BUILD file. If it does not, use - <a href="${link new_http_archive}">new_http_archive</a> instead.</p> - -<p>It supports Zip-formatted archives and tarballs. The full set of extensions supported is -.zip, .jar, .war, .tar.gz, .tgz, .tar.xz, or .tar.bz2.</p> - -<h4 id="http_archive_examples">Examples</h4> - -<p>Suppose the current repository contains the source code for a chat program, rooted at the - directory <i>~/chat-app</i>. It needs to depend on an SSL library which is available from - <i>http://example.com/openssl.zip</i>. This .zip file contains the following directory - structure:</p> - -<pre class="code"> -WORKSPACE -src/ - BUILD - openssl.cc - openssl.h -</pre> - -<p><i>src/BUILD</i> contains the following target definition:</p> - -<pre class="code"> -cc_library( - name = "openssl-lib", - srcs = ["openssl.cc"], - hdrs = ["openssl.h"], -) -</pre> - -<p>Targets in the <i>~/chat-app</i> repository can depend on this target if the following lines are - added to <i>~/chat-app/WORKSPACE</i>:</p> - -<pre class="code"> -http_archive( - name = "my_ssl", - url = "http://example.com/openssl.zip", - sha256 = "03a58ac630e59778f328af4bcc4acb4f80208ed4", -) -</pre> - -<p>Then targets would specify <code>@my_ssl//src:openssl-lib</code> as a dependency.</p> - -<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/HttpFileRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/HttpFileRule.java deleted file mode 100644 index 104d5ef..0000000 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/HttpFileRule.java +++ /dev/null
@@ -1,108 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.devtools.build.lib.bazel.rules.workspace; - -import static com.google.devtools.build.lib.packages.Attribute.attr; -import static com.google.devtools.build.lib.syntax.Type.BOOLEAN; -import static com.google.devtools.build.lib.syntax.Type.STRING; -import static com.google.devtools.build.lib.syntax.Type.STRING_LIST; - -import com.google.devtools.build.lib.analysis.RuleDefinition; -import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; -import com.google.devtools.build.lib.packages.RuleClass; -import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType; -import com.google.devtools.build.lib.rules.repository.WorkspaceBaseRule; -import com.google.devtools.build.lib.rules.repository.WorkspaceConfiguredTargetFactory; - -/** - * Rule definition for the http_file rule. - */ -public class HttpFileRule implements RuleDefinition { - - public static final String NAME = "http_file"; - - @Override - public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) { - return builder - /* <!-- #BLAZE_RULE(http_file).ATTRIBUTE(url) --> - (Deprecated) A URL to a file that will be made available to Bazel. - - <p>This value has the same meaning as a <code>urls</code> list with a single item. This - must not be specified if <code>urls</code> is also specified.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("url", STRING)) - /* <!-- #BLAZE_RULE(http_file).ATTRIBUTE(urls) --> - List of mirror URLs referencing the same file that will be made available to Bazel. - - <p>This must be an http, https, or file URL. Authentication is not supported.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("urls", STRING_LIST)) - /* <!-- #BLAZE_RULE(http_file).ATTRIBUTE(sha256) --> - The expected SHA-256 of the file downloaded. - - <p>This must match the SHA-256 of the file downloaded. <em>It is a security risk to - omit the SHA-256 as remote files can change.</em> At best omitting this field will make - your build non-hermetic. It is optional to make development easier but should be set - before shipping.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("sha256", STRING)) - /* <!-- #BLAZE_RULE(http_file).ATTRIBUTE(executable) --> - If the downloaded file should be made executable. Defaults to False. - - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("executable", BOOLEAN)) - .setWorkspaceOnly() - .build(); - } - - @Override - public Metadata getMetadata() { - return RuleDefinition.Metadata.builder() - .name(HttpFileRule.NAME) - .type(RuleClassType.WORKSPACE) - .ancestors(WorkspaceBaseRule.class) - .factoryClass(WorkspaceConfiguredTargetFactory.class) - .build(); - } -} -/*<!-- #BLAZE_RULE (NAME = http_file, TYPE = OTHER, FAMILY = Workspace)[GENERIC_RULE] --> - -<p><strong>Deprecated. -<code>load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")</code> -for a drop-in replacement.</strong></p> - -<p>Downloads a file from a URL and makes it available to be used as a file group.</p> - -<h4 id="http_file_examples">Examples</h4> - -<p>Suppose you need to have a debian package for your custom rules. This package is available from -<i>http://example.com/package.deb</i>. Then you can add to your WORKSPACE file:</p> - -<pre class="code"> -http_file( - name = "my_deb", - url = "http://example.com/package.deb", - sha256 = "03a58ac630e59778f328af4bcc4acb4f80208ed4", -) -</pre> - -<p>Targets would specify <code>@my_deb//file</code> as a dependency to depend on this file.</p> - -<p>You may also reference files on the current system (localhost) by using "file:///path/to/file" -if you are on Unix-based systems. If you're on Windows, use "file:///c:/path/to/file". In both -examples, note the three slashes (<code>/</code>) -- the first two slashes belong to -<code>file://</code> and the third one belongs to the absolute path to the file.</p> - -<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/HttpJarRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/HttpJarRule.java deleted file mode 100644 index bc18509..0000000 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/HttpJarRule.java +++ /dev/null
@@ -1,95 +0,0 @@ -// Copyright 2014 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.devtools.build.lib.bazel.rules.workspace; - -import static com.google.devtools.build.lib.packages.Attribute.attr; -import static com.google.devtools.build.lib.syntax.Type.STRING; - -import com.google.devtools.build.lib.analysis.RuleDefinition; -import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; -import com.google.devtools.build.lib.packages.RuleClass; -import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType; -import com.google.devtools.build.lib.rules.repository.WorkspaceBaseRule; -import com.google.devtools.build.lib.rules.repository.WorkspaceConfiguredTargetFactory; - -/** - * Rule definition for the http_jar rule. - */ -public class HttpJarRule implements RuleDefinition { - - public static final String NAME = "http_jar"; - - @Override - public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) { - return builder - /* <!-- #BLAZE_RULE(http_jar).ATTRIBUTE(url) --> - A URL to an archive file containing a Bazel repository. - - <p>This must be an http or https URL that ends with .jar.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("url", STRING).mandatory()) - /* <!-- #BLAZE_RULE(http_jar).ATTRIBUTE(sha256) --> - The expected SHA-256 of the file downloaded. - - <p>This must match the SHA-256 of the file downloaded. <em>It is a security risk to - omit the SHA-256 as remote files can change.</em> At best omitting this field will make - your build non-hermetic. It is optional to make development easier but should be set - before shipping.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("sha256", STRING)) - .setWorkspaceOnly() - .build(); - } - - @Override - public Metadata getMetadata() { - return RuleDefinition.Metadata.builder() - .name(HttpJarRule.NAME) - .type(RuleClassType.WORKSPACE) - .ancestors(WorkspaceBaseRule.class) - .factoryClass(WorkspaceConfiguredTargetFactory.class) - .build(); - } -} -/*<!-- #BLAZE_RULE (NAME = http_jar, TYPE = OTHER, FAMILY = Workspace)[GENERIC_RULE] --> - -<p><strong>Deprecated. -<code>load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")</code> -for a drop-in replacement.</strong></p> - -<p>Downloads a jar from a URL and makes it available to be used as a Java dependency.</p> - -<p>Downloaded files must have a .jar extension.</p> - -<h4 id="http_jar_examples">Examples</h4> - -<p>Suppose the current repository contains the source code for a chat program, rooted at the - directory <i>~/chat-app</i>. It needs to depend on an SSL library which is available from - <i>http://example.com/openssl-0.2.jar</i>.</p> - -<p>Targets in the <i>~/chat-app</i> repository can depend on this target if the following lines are - added to <i>~/chat-app/WORKSPACE</i>:</p> - -<pre class="code"> -http_jar( - name = "my_ssl", - url = "http://example.com/openssl-0.2.jar", - sha256 = "03a58ac630e59778f328af4bcc4acb4f80208ed4", -) -</pre> - -<p>Targets would specify <code>@my_ssl//jar</code> as a dependency to depend on this jar.</p> - -<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/NewGitRepositoryRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/NewGitRepositoryRule.java deleted file mode 100644 index a7132b6..0000000 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/NewGitRepositoryRule.java +++ /dev/null
@@ -1,161 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.devtools.build.lib.bazel.rules.workspace; - -import static com.google.devtools.build.lib.packages.Attribute.attr; -import static com.google.devtools.build.lib.syntax.Type.BOOLEAN; -import static com.google.devtools.build.lib.syntax.Type.STRING; - -import com.google.devtools.build.lib.analysis.RuleDefinition; -import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; -import com.google.devtools.build.lib.packages.RuleClass; -import com.google.devtools.build.lib.rules.repository.WorkspaceBaseRule; -import com.google.devtools.build.lib.rules.repository.WorkspaceConfiguredTargetFactory; - -/** - * Rule definition for the new_git_repository rule. - */ -public class NewGitRepositoryRule implements RuleDefinition { - public static final String NAME = "new_git_repository"; - - @Override - public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) { - return builder - /* <!-- #BLAZE_RULE(new_git_repository).ATTRIBUTE(remote) --> - The URI of the remote Git repository. - - <p>This must be a HTTP URL. There is currently no support for authentication.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("remote", STRING).mandatory()) - /* <!-- #BLAZE_RULE(git_repository).ATTRIBUTE(commit) --> - The commit hash to check out in the repository. - - <p>Note that one of either <code>commit</code> or <code>tag</code> must be defined.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("commit", STRING)) - /* <!-- #BLAZE_RULE(git_repository).ATTRIBUTE(tag) --> - The Git tag to check out in the repository. - - <p>Note that one of either <code>commit</code> or <code>tag</code> must be defined.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("tag", STRING)) - /* <!-- #BLAZE_RULE(new_git_repository).ATTRIBUTE(build_file) --> - The file to use as the BUILD file for this repository. - - <p>Either build_file or build_file_content must be specified.</p> - - <p>This attribute is a label relative to the main workspace. The file does not need to be - named BUILD, but can be. (Something like BUILD.new-repo-name may work well for - distinguishing it from the repository's actual BUILD files.)</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("build_file", STRING)) - /* <!-- #BLAZE_RULE(new_git_repository).ATTRIBUTE(build_file_content) --> - The content for the BUILD file for this repository. - - <p>Either build_file or build_file_content must be specified.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("build_file_content", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(workspace_file) --> - The file to use as the WORKSPACE file for this repository. - - <p>Either workspace_file or workspace_file_content can be specified, but not both.</p> - - <p>This attribute is a label relative to the main workspace. The file does not need to be - named WORKSPACE, but can be. (Something like WORKSPACE.new-repo-name may work well for - distinguishing it from the repository's actual WORKSPACE files.)</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("workspace_file", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(workspace_file_content) --> - The content for the WORKSPACE file for this repository. - - <p>Either workspace_file or workspace_file_content can be specified, but not both.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("workspace_file_content", STRING)) - /* <!-- #BLAZE_RULE(new_git_repository).ATTRIBUTE(init_submodules) --> - Whether to clone submodules in the repository. - - <p>Currently, only cloning the top-level submodules is supported</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("init_submodules", BOOLEAN).value(false)) - /* <!-- #BLAZE_RULE(new_git_repository).ATTRIBUTE(sha256) --> - The expected SHA-256 hash of the file downloaded. Specifying this forces the repository to - be downloaded as a tarball. Currently, this is only supported for public GitHub - repositories. - - <p>This must match the SHA-256 hash of the file downloaded. <em>It is a security risk to - omit the SHA-256 as remote files can change.</em> At best omitting this field will make - your build non-hermetic. It is optional to make development easier but should be set - before shipping.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("sha256", STRING)) - .setWorkspaceOnly() - .build(); - } - - @Override - public Metadata getMetadata() { - return RuleDefinition.Metadata.builder() - .name(NewGitRepositoryRule.NAME) - .type(RuleClass.Builder.RuleClassType.WORKSPACE) - .ancestors(WorkspaceBaseRule.class) - .factoryClass(WorkspaceConfiguredTargetFactory.class) - .build(); - } -} - -/*<!-- #BLAZE_RULE (NAME = new_git_repository, TYPE = OTHER, FAMILY = Workspace)[GENERIC_RULE] --> - -<p><strong>Deprecated. -<code>load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")</code> -for a drop-in replacement.</strong></p> - -<p>Clones a Git repository, checks out the specified tag, or commit, and makes its targets -available for binding.</p> - -<h4 id="git_repository_examples">Examples</h4> - -<p>Suppose the current repository contains the source code for a chat program, rooted at the - directory <i>~/chat-app</i>. It needs to depend on an SSL library which is available in the - remote Git repository <i>http://example.com/openssl/openssl.git</i>. The chat app depends - on version 1.0.2 of the SSL library, which is tagged by the v1.0.2 Git tag.<p> - -<p>This Git repository contains the following directory structure:</p> - -<pre class="code"> -src/ - openssl.cc - openssl.h -</pre> - -<p>Targets in the <i>~/chat-app</i> repository can depend on this target if the following lines are - added to <i>~/chat-app/WORKSPACE</i>:</p> - -<pre class="code"> -new_git_repository( - name = "my_ssl", - remote = "http://example.com/openssl/openssl.git", - tag = "v1.0.2", - build_file_content = """ -cc_library( - name = "openssl-lib", - srcs = ["src/openssl.cc"], - hdrs = ["src/openssl.h"], -)""", -) -</pre> - -<p>Then targets would specify <code>@my_ssl//:openssl-lib</code> as a dependency.</p> - -<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/NewHttpArchiveRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/NewHttpArchiveRule.java deleted file mode 100644 index cd5c012..0000000 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/workspace/NewHttpArchiveRule.java +++ /dev/null
@@ -1,185 +0,0 @@ -// Copyright 2014 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.devtools.build.lib.bazel.rules.workspace; - -import static com.google.devtools.build.lib.packages.Attribute.attr; -import static com.google.devtools.build.lib.syntax.Type.STRING; -import static com.google.devtools.build.lib.syntax.Type.STRING_LIST; - -import com.google.devtools.build.lib.analysis.RuleDefinition; -import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; -import com.google.devtools.build.lib.packages.RuleClass; -import com.google.devtools.build.lib.rules.repository.WorkspaceBaseRule; -import com.google.devtools.build.lib.rules.repository.WorkspaceConfiguredTargetFactory; - -/** - * Rule definition for the new_http_archive rule. - */ -public class NewHttpArchiveRule implements RuleDefinition { - public static final String NAME = "new_http_archive"; - - @Override - public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment environment) { - return builder - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(url) --> - (Deprecated) A URL referencing an archive file. - - <p>This value has the same meaning as a <code>urls</code> list with a single item. This - must not be specified if <code>urls</code> is also specified.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("url", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(urls) --> - List of mirror URLs referencing the same archive file containing a Bazel repository. - - <p>This must be an http, https, or file URL. Archives of type .zip, .jar, .war, .tar.gz, - .tgz, tar.bz2, or tar.xz are supported. There is no support for authentication.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("urls", STRING_LIST)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(sha256) --> - The expected SHA-256 hash of the file downloaded. - - <p>This must match the SHA-256 hash of the file downloaded. <em>It is a security risk to - omit the SHA-256 as remote files can change.</em> At best omitting this field will make - your build non-hermetic. It is optional to make development easier but should be set - before shipping.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("sha256", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(build_file) --> - The file to use as the BUILD file for this repository. - - <p>Either build_file or build_file_content must be specified.</p> - - <p>This attribute is a label relative to the main workspace. The file does not need to be - named BUILD, but can be. (Something like BUILD.new-repo-name may work well for - distinguishing it from the repository's actual BUILD files.)</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("build_file", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(build_file_content) --> - The content for the BUILD file for this repository. - - <p>Either build_file or build_file_content must be specified.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("build_file_content", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(workspace_file) --> - The file to use as the WORKSPACE file for this repository. - - <p>Either workspace_file or workspace_file_content can be specified, but not both.</p> - - <p>This attribute is a label relative to the main workspace. The file does not need to be - named WORKSPACE, but can be. (Something like WORKSPACE.new-repo-name may work well for - distinguishing it from the repository's actual WORKSPACE files.)</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("workspace_file", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(workspace_file_content) --> - The content for the WORKSPACE file for this repository. - - <p>Either workspace_file or workspace_file_content can be specified, but not both.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("workspace_file_content", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(type) --> - The archive type of the downloaded file. - - <p>By default, the archive type is determined from the file extension of the URL. If the - file has no extension, you can explicitly specify one of the following: `"zip"`, `"jar"`, - `"war"`, `"tar.gz"`, `"tgz"`, `"tar.xz"`, and `tar.bz2`</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("type", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(strip_prefix) --> - A directory prefix to strip from the extracted files. - - <p>Many archives contain a top-level directory that contains all of the useful files in - archive. Instead of needing to specify this prefix over and over in the - <code>build_file</code>, this field can be used to strip it from all of the extracted - files.</p> - - <p>For example, suppose you are using foo-lib-latest.zip, which contains the directory - foo-lib-1.2.3/ under which there are src/, lib/, and test/ directories that contain the - actual code you wish to build. Specify <code>strip_prefix = "foo-lib-1.2.3"</code> and - your <code>build_file</code> will not have to account for this top-level directory.</p> - - <p>Note that if there are files outside of this directory, they will be discarded and - inaccessible (e.g., a top-level license file). This includes files/directories that - start with the prefix but are not in the directory (e.g., foo-lib-1.2.3.release-notes). - If the specified prefix does not match a directory in the archive, Bazel will return an - error.</p> - <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr("strip_prefix", STRING)) - .setWorkspaceOnly() - .build(); - } - - @Override - public Metadata getMetadata() { - return RuleDefinition.Metadata.builder() - .name(NewHttpArchiveRule.NAME) - .type(RuleClass.Builder.RuleClassType.WORKSPACE) - .ancestors(WorkspaceBaseRule.class) - .factoryClass(WorkspaceConfiguredTargetFactory.class) - .build(); - } -} - -/*<!-- #BLAZE_RULE (NAME = new_http_archive, TYPE = OTHER, FAMILY = Workspace)[GENERIC_RULE] --> - -<p><strong>Deprecated. -<code>load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")</code> -for a drop-in replacement.</strong></p> - -<p>Downloads a compressed archive file, decompresses it, and creates a Bazel repository by -combining the archive with the provided BUILD file.</p> - -<p>It supports Zip-formatted archives and tarballs. The full set of extensions supported is -.zip, .jar, .war, .tar.gz, .tgz, .tar.xz, or .tar.bz2.</p> - -<h4 id="new_http_archive_examples">Examples</h4> - -<p>Suppose the current repository contains the source code for a chat program, rooted at the - directory <i>~/chat-app</i>. It needs to depend on an SSL library which is available from - <i>http://example.com/openssl.zip</i>. This .zip file contains the following directory - structure:</p> - -<pre class="code"> -src/ - openssl.cc - openssl.h -</pre> - -<p>In the local repository, the user creates a <i>BUILD.ssl</i> file which contains the following -target definition:</p> - -<pre class="code"> -cc_library( - name = "openssl-lib", - srcs = ["src/openssl.cc"], - hdrs = ["src/openssl.h"], -) -</pre> - -<p>Targets in the <i>~/chat-app</i> repository can depend on this target if the following lines are - added to <i>~/chat-app/WORKSPACE</i>:</p> - -<pre class="code"> -new_http_archive( - name = "my_ssl", - url = "http://example.com/openssl.zip", - sha256 = "03a58ac630e59778f328af4bcc4acb4f80208ed4", - build_file = "BUILD.ssl", -) -</pre> - -<p>Targets would specify <code>@my_ssl//:openssl-lib</code> as a dependency to depend on this - jar.</p> - -<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryRule.java b/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryRule.java index bb83728..cb6e02a 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryRule.java
@@ -53,7 +53,7 @@ <p>Either build_file or build_file_content must be specified.</p> <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ .add(attr("build_file_content", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(workspace_file) --> + /* <!-- #BLAZE_RULE(new_local_repository).ATTRIBUTE(workspace_file) --> The file to use as the WORKSPACE file for this repository. <p>Either workspace_file or workspace_file_content can be specified, but not both.</p> @@ -63,7 +63,7 @@ distinguishing it from the repository's actual WORKSPACE files.)</p> <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ .add(attr("workspace_file", STRING)) - /* <!-- #BLAZE_RULE(new_http_archive).ATTRIBUTE(workspace_file_content) --> + /* <!-- #BLAZE_RULE(new_local_repository).ATTRIBUTE(workspace_file_content) --> The content for the WORKSPACE file for this repository. <p>Either workspace_file or workspace_file_content can be specified, but not both.</p>
diff --git a/src/test/java/com/google/devtools/build/lib/repository/ExternalPackageUtilTest.java b/src/test/java/com/google/devtools/build/lib/repository/ExternalPackageUtilTest.java index d7f2840..8d6157b 100644 --- a/src/test/java/com/google/devtools/build/lib/repository/ExternalPackageUtilTest.java +++ b/src/test/java/com/google/devtools/build/lib/repository/ExternalPackageUtilTest.java
@@ -164,7 +164,7 @@ if (!analysisMock.isThisBazel()) { return; } - scratch.overwriteFile("WORKSPACE", "http_archive(name = 'foo', url = 'http://foo')"); + scratch.overwriteFile("WORKSPACE", "local_repository(name = 'foo', path = 'path/to/repo')"); SkyKey key = getRuleByNameKey("foo"); EvaluationResult<GetRuleByNameValue> result = getRuleByName(key); @@ -185,7 +185,7 @@ if (!analysisMock.isThisBazel()) { return; } - scratch.overwriteFile("WORKSPACE", "http_archive(name = 'foo', url = 'http://foo')"); + scratch.overwriteFile("WORKSPACE", "local_repository(name = 'foo', path = 'path/to/repo')"); SkyKey key = getRuleByNameKey("bar"); EvaluationResult<GetRuleByNameValue> result = getRuleByName(key);
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index 03d29a8..9f9efa7 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh
@@ -504,16 +504,6 @@ diff bazel-genfiles/timestamp first_timestamp || fail "Output was built again" } -function test_invalid_rule() { - # http_jar with missing URL field. - cat > WORKSPACE <<EOF -http_jar(name = 'endangered', sha256 = '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9826') -EOF - - bazel fetch //external:endangered >& $TEST_log && fail "Expected fetch to fail" - expect_log "missing value for mandatory attribute 'url' in 'http_jar' rule" -} - function test_new_remote_repo_with_build_file() { do_new_remote_repo_test "build_file" }