Skip to content

Commit

Permalink
Remove "jetify" functionality (#971)
Browse files Browse the repository at this point in the history
This has been deprecated for a while, and the list of dependencies that required
jetifying is old. It is hoped that people will have updated their own dependencies
by now, rather than requiring this tooling to handle that case.
  • Loading branch information
shs96c committed Oct 20, 2023
1 parent 65183c7 commit 99ca15d
Show file tree
Hide file tree
Showing 36 changed files with 11 additions and 957 deletions.
16 changes: 0 additions & 16 deletions .allstar/binary_artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,3 @@ ignorePaths:
- private/tools/prebuilt/hasher_deploy.jar
- private/tools/prebuilt/list_packages_deploy.jar
- private/tools/prebuilt/outdated_deploy.jar
- third_party/jetifier/jetifier-standalone/bin/jetifier-standalone
- third_party/jetifier/jetifier-standalone/bin/jetifier-standalone.bat
- third_party/jetifier/jetifier-standalone/lib/annotations-13.0.jar
- third_party/jetifier/jetifier-standalone/lib/asm-8.0.1.jar
- third_party/jetifier/jetifier-standalone/lib/asm-analysis-8.0.1.jar
- third_party/jetifier/jetifier-standalone/lib/asm-commons-8.0.1.jar
- third_party/jetifier/jetifier-standalone/lib/asm-tree-8.0.1.jar
- third_party/jetifier/jetifier-standalone/lib/asm-util-8.0.1.jar
- third_party/jetifier/jetifier-standalone/lib/commons-cli-1.3.1.jar
- third_party/jetifier/jetifier-standalone/lib/gson-2.8.0.jar
- third_party/jetifier/jetifier-standalone/lib/jdom2-2.0.6.jar
- third_party/jetifier/jetifier-standalone/lib/jetifier-core-1.0.0-beta10.jar
- third_party/jetifier/jetifier-standalone/lib/jetifier-processor-1.0.0-beta10.jar
- third_party/jetifier/jetifier-standalone/lib/jetifier-standalone.jar
- third_party/jetifier/jetifier-standalone/lib/kotlin-stdlib-1.3.71.jar
- third_party/jetifier/jetifier-standalone/lib/kotlin-stdlib-common-1.3.71.jar
2 changes: 0 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ bzl_library(
"//private/rules:has_maven_deps.bzl",
"//private/rules:java_export.bzl",
"//private/rules:javadoc.bzl",
"//private/rules:jetifier.bzl",
"//private/rules:jetifier_maven_map.bzl",
"//private/rules:jvm_import.bzl",
"//private/rules:maven_bom.bzl",
"//private/rules:maven_bom_fragment.bzl",
Expand Down
31 changes: 0 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Table of Contents
* [Repository remapping](#repository-remapping)
* [Hiding transitive dependencies](#hiding-transitive-dependencies)
* [Fetch and resolve timeout](#fetch-and-resolve-timeout)
* [Jetifier](#jetifier)
* [Duplicate artifact warning](#duplicate-artifact-warning)
* [Resolving issues with nonstandard system default JDKs](#resolving-issues-with-nonstandard-system-default-jdks)
* [Exporting and consuming artifacts from external repositories](#exporting-and-consuming-artifacts-from-external-repositories)
Expand Down Expand Up @@ -870,36 +869,6 @@ maven_install(
)
```

### Jetifier

As part of the [Android
Jetpack](https://medium.com/google-developer-experts/converting-your-android-app-to-jetpack-85aecfce34d3)
migration, convert legacy Android support library (`com.android.support`)
libraries to rely on new AndroidX packages using the
[Jetifier](https://developer.android.com/studio/command-line/jetifier) tool.
Enable jetification by specifying `jetify = True` in `maven_install.`
Control which artifacts to jetify with `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.

NOTE: There is a performance penalty to using jetifier due to modifying fetched binaries, fetching
additional `AndroidX` artifacts, and modifying the maven dependency graph.

```python
maven_install(
artifacts = [
# ...
],
repositories = [
# ...
],
jetify = True,
# Optional
jetify_include_list = [
"exampleGroupId:exampleArtifactId",
],
)
```

### Duplicate artifact warning

By default you will be warned if there are duplicate artifacts in your artifact list. The `duplicate_version_warning` setting can be used to change this behavior. Use "none" to disable the warning and "error" to fail the build instead of warn.
Expand Down
48 changes: 0 additions & 48 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -382,37 +382,6 @@ load("@maven_install_in_custom_location//:defs.bzl", "pinned_maven_install")

pinned_maven_install()

maven_install(
name = "jetify_all_test",
artifacts = [
"com.google.guava:guava:27.0-jre",
"com.android.support:appcompat-v7:28.0.0",
"com.android.support:swiperefreshlayout:28.0.0",
],
jetify = True,
repositories = [
"https://repo1.maven.org/maven2",
"https://maven.google.com",
],
)

maven_install(
name = "jetify_include_list_test",
artifacts = [
"com.google.guava:guava:27.0-jre",
"com.android.support:appcompat-v7:28.0.0",
"com.android.support:swiperefreshlayout:28.0.0",
],
jetify = True,
jetify_include_list = [
"com.android.support:appcompat-v7",
],
repositories = [
"https://repo1.maven.org/maven2",
"https://maven.google.com",
],
)

maven_install(
name = "duplicate_version_warning",
artifacts = [
Expand Down Expand Up @@ -483,7 +452,6 @@ maven_install(
"androidx.work:work-runtime:2.6.0",
],
fetch_sources = True,
jetify = False,
repositories = [
"https://repo1.maven.org/maven2",
"https://maven.google.com",
Expand All @@ -507,22 +475,6 @@ maven_install(
use_starlark_android_rules = True,
)

maven_install(
name = "starlark_aar_import_with_jetify_test",
# Not actually necessary since this is the default value, but useful for
# testing.
aar_import_bzl_label = "@build_bazel_rules_android//android:rules.bzl",
artifacts = [
"com.android.support:appcompat-v7:28.0.0",
],
jetify = True,
repositories = [
"https://repo1.maven.org/maven2",
"https://maven.google.com",
],
use_starlark_android_rules = True,
)

# for the above "starlark_aar_import_test" maven_install with
# use_starlark_android_rules = True
http_archive(
Expand Down
51 changes: 2 additions & 49 deletions coursier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and

load("//:specs.bzl", "parse", "utils")
load("//:specs.bzl", "utils")
load("//private:artifact_utilities.bzl", "deduplicate_and_sort_artifacts")
load("//private:coursier_utilities.bzl", "SUPPORTED_PACKAGING_TYPES", "escape", "is_maven_local_path")
load("//private:dependency_tree_parser.bzl", "JETIFY_INCLUDE_LIST_JETIFY_ALL", "parser")
load("//private:dependency_tree_parser.bzl", "parser")
load("//private:java_utilities.bzl", "build_java_argsfile_content", "parse_java_version")
load("//private:proxy.bzl", "get_java_proxy_args")
load(
Expand All @@ -23,7 +23,6 @@ load(
"COURSIER_CLI_GITHUB_ASSET_URL",
"COURSIER_CLI_SHA256",
)
load("//private/rules:jetifier.bzl", "jetify_artifact_dependencies", "jetify_maven_coord")
load("//private/rules:urls.bzl", "remove_auth_from_url")
load("//private/rules:v1_lock_file.bzl", "v1_lock_file")
load("//private/rules:v2_lock_file.bzl", "v2_lock_file")
Expand All @@ -33,7 +32,6 @@ _BUILD = """
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_jvm_external//private/rules:jvm_import.bzl", "jvm_import")
load("@rules_jvm_external//private/rules:jetifier.bzl", "jetify_aar_import", "jetify_jvm_import")
{aar_import_statement}
{imports}
Expand Down Expand Up @@ -893,44 +891,7 @@ def _coursier_fetch_impl(repository_ctx):
repository_ctx.attr.resolve_timeout,
)

# Fetch all possible jetified artifacts. We will wire them up later.
if repository_ctx.attr.jetify:
extra_jetify_artifacts = []
for artifact in dep_tree["dependencies"]:
artifact_coord = parse.parse_maven_coordinate(artifact["coord"])
jetify_coord_tuple = jetify_maven_coord(
artifact_coord["group"],
artifact_coord["artifact"],
artifact_coord["version"],
)
if jetify_coord_tuple:
artifact_coord["group"] = jetify_coord_tuple[0]
artifact_coord["artifact"] = jetify_coord_tuple[1]
artifact_coord["version"] = jetify_coord_tuple[2]
extra_jetify_artifacts.append(artifact_coord)
dep_tree = make_coursier_dep_tree(
repository_ctx,
# Order is important due to version conflict resolution. "pinned" will take the last
# version that is provided so having the explicit artifacts last makes those versions
# stick.
extra_jetify_artifacts + artifacts,
excluded_artifacts,
repositories,
repository_ctx.attr.version_conflict_policy,
repository_ctx.attr.fail_on_missing_checksum,
repository_ctx.attr.fetch_sources,
repository_ctx.attr.fetch_javadoc,
repository_ctx.attr.resolve_timeout,
report_progress_prefix = "Second pass for Jetified Artifacts: ",
)

# Reconstruct the original URLs from the relative path to the artifact,
# which encodes the URL components for the protocol, domain, and path to
# the file.

files_to_inspect = []
jetify_include_dict = {k: None for k in repository_ctx.attr.jetify_include_list}
jetify_all = repository_ctx.attr.jetify and repository_ctx.attr.jetify_include_list == JETIFY_INCLUDE_LIST_JETIFY_ALL

for artifact in dep_tree["dependencies"]:
# Some artifacts don't contain files; they are just parent artifacts
Expand All @@ -940,10 +901,6 @@ def _coursier_fetch_impl(repository_ctx):

coord_split = artifact["coord"].split(":")
coord_unversioned = "{}:{}".format(coord_split[0], coord_split[1])
should_jetify = jetify_all or (repository_ctx.attr.jetify and coord_unversioned in jetify_include_dict)
if should_jetify:
artifact["directDependencies"] = jetify_artifact_dependencies(artifact["directDependencies"])
artifact["dependencies"] = jetify_artifact_dependencies(artifact["dependencies"])

# Normalize paths in place here.
artifact.update({"file": _normalize_to_unix_path(artifact["file"])})
Expand Down Expand Up @@ -1254,8 +1211,6 @@ pinned_coursier_fetch = repository_rule(
default = False,
),
"strict_visibility_value": attr.label_list(default = ["//visibility:private"]),
"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),
"additional_netrc_lines": attr.string_list(doc = "Additional lines prepended to the netrc file used by `http_file` (with `maven_install_json` only).", default = []),
"use_credentials_from_home_netrc_file": attr.bool(default = False, doc = "Whether to include coursier credentials gathered from the user home ~/.netrc file"),
"fail_if_repin_required": attr.bool(doc = "Whether to fail the build if the maven_artifact inputs have changed but the lock file has not been repinned.", default = False),
Expand Down Expand Up @@ -1321,8 +1276,6 @@ coursier_fetch = repository_rule(
),
"strict_visibility_value": attr.label_list(default = ["//visibility:private"]),
"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),
"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"),
"duplicate_version_warning": attr.string(
Expand Down
12 changes: 6 additions & 6 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ load("@rules_jvm_external//:defs.bzl", "maven_install", "artifact")
## javadoc

<pre>
javadoc(<a href="#javadoc-name">name</a>, <a href="#javadoc-additional_dependencies">additional_dependencies</a>, <a href="#javadoc-deps">deps</a>, <a href="#javadoc-excluded_workspaces">excluded_workspaces</a>, <a href="#javadoc-javadocopts">javadocopts</a>)
javadoc(<a href="#javadoc-name">name</a>, <a href="#javadoc-additional_dependencies">additional_dependencies</a>, <a href="#javadoc-deps">deps</a>, <a href="#javadoc-doc_deps">doc_deps</a>, <a href="#javadoc-doc_url">doc_url</a>, <a href="#javadoc-excluded_workspaces">excluded_workspaces</a>, <a href="#javadoc-javadocopts">javadocopts</a>)
</pre>

Generate a javadoc from all the `deps`
Expand All @@ -45,6 +45,8 @@ Generate a javadoc from all the `deps`
| <a id="javadoc-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="javadoc-additional_dependencies"></a>additional_dependencies | Mapping of <code>Label</code>s to the excluded workspace names. Note that this must match the values passed to the <code>pom_file</code> rule so the <code>pom.xml</code> correctly lists these dependencies. | <a href="https://bazel.build/rules/lib/dict">Dictionary: Label -> String</a> | optional | <code>{}</code> |
| <a id="javadoc-deps"></a>deps | The java libraries to generate javadocs for.<br><br> The source jars of each dep will be used to generate the javadocs. Currently docs for transitive dependencies are not generated. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | |
| <a id="javadoc-doc_deps"></a>doc_deps | <code>javadoc</code> targets referenced by the current target.<br><br> Use this to automatically add appropriate <code>-linkoffline</code> javadoc options to resolve references to packages documented by the given javadoc targets that have <code>url</code> specified. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
| <a id="javadoc-doc_url"></a>doc_url | The URL at which this documentation will be hosted.<br><br> This information is only used by javadoc targets depending on this target. | String | optional | <code>""</code> |
| <a id="javadoc-excluded_workspaces"></a>excluded_workspaces | A list of bazel workspace names to exclude from the generated jar | List of strings | optional | <code>["com_google_protobuf"]</code> |
| <a id="javadoc-javadocopts"></a>javadocopts | javadoc options. Note sources and classpath are derived from the deps. Any additional options can be passed here. | List of strings | optional | <code>[]</code> |

Expand Down Expand Up @@ -190,9 +192,9 @@ Generated rules:
maven_install(<a href="#maven_install-name">name</a>, <a href="#maven_install-repositories">repositories</a>, <a href="#maven_install-artifacts">artifacts</a>, <a href="#maven_install-fail_on_missing_checksum">fail_on_missing_checksum</a>, <a href="#maven_install-fetch_sources">fetch_sources</a>, <a href="#maven_install-fetch_javadoc">fetch_javadoc</a>,
<a href="#maven_install-excluded_artifacts">excluded_artifacts</a>, <a href="#maven_install-generate_compat_repositories">generate_compat_repositories</a>, <a href="#maven_install-version_conflict_policy">version_conflict_policy</a>,
<a href="#maven_install-maven_install_json">maven_install_json</a>, <a href="#maven_install-override_targets">override_targets</a>, <a href="#maven_install-strict_visibility">strict_visibility</a>, <a href="#maven_install-strict_visibility_value">strict_visibility_value</a>,
<a href="#maven_install-resolve_timeout">resolve_timeout</a>, <a href="#maven_install-jetify">jetify</a>, <a href="#maven_install-jetify_include_list">jetify_include_list</a>, <a href="#maven_install-additional_netrc_lines">additional_netrc_lines</a>,
<a href="#maven_install-use_credentials_from_home_netrc_file">use_credentials_from_home_netrc_file</a>, <a href="#maven_install-fail_if_repin_required">fail_if_repin_required</a>,
<a href="#maven_install-use_starlark_android_rules">use_starlark_android_rules</a>, <a href="#maven_install-aar_import_bzl_label">aar_import_bzl_label</a>, <a href="#maven_install-duplicate_version_warning">duplicate_version_warning</a>)
<a href="#maven_install-resolve_timeout">resolve_timeout</a>, <a href="#maven_install-additional_netrc_lines">additional_netrc_lines</a>, <a href="#maven_install-use_credentials_from_home_netrc_file">use_credentials_from_home_netrc_file</a>,
<a href="#maven_install-fail_if_repin_required">fail_if_repin_required</a>, <a href="#maven_install-use_starlark_android_rules">use_starlark_android_rules</a>, <a href="#maven_install-aar_import_bzl_label">aar_import_bzl_label</a>,
<a href="#maven_install-duplicate_version_warning">duplicate_version_warning</a>)
</pre>

Resolves and fetches artifacts transitively from Maven repositories.
Expand Down Expand Up @@ -220,8 +222,6 @@ and fetch Maven artifacts transitively.
| <a id="maven_install-strict_visibility"></a>strict_visibility | Controls visibility of transitive dependencies. If <code>True</code>, transitive dependencies are private and invisible to user's rules. If <code>False</code>, transitive dependencies are public and visible to user's rules. | <code>False</code> |
| <a id="maven_install-strict_visibility_value"></a>strict_visibility_value | Allows changing transitive dependencies strict visibility scope from private to specified scopes list. | <code>["//visibility:private"]</code> |
| <a id="maven_install-resolve_timeout"></a>resolve_timeout | The execution timeout of resolving and fetching artifacts. | <code>600</code> |
| <a id="maven_install-jetify"></a>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. | <code>False</code> |
| <a id="maven_install-jetify_include_list"></a>jetify_include_list | List of artifacts that need to be jetified in <code>groupId:artifactId</code> format. By default all artifacts are jetified if <code>jetify</code> is set to True. | <code>["*"]</code> |
| <a id="maven_install-additional_netrc_lines"></a>additional_netrc_lines | Additional lines prepended to the netrc file used by <code>http_file</code> (with <code>maven_install_json</code> only). | <code>[]</code> |
| <a id="maven_install-use_credentials_from_home_netrc_file"></a>use_credentials_from_home_netrc_file | Whether to pass machine login credentials from the ~/.netrc file to coursier. | <code>False</code> |
| <a id="maven_install-fail_if_repin_required"></a>fail_if_repin_required | Whether to fail the build if the required maven artifacts have been changed but not repinned. Requires the <code>maven_install_json</code> to have been set. | <code>False</code> |
Expand Down
2 changes: 1 addition & 1 deletion examples/bzlmod/maven_install.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": 618211806,
"__INPUT_ARTIFACTS_HASH": 618209980,
"__RESOLVED_ARTIFACTS_HASH": 2024597311,
"artifacts": {
"com.beust:jcommander": {
Expand Down
Loading

0 comments on commit 99ca15d

Please sign in to comment.