Set default of --incompatible_remove_native_{http_archive,git_repository} to true

...and switch tests to test the skylark implementation rather than the (deprecated,
by default disabled) native implementation.

(Rollforward with remaining calls to the native funcitons in the WORKSPACE
 adapted as well, tus fixing bazel_determinism_test.)

Change-Id: I3b604a27615f36463e62112dd02319fcf24f90f0
PiperOrigin-RevId: 218309750
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
index 07de157..13610e5 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredRuleClassProvider.java
@@ -267,6 +267,12 @@
       return this;
     }
 
+    @VisibleForTesting
+    public Builder clearWorkspaceFileSuffixForTesting() {
+      defaultWorkspaceFileSuffix.delete(0, defaultWorkspaceFileSuffix.length());
+      return this;
+    }
+
     public Builder setPrelude(String preludeLabelString) {
       try {
         this.preludeLabel = Label.parseAbsolute(preludeLabelString, ImmutableMap.of());
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE
index 8c8879e..bead2bd 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE
@@ -1,4 +1,5 @@
 # External dependencies for the java_* rules.
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
 
 new_local_repository(
     name = "local_jdk",
@@ -88,89 +89,89 @@
 # This will allow us to stop bundling the full JDK with Bazel.
 # Note that while these are currently the same as the openjdk_* rules in
 # Bazel's WORKSPACE file, but they don't have to be the same.
-new_http_archive(
+http_archive(
     name = "remotejdk_linux",
     sha256 = "f27cb933de4f9e7fe9a703486cf44c84bc8e9f138be0c270c9e5716a32367e87",
     urls = [
         "https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-linux_x64-allmodules.tar.gz",
     ],
-    build_file = __embedded_dir__ + "/jdk.BUILD",
+    build_file = "@local_jdk//:BUILD.bazel",
     strip_prefix = "zulu9.0.7.1-jdk9.0.7-linux_x64-allmodules",
 )
 
-new_http_archive(
+http_archive(
     name = "remotejdk_macos",
     sha256 = "404e7058ff91f956612f47705efbee8e175a38b505fb1b52d8c1ea98718683de",
     urls = [
         "https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-macosx_x64-allmodules.tar.gz",
     ],
-    build_file = __embedded_dir__ + "/jdk.BUILD",
+    build_file = "@local_jdk//:BUILD.bazel",
     strip_prefix = "zulu9.0.7.1-jdk9.0.7-macosx_x64-allmodules",
 )
 
-new_http_archive(
+http_archive(
     name = "remotejdk_win",
     sha256 = "e738829017f107e7a7cd5069db979398ec3c3f03ef56122f89ba38e7374f63ed",
     urls = [
         "https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-win_x64-allmodules.zip",
     ],
-    build_file = __embedded_dir__ + "/jdk.BUILD",
+    build_file = "@local_jdk//:BUILD.bazel",
     strip_prefix = "zulu9.0.7.1-jdk9.0.7-win_x64-allmodules",
 )
 
 # The source-code for this OpenJDK can be found at:
 # https://openjdk.linaro.org/releases/jdk9-src-1708.tar.xz
-new_http_archive(
+http_archive(
     name = "remotejdk_linux_aarch64",
     sha256 = "72e7843902b0395e2d30e1e9ad2a5f05f36a4bc62529828bcbc698d54aec6022",
     urls = [
         # When you update this, also update the link to the source-code above.
         "http://openjdk.linaro.org/releases/jdk9-server-release-1708.tar.xz",
     ],
-    build_file = __embedded_dir__ + "/jdk.BUILD",
+    build_file = "@local_jdk//:BUILD.bazel",
     strip_prefix = "jdk9-server-release-1708",
 )
 
-new_http_archive(
+http_archive(
     name = "remotejdk10_linux",
     sha256 = "57fad3602e74c79587901d6966d3b54ef32cb811829a2552163185d5064fe9b5",
     urls = [
         "https://mirror.bazel.build/openjdk/azul-zulu10.2+3-jdk10.0.1/zulu10.2+3-jdk10.0.1-linux_x64-allmodules.tar.gz",
     ],
-    build_file = __embedded_dir__ + "/jdk.BUILD",
+    build_file = "@local_jdk//:BUILD.bazel",
     strip_prefix = "zulu10.2+3-jdk10.0.1-linux_x64-allmodules",
 )
 
 
-new_http_archive(
+http_archive(
     name = "remotejdk10_macos",
     sha256 = "e669c9a897413d855b550b4e39d79614392e6fb96f494e8ef99a34297d9d85d3",
     urls = [
         "https://mirror.bazel.build/openjdk/azul-zulu10.2+3-jdk10.0.1/zulu10.2+3-jdk10.0.1-macosx_x64-allmodules.tar.gz",
     ],
-    build_file = __embedded_dir__ + "/jdk.BUILD",
+    build_file = "@local_jdk//:BUILD.bazel",
     strip_prefix = "zulu10.2+3-jdk10.0.1-macosx_x64-allmodules"
 )
 
-new_http_archive(
+http_archive(
     name = "remotejdk10_win",
     sha256 = "c39e7700a8d41794d60985df5a20352435196e78ecbc6a2b30df7be8637bffd5",
     urls = [
         "https://mirror.bazel.build/openjdk/azul-zulu10.2+3-jdk10.0.1/zulu10.2+3-jdk10.0.1-win_x64-allmodules.zip",
     ],
-    build_file = __embedded_dir__ + "/jdk.BUILD",
+    build_file = "@local_jdk//:BUILD.bazel",
     strip_prefix = "zulu10.2+3-jdk10.0.1-win_x64-allmodules",
 )
 
 # The source-code for this OpenJDK can be found at:
 # https://openjdk.linaro.org/releases/jdk10-src-1804.tar.xz
-new_http_archive(
+http_archive(
     name = "remotejdk10_linux_aarch64",
     sha256 = "b7098b7aaf6ee1ffd4a2d0371a0be26c5a5c87f6aebbe46fe9a92c90583a84be",
     urls = [
         # When you update this, also update the link to the source-code above.
         "http://openjdk.linaro.org/releases/jdk10-server-release-1804.tar.xz",
     ],
-    build_file = __embedded_dir__ + "/jdk.BUILD",
+    build_file = "@local_jdk//:BUILD.bazel",
     strip_prefix = "jdk10-server-release-1804",
 )
diff --git a/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java
index 3ff7dff..ac602c6 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java
@@ -445,7 +445,7 @@
 
   @Option(
       name = "incompatible_remove_native_git_repository",
-      defaultValue = "false",
+      defaultValue = "true",
       documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS,
       effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
       metadataTags = {
@@ -454,13 +454,12 @@
       },
       help =
           "If set to true, the native git_repository rules are disabled; only the skylark version "
-              + "will be available"
-  )
+              + "will be available")
   public boolean incompatibleRemoveNativeGitRepository;
 
   @Option(
       name = "incompatible_remove_native_http_archive",
-      defaultValue = "false",
+      defaultValue = "true",
       documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS,
       effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
       metadataTags = {
@@ -469,8 +468,7 @@
       },
       help =
           "If set to true, the native http_archive rules are disabled; only the skylark version "
-              + "will be available"
-  )
+              + "will be available")
   public boolean incompatibleRemoveNativeHttpArchive;
 
   @Option(
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java
index df6e9f9..cb3886d 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java
@@ -219,8 +219,8 @@
           .incompatibleNoTransitiveLoads(false)
           .incompatiblePackageNameIsAFunction(false)
           .incompatibleRangeType(false)
-          .incompatibleRemoveNativeGitRepository(false)
-          .incompatibleRemoveNativeHttpArchive(false)
+          .incompatibleRemoveNativeGitRepository(true)
+          .incompatibleRemoveNativeHttpArchive(true)
           .incompatibleStaticNameResolution(false)
           .incompatibleStringIsNotIterable(false)
           .internalSkylarkFlagTestCanary(false)
diff --git a/src/main/tools/jdk.BUILD b/src/main/tools/jdk.BUILD
index ce757ac..31fbb64 100644
--- a/src/main/tools/jdk.BUILD
+++ b/src/main/tools/jdk.BUILD
@@ -1,5 +1,7 @@
 package(default_visibility = ["//visibility:public"])
 
+exports_files(["BUILD.bazel"])
+
 DEPRECATION_MESSAGE = ("Don't depend on targets in the JDK workspace;" +
                        " use @bazel_tools//tools/jdk:current_java_runtime instead" +
                        " (see https://github.com/bazelbuild/bazel/issues/5594)")