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 support for custom java install with coursier #533

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion coursier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ def _generate_java_jar_command(repository_ctx, jar_path):
coursier_opts = repository_ctx.os.environ.get("COURSIER_OPTS", "")
coursier_opts = coursier_opts.split(" ") if len(coursier_opts) > 0 else []

if java_home != None:
if repository_ctx.attr.java_binary != None:
java = repository_ctx.path(repository_ctx.attr.java_binary)
cmd = [java, "-noverify", "-jar"] + coursier_opts + _get_java_proxy_args(repository_ctx) + [jar_path]
elif java_home != None:
# https://github.com/coursier/coursier/blob/master/doc/FORMER-README.md#how-can-the-launcher-be-run-on-windows-or-manually-with-the-java-program
# The -noverify option seems to be required after the proguarding step
# of the main JAR of coursier.
Expand Down Expand Up @@ -1120,6 +1123,7 @@ coursier_fetch = repository_rule(
"resolve_timeout": attr.int(default = 600),
"jetify": attr.bool(doc = "Runs the AndroidX [Jetifier](https://developer.android.com/studio/command-line/jetifier) tool on artifacts specified in jetify_include_list. If jetify_include_list is not specified, run Jetifier on all artifacts.", default = False),
"jetify_include_list": attr.string_list(doc = "List of artifacts that need to be jetified in `groupId:artifactId` format. By default all artifacts are jetified if `jetify` is set to True.", default = JETIFY_INCLUDE_LIST_JETIFY_ALL),
"java_binary": attr.label(doc = "Full path to a java executable", default = None),
"use_starlark_android_rules": attr.bool(default = False, doc = "Whether to use the native or Starlark version of the Android rules."),
"aar_import_bzl_label": attr.string(default = DEFAULT_AAR_IMPORT_LABEL, doc = "The label (as a string) to use to import aar_import from"),
},
Expand Down
3 changes: 3 additions & 0 deletions defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def maven_install(
resolve_timeout = 600,
jetify = False,
jetify_include_list = JETIFY_INCLUDE_LIST_JETIFY_ALL,
java_binary = None,
additional_netrc_lines = [],
fail_if_repin_required = False,
use_starlark_android_rules = False,
Expand Down Expand Up @@ -77,6 +78,7 @@ def maven_install(
resolve_timeout: The execution timeout of resolving and fetching artifacts.
jetify: Runs the AndroidX [Jetifier](https://developer.android.com/studio/command-line/jetifier) tool on artifacts specified in jetify_include_list. If jetify_include_list is not specified, run Jetifier on all artifacts.
jetify_include_list: List of artifacts that need to be jetified in `groupId:artifactId` format. By default all artifacts are jetified if `jetify` is set to True.
java_binary: Label pointing to a java binary if you want to provide a custom installation (default: None)
additional_netrc_lines: Additional lines prepended to the netrc file used by `http_file` (with `maven_install_json` only).
fail_if_repin_required: Whether to fail the build if the required maven artifacts have been changed but not repinned. Requires the `maven_install_json` to have been set.
use_starlark_android_rules: Whether to use the native or Starlark version
Expand Down Expand Up @@ -134,6 +136,7 @@ def maven_install(
resolve_timeout = resolve_timeout,
jetify = jetify,
jetify_include_list = jetify_include_list,
java_binary = java_binary,
use_starlark_android_rules = use_starlark_android_rules,
aar_import_bzl_label = aar_import_bzl_label,
)
Expand Down