diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 619d5f7c0..54e27a4c7 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -31,50 +31,40 @@ tasks: name: "Example - Android" platform: ubuntu1804 shell_commands: - - "cd ../.. && bazel build //:rules_kotlin_release && rm -rf /tmp/rules_kotlin_release && mkdir -p /tmp/rules_kotlin_release && tar -C /tmp/rules_kotlin_release -xvf bazel-bin/rules_kotlin_release.tgz" + - "export RULES_KOTLIN_WORKSPACE_PATH=$(realpath ../..)" working_directory: examples/android - test_flags: - - "--override_repository=io_bazel_rules_kotlin=/tmp/rules_kotlin_release" test_targets: - //... example-associates: name: "Example - Associates" platform: ubuntu1804 shell_commands: - - "cd ../.. && bazel build //:rules_kotlin_release && rm -rf /tmp/rules_kotlin_release && mkdir -p /tmp/rules_kotlin_release && tar -C /tmp/rules_kotlin_release -xvf bazel-bin/rules_kotlin_release.tgz && cat /tmp/rules_kotlin_release/kotlin/internal/opts.bzl" + - "export RULES_KOTLIN_WORKSPACE_PATH=$(realpath ../..)" working_directory: examples/associates - test_flags: - - "--override_repository=io_bazel_rules_kotlin=/tmp/rules_kotlin_release" test_targets: - //... example-anvil: name: "Example - Anvil" platform: ubuntu1804 shell_commands: - - "cd ../.. && bazel build //:rules_kotlin_release && rm -rf /tmp/rules_kotlin_release && mkdir -p /tmp/rules_kotlin_release && tar -C /tmp/rules_kotlin_release -xvf bazel-bin/rules_kotlin_release.tgz && cat /tmp/rules_kotlin_release/kotlin/internal/opts.bzl" + - "export RULES_KOTLIN_WORKSPACE_PATH=$(realpath ../..)" working_directory: examples/anvil - #test_flags: - # - "--override_repository=io_bazel_rules_kotlin=/tmp/rules_kotlin_release" test_targets: - //... example-plugins: name: "Example - Plugins" platform: ubuntu1804 shell_commands: - - "cd ../.. && bazel build //:rules_kotlin_release && rm -rf /tmp/rules_kotlin_release && mkdir -p /tmp/rules_kotlin_release && tar -C /tmp/rules_kotlin_release -xvf bazel-bin/rules_kotlin_release.tgz && grep -R rkt_1_4 /tmp/rules_kotlin_release" + - "export RULES_KOTLIN_WORKSPACE_PATH=$(realpath ../..)" working_directory: examples/plugin - test_flags: - - "--override_repository=io_bazel_rules_kotlin=/tmp/rules_kotlin_release" test_targets: - //... examples-trivial: name: "Example - Trivial" platform: ubuntu1804 shell_commands: - - "cd ../.. && bazel build //:rules_kotlin_release && rm -rf /tmp/rules_kotlin_release && mkdir -p /tmp/rules_kotlin_release && tar -C /tmp/rules_kotlin_release -xvf bazel-bin/rules_kotlin_release.tgz" + - "export RULES_KOTLIN_WORKSPACE_PATH=$(realpath ../..)" working_directory: examples/trivial - test_flags: - - "--override_repository=io_bazel_rules_kotlin=/tmp/rules_kotlin_release" include_json_profile: - build - test @@ -84,13 +74,11 @@ tasks: name: Example - Node platform: ubuntu1804 shell_commands: - - "cd ../.. && bazel build //:rules_kotlin_release && rm -rf /tmp/rules_kotlin_release && mkdir -p /tmp/rules_kotlin_release && tar -C /tmp/rules_kotlin_release -xvf bazel-bin/rules_kotlin_release.tgz" + - "export RULES_KOTLIN_WORKSPACE_PATH=$(realpath ../..)" working_directory: examples/node include_json_profile: - build - test - test_flags: - - "--override_repository=io_bazel_rules_kotlin=/tmp/rules_kotlin_release" build_targets: - //coroutines-helloworld/... - //express/... diff --git a/.bazelignore b/.bazelignore index 2895b3ec1..f1cffcd7d 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1,10 +1,2 @@ -# Some examples have their own WORKSPACE. Ignore as part of this root WORKSPACE so -# we don't break trying to build separate workspaces using wildcards like //... -# examples/dagger doesn't have its own workspace, so don't do all of examples. -examples/android -examples/associates -examples/jetpack_compose -examples/node -examples/trivial -examples/anvil -examples/multiplex +# Exclude examples from //...:all +examples/* diff --git a/docs/kotlin.md b/docs/kotlin.md index 181ddcb45..b61fae361 100755 --- a/docs/kotlin.md +++ b/docs/kotlin.md @@ -436,8 +436,8 @@ Define the Kotlin toolchain. | experimental_report_unused_deps |
-
|None
|
| experimental_reduce_classpath_mode | -
|None
|
| experimental_multiplex_workers | -
|None
|
-| javac_options | -
|None
|
-| kotlinc_options | -
|None
|
+| javac_options | -
|Label("//kotlin/internal:default_javac_options")
|
+| kotlinc_options | -
|Label("//kotlin/internal:default_kotlinc_options")
|
| jacocorunner | -
|None
|
diff --git a/examples/android/WORKSPACE b/examples/android/WORKSPACE
index 436b73614..6fed611d0 100644
--- a/examples/android/WORKSPACE
+++ b/examples/android/WORKSPACE
@@ -1,19 +1,26 @@
workspace(name = "android_example")
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-# Directly load the kotlin rules from the parent repo.
local_repository(
- name = "io_bazel_rules_kotlin",
- path = "../..",
+ name = "release_archive",
+ path = "../release_archive",
)
-load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
+load("@release_archive//:repository.bzl", "archive_repository")
-kt_download_local_dev_dependencies()
+archive_repository(
+ name = "io_bazel_rules_kotlin",
+)
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "versions")
+kotlin_repositories()
+
+load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
+
+kt_register_toolchains()
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
http_archive(
name = "bazel_skylib",
sha256 = versions.SKYLIB_SHA,
diff --git a/examples/anvil/WORKSPACE b/examples/anvil/WORKSPACE
index ed009fcd5..e47187dc1 100644
--- a/examples/anvil/WORKSPACE
+++ b/examples/anvil/WORKSPACE
@@ -1,40 +1,30 @@
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-http_archive(
- name = "build_bazel_rules_android",
- sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
- strip_prefix = "rules_android-0.1.1",
- urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
+local_repository(
+ name = "release_archive",
+ path = "../release_archive",
)
-# Directly load the kotlin rules from the parent repo.
-rules_kotlin_version = "1.5.0-beta-3"
-
-rules_kotlin_sha = "d8650bb939d87a080448ffbbbd1594f5ae054738df5d9471941c18784aa139b9"
+load("@release_archive//:repository.bzl", "archive_repository")
-http_archive(
+archive_repository(
name = "io_bazel_rules_kotlin",
- sha256 = rules_kotlin_sha,
- strip_prefix = "rules_kotlin-%s" % rules_kotlin_version,
- type = "zip",
- urls = ["https://github.com/bazelbuild/rules_kotlin/archive/v%s.zip" % rules_kotlin_version],
)
-print("loading repositories")
-
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "versions")
-print("setting up repositories")
-
-kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below
-
-print("loading core")
+kotlin_repositories()
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
-print("registering toolchians")
+kt_register_toolchains()
-kt_register_toolchains() # to use the default toolchain, otherwise see toolchains below
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
+ name = "build_bazel_rules_android",
+ sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
+ strip_prefix = "rules_android-0.1.1",
+ urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
+)
load(
"@build_bazel_rules_android//android:rules.bzl",
diff --git a/examples/associates/WORKSPACE b/examples/associates/WORKSPACE
index 611f443ab..7382dbf6b 100644
--- a/examples/associates/WORKSPACE
+++ b/examples/associates/WORKSPACE
@@ -1,8 +1,23 @@
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+local_repository(
+ name = "release_archive",
+ path = "../release_archive",
+)
+
+load("@release_archive//:repository.bzl", "archive_repository")
-SKYLIB_VERSION = "1.0.3"
+archive_repository(
+ name = "io_bazel_rules_kotlin",
+)
+
+load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "versions")
-SKYLIB_SHA = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c"
+kotlin_repositories()
+
+load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
+
+kt_register_toolchains()
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_android",
@@ -20,27 +35,13 @@ http_archive(
http_archive(
name = "bazel_skylib",
- sha256 = SKYLIB_SHA,
- urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/%s/bazel-skylib-%s.tar.gz" % (SKYLIB_VERSION, SKYLIB_VERSION)],
+ sha256 = versions.SKYLIB_SHA,
+ urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/%s/bazel-skylib-%s.tar.gz" % (
+ versions.SKYLIB_VERSION,
+ versions.SKYLIB_VERSION,
+ )],
)
-local_repository(
- name = "io_bazel_rules_kotlin",
- path = "../..",
-)
-
-load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
-
-kt_download_local_dev_dependencies()
-
-load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "versions")
-
-kotlin_repositories()
-
-load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
-
-kt_register_toolchains()
-
http_archive(
name = "rules_jvm_external",
sha256 = versions.RULES_JVM_EXTERNAL_SHA,
diff --git a/examples/dagger/BUILD b/examples/dagger/BUILD
index ce69e5f14..7a3437c99 100644
--- a/examples/dagger/BUILD
+++ b/examples/dagger/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("@rules_java//java:defs.bzl", "java_binary")
-load("//kotlin:jvm.bzl", "kt_jvm_library")
+load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
package(default_visibility = ["//visibility:private"])
@@ -58,7 +58,7 @@ kt_jvm_library(
],
deps = [
"//third_party:dagger",
- "@kotlin_rules_maven//:org_jetbrains_kotlinx_kotlinx_coroutines_core",
+ "@maven//:org_jetbrains_kotlinx_kotlinx_coroutines_core",
],
)
diff --git a/examples/dagger/WORKSPACE b/examples/dagger/WORKSPACE
new file mode 100644
index 000000000..9563fa3ae
--- /dev/null
+++ b/examples/dagger/WORKSPACE
@@ -0,0 +1,42 @@
+local_repository(
+ name = "release_archive",
+ path = "../release_archive",
+)
+
+load("@release_archive//:repository.bzl", "archive_repository")
+
+archive_repository(
+ name = "io_bazel_rules_kotlin",
+)
+
+load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "versions")
+
+kotlin_repositories()
+
+load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
+
+kt_register_toolchains()
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
+ name = "rules_jvm_external",
+ sha256 = versions.RULES_JVM_EXTERNAL_SHA,
+ strip_prefix = "rules_jvm_external-%s" % versions.RULES_JVM_EXTERNAL_TAG,
+ url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % versions.RULES_JVM_EXTERNAL_TAG,
+)
+
+load("@rules_jvm_external//:defs.bzl", "maven_install")
+
+maven_install(
+ artifacts = [
+ "com.google.dagger:dagger:2.35.1",
+ "com.google.dagger:dagger-compiler:2.35.1",
+ "com.google.dagger:dagger-producers:2.35.1",
+ "javax.inject:javax.inject:1",
+ "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2",
+ ],
+ repositories = [
+ "https://repo1.maven.org/maven2",
+ ],
+)
diff --git a/examples/dagger/third_party/BUILD.bazel b/examples/dagger/third_party/BUILD.bazel
new file mode 100644
index 000000000..e970b921c
--- /dev/null
+++ b/examples/dagger/third_party/BUILD.bazel
@@ -0,0 +1,21 @@
+load("@rules_java//java:defs.bzl", "java_library", "java_plugin")
+
+java_plugin(
+ name = "dagger_component_plugin",
+ generates_api = True,
+ processor_class = "dagger.internal.codegen.ComponentProcessor",
+ visibility = ["//visibility:private"],
+ deps = [
+ "@maven//:com_google_dagger_dagger_compiler",
+ ],
+)
+
+java_library(
+ name = "dagger",
+ exported_plugins = [":dagger_component_plugin"],
+ visibility = ["//visibility:public"],
+ exports = [
+ "@maven//:com_google_dagger_dagger",
+ "@maven//:javax_inject_javax_inject",
+ ],
+)
diff --git a/examples/jetpack_compose/WORKSPACE b/examples/jetpack_compose/WORKSPACE
index 65bda2f61..eb1273b57 100644
--- a/examples/jetpack_compose/WORKSPACE
+++ b/examples/jetpack_compose/WORKSPACE
@@ -1,3 +1,20 @@
+local_repository(
+ name = "release_archive",
+ path = "../release_archive",
+)
+
+load("@release_archive//:repository.bzl", "archive_repository")
+
+archive_repository(
+ name = "io_bazel_rules_kotlin",
+)
+
+load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
+
+kotlin_repositories()
+
+register_toolchains("//:kotlin_toolchain")
+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
_KOTLIN_COMPILER_VERSION = "1.4.21"
@@ -127,20 +144,3 @@ android_sdk_repository(
name = "androidsdk",
api_level = 29,
)
-
-## Kotlin
-
-local_repository(
- name = "io_bazel_rules_kotlin",
- path = "../..",
-)
-
-load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
-
-kt_download_local_dev_dependencies()
-
-load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
-
-kotlin_repositories()
-
-register_toolchains("//:kotlin_toolchain")
diff --git a/examples/multiplex/WORKSPACE b/examples/multiplex/WORKSPACE
index 48bcdd6c1..16e6b8ff3 100644
--- a/examples/multiplex/WORKSPACE
+++ b/examples/multiplex/WORKSPACE
@@ -1,13 +1,15 @@
workspace(name = "multiplex")
local_repository(
- name = "io_bazel_rules_kotlin",
- path = "../..",
+ name = "release_archive",
+ path = "../release_archive",
)
-load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
+load("@release_archive//:repository.bzl", "archive_repository")
-kt_download_local_dev_dependencies()
+archive_repository(
+ name = "io_bazel_rules_kotlin",
+)
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
diff --git a/examples/node/WORKSPACE b/examples/node/WORKSPACE
index 13a67b6eb..6828a7385 100644
--- a/examples/node/WORKSPACE
+++ b/examples/node/WORKSPACE
@@ -1,16 +1,15 @@
workspace(name = "kotlin_node_examples")
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-# Directly load the kotlin rules from the parent repo.
local_repository(
- name = "io_bazel_rules_kotlin",
- path = "../..",
+ name = "release_archive",
+ path = "../release_archive",
)
-load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
+load("@release_archive//:repository.bzl", "archive_repository")
-kt_download_local_dev_dependencies()
+archive_repository(
+ name = "io_bazel_rules_kotlin",
+)
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "versions")
@@ -20,6 +19,8 @@ load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
http_archive(
name = "rules_jvm_external",
sha256 = versions.RULES_JVM_EXTERNAL_SHA,
diff --git a/examples/plugin/WORKSPACE b/examples/plugin/WORKSPACE
index a2e599f4a..36297bd96 100644
--- a/examples/plugin/WORKSPACE
+++ b/examples/plugin/WORKSPACE
@@ -1,42 +1,14 @@
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-SKYLIB_VERSION = "1.0.3"
-
-SKYLIB_SHA = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c"
-
-RULES_JVM_EXTERNAL_TAG = "4.1"
-
-RULES_JVM_EXTERNAL_SHA = "f36441aa876c4f6427bfb2d1f2d723b48e9d930b62662bf723ddfb8fc80f0140"
-
-http_archive(
- name = "bazel_skylib",
- sha256 = SKYLIB_SHA,
- urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/%s/bazel-skylib-%s.tar.gz" % (SKYLIB_VERSION, SKYLIB_VERSION)],
+local_repository(
+ name = "release_archive",
+ path = "../release_archive",
)
-http_archive(
- name = "rules_android",
- sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
- strip_prefix = "rules_android-0.1.1",
- urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
-)
+load("@release_archive//:repository.bzl", "archive_repository")
-http_archive(
- name = "rules_jvm_external",
- sha256 = RULES_JVM_EXTERNAL_SHA,
- strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
- url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
-)
-
-local_repository(
+archive_repository(
name = "io_bazel_rules_kotlin",
- path = "../..",
)
-load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
-
-kt_download_local_dev_dependencies()
-
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "versions")
kotlin_repositories()
@@ -45,6 +17,15 @@ load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
+ name = "rules_jvm_external",
+ sha256 = versions.RULES_JVM_EXTERNAL_SHA,
+ strip_prefix = "rules_jvm_external-%s" % versions.RULES_JVM_EXTERNAL_TAG,
+ url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % versions.RULES_JVM_EXTERNAL_TAG,
+)
+
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
diff --git a/examples/release_archive/BUILD.bazel b/examples/release_archive/BUILD.bazel
new file mode 100644
index 000000000..e69de29bb
diff --git a/examples/release_archive/README.md b/examples/release_archive/README.md
new file mode 100644
index 000000000..fff636ab0
--- /dev/null
+++ b/examples/release_archive/README.md
@@ -0,0 +1,3 @@
+# archive workspace
+
+archive pr
diff --git a/examples/release_archive/WORKSPACE b/examples/release_archive/WORKSPACE
new file mode 100644
index 000000000..e69de29bb
diff --git a/examples/release_archive/repository.bzl b/examples/release_archive/repository.bzl
new file mode 100644
index 000000000..a043b6798
--- /dev/null
+++ b/examples/release_archive/repository.bzl
@@ -0,0 +1,117 @@
+versions = struct(
+ RULES_KOTLIN = struct(
+ urls = [
+ "https://github.com/bazelbuild/rules_kotlin/archive/v1.5.0-beta-3.zip",
+ ],
+ sha256 = "d8650bb939d87a080448ffbbbd1594f5ae054738df5d9471941c18784aa139b9",
+ prefix = "rules_kotlin-1.5.0-beta-3",
+ ),
+)
+
+def archive_repository_implementation(repository_ctx):
+ attr = repository_ctx.attr
+
+ # In a perfect world, the local archive path would be set via a build config setting
+ # Alas, a repository label is never replaced with a target -- meaning repository_rules are
+ # evaluated first (reasonable) but disallow using settings as they need to be targets.
+ # One day, one hopes that there will be a flag to control repository behavior.
+ # Instead, environment variables are a tried and true workaround.
+ environ = repository_ctx.os.environ
+
+ if attr.env_archive in environ:
+ repository_ctx.extract(
+ archive = environ[attr.env_archive],
+ stripPrefix = environ.get(attr.env_archive_prefix, ""),
+ )
+ elif attr.env_stable in environ:
+ repository_ctx.download_and_extract(
+ attr._remote_urls,
+ sha256 = attr._remote_sha256,
+ stripPrefix = attr._remote_prefix,
+ )
+ else:
+ # not OS safe. Presuming linux-likes until complaints.
+ workspace = _find_workspace(attr, environ, repository_ctx.path)
+
+ release_archive = attr.local_release_archive_target
+
+ target = "//%s:%s" % (release_archive.package, release_archive.name)
+
+ repository_ctx.report_progress(
+ "Building %s in %s... (may take a while.)" % (target, workspace)
+ )
+
+ result = repository_ctx.execute(
+ [
+ "bazel",
+ "build",
+ target,
+ ],
+ working_directory = str(workspace),
+ timeout = 1200, # build take a minute.
+ )
+
+ if result.return_code:
+ fail("%s: %s\n%s\n\nenv:%s" % (str(base), result.stderr, result.stdout, environ))
+ release_artifact = base.get_child("bazel-bin")
+ if release_archive.package:
+ release_artifact = release_artifact.get_child(release_archive.package)
+ release_artifact = release_artifact.get_child(release_archive.name + ".tgz")
+
+ repository_ctx.extract(
+ archive = release_artifact,
+ )
+
+# not windows compatible.
+def _find_workspace(attr, environ, path):
+ if attr.local_repository_path_env in environ:
+ workspace = path(environ[attr.local_repository_path_env])
+ if workspace.exists:
+ return workspace
+ if attr.local_repository_path.startswith(sep):
+ return path(attr.local_repository_path)
+
+ return path(environ["PWD"] + '/' + attr.local_repository_path)
+
+
+archive_repository = repository_rule(
+ implementation = archive_repository_implementation,
+ attrs = {
+ "_remote_urls": attr.string_list(
+ doc = "A list of urls for the archive",
+ default = versions.RULES_KOTLIN.urls,
+ ),
+ "_remote_sha256": attr.string(
+ doc = "sha256 of the archive",
+ default = versions.RULES_KOTLIN.sha256,
+ ),
+ "_remote_prefix": attr.string(
+ doc = "prefix to remove from the remote archive",
+ default = versions.RULES_KOTLIN.prefix,
+ ),
+ "local_repository_path": attr.string(
+ doc = "local repository directory",
+ default = "../..",
+ ),
+ "local_repository_path_env": attr.string(
+ doc = "local repository directory",
+ default = "RULES_KOTLIN_WORKSPACE_PATH",
+ ),
+ "local_release_archive_target": attr.label(
+ doc = "release_archive rule.",
+ default = Label("//:rules_kotlin_release"),
+ ),
+ "env_archive": attr.string(
+ doc = "release archive path environment variable name",
+ default = "RULES_KOTLIN_ARCHIVE",
+ ),
+ "env_archive_prefix": attr.string(
+ doc = "release archive path environment variable name",
+ default = "RULES_KOTLIN_ARCHIVE_PREFIX",
+ ),
+ "env_stable": attr.string(
+ doc = "Use stable release",
+ default = "RULES_KOTLIN_STABLE",
+ ),
+ },
+)
diff --git a/examples/release_archive/versions.bzl b/examples/release_archive/versions.bzl
new file mode 100644
index 000000000..e69de29bb
diff --git a/examples/trivial/WORKSPACE b/examples/trivial/WORKSPACE
index 2e254be08..5ff78cdb4 100644
--- a/examples/trivial/WORKSPACE
+++ b/examples/trivial/WORKSPACE
@@ -1,15 +1,17 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
local_repository(
- name = "io_bazel_rules_kotlin",
- path = "../..",
+ name = "release_archive",
+ path = "../release_archive",
)
-load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
+load("@release_archive//:repository.bzl", "archive_repository")
-kt_download_local_dev_dependencies()
+archive_repository(
+ name = "io_bazel_rules_kotlin",
+)
-load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
+load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "versions")
kotlin_repositories()
@@ -17,15 +19,11 @@ load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains()
-RULES_JVM_EXTERNAL_TAG = "2.7"
-
-RULES_JVM_EXTERNAL_SHA = "f04b1466a00a2845106801e0c5cec96841f49ea4e7d1df88dc8e4bf31523df74"
-
http_archive(
name = "rules_jvm_external",
- sha256 = RULES_JVM_EXTERNAL_SHA,
- strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
- url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
+ sha256 = versions.RULES_JVM_EXTERNAL_SHA,
+ strip_prefix = "rules_jvm_external-%s" % versions.RULES_JVM_EXTERNAL_TAG,
+ url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % versions.RULES_JVM_EXTERNAL_TAG,
)
load("@rules_jvm_external//:defs.bzl", "maven_install")
diff --git a/scripts/release.sh b/scripts/release.sh
index 3f988ba2d..a5d20a002 100755
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -53,10 +53,8 @@ bazel build //:rules_kotlin_release || fail "release archive failed"
# unpack to for repository overriding
ARCHIVE_DIR="$TMPDIR/rules_kotlin_release"
-rm -rf $ARCHIVE_DIR
-mkdir $ARCHIVE_DIR
+RELEASE_ARCHIVE=$(realpath bazel-bin/rules_kotlin_release.tgz)
-tar -C $ARCHIVE_DIR -xzvf bazel-bin/rules_kotlin_release.tgz
shasum -a 256 bazel-bin/rules_kotlin_release.tgz >bazel-bin/rules_kotlin_release.tgz.sha256
# iterate through the examples and build them
@@ -64,7 +62,9 @@ for ex in examples/*/; do
if [[ -f "$ex/WORKSPACE" ]] && ! [[ -f "$ex/ignore.me" ]]; then
(
cd "$ex"
- bazel build ${BUILD_ARGS} --override_repository=io_bazel_rules_kotlin=$ARCHIVE_DIR //...:all
+ # shellcheck disable=SC1007
+ export RULES_KOTLIN_ARCHIVE="$RELEASE_ARCHIVE"
+ bazel build ${BUILD_ARGS} //...:all
) || fail "$ex failed to build"
fi
done
@@ -80,3 +80,4 @@ cp -f bazel-bin/kotlin/kotlin.md docs/ || fail "couldn't copy"
echo "Release artifact is good:"
echo " bazel-bin/rules_kotlin_release.tgz"
echo " bazel-bin/rules_kotlin_release.tgz.sha256"
+echo "sha256: $(cat bazel-bin/rules_kotlin_release.tgz.sha256)"