Skip to content

Commit

Permalink
Merge pull request #84 from menny/allow-test-only-deps
Browse files Browse the repository at this point in the history
Allow test only deps
  • Loading branch information
menny committed May 29, 2021
2 parents b85633f + 24ea15a commit f05a194
Show file tree
Hide file tree
Showing 28 changed files with 552 additions and 187 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This WORKSPACE will provide `mabel_rule` rule and `artifact` macro which will au
* Transitively resolves all dependencies from a given list of Maven dependencies, and manages version conflicts - ensuring that only one version of each artifact is available in the dependencies graph.
* Generates repository-rules for all remote artifacts.
* Generates required Java rule (with transitive dependencies).
* Allows to mark dependencies as `test_only`.
* Automatically detects which rule-type to create for a given dependency:
* `aar_import` for Android artifacts.
* `java_plugin` + `java_library` for annotation-processors. More about this [here](#annotation-processors).
Expand Down Expand Up @@ -165,6 +166,7 @@ Attributes:

* `coordinate`: Maven coordinate in the form of `group-id:artifact-id:version`.
* `type`: What is the type of target(s) to create for this artifact. Default `auto`. Can be `jar`, `aar`, `kotlin`, `kotlin_aar`, `naive`, `processor`, `auto`. For more details, see [here](resolver/src/main/java/net/evendanan/bazel/mvn/api/model/TargetType.java).
* `test_only`: Mark this dependency to be used in tests only.
* `maven_exclude_deps`: List of Maven dependencies which should not be resolved. You can omit the `version` or both `artifact-id:version`.
* `repositories`: List of URLs that point to Maven servers. The default list includes Maven-Central.

Expand Down
4 changes: 2 additions & 2 deletions examples/android/program/aar_import_replacement.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ load("@build_bazel_rules_android//android:rules.bzl", "aar_import")
# you can use this pattern to provide a different implementation of aar_import
# that does extra work (like jetifying).
# make sure you are using the exposing the same arguments as aar_import!
def macro_instead_of_aar_import(name, aar, deps, exports, tags):
aar_import(name = name, aar = aar, deps = deps, exports = exports, tags = tags)
def macro_instead_of_aar_import(name, aar, deps, exports, tags, testonly):
aar_import(name = name, aar = aar, deps = deps, exports = exports, tags = tags, testonly = testonly)
31 changes: 31 additions & 0 deletions examples/android/program/main_deps/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_activity__activity__1_0_0_alpha02",
aar = "@androidx_activity__activity__1_0_0_alpha02//file",
testonly = False,
tags = ["maven_coordinates=androidx.activity:activity:1.0.0-alpha02"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -417,6 +418,7 @@ def generate_transitive_dependency_targets(
java_import(
name = "androidx_annotation__annotation__1_0_0",
jars = ["@androidx_annotation__annotation__1_0_0//file"],
testonly = False,
tags = [
"mabel_license_detected_type=Apache",
"mabel_license_name=The Apache Software License, Version 2.0",
Expand All @@ -442,6 +444,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_appcompat__appcompat__1_0_2",
aar = "@androidx_appcompat__appcompat__1_0_2//file",
testonly = False,
tags = ["maven_coordinates=androidx.appcompat:appcompat:1.0.2"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -484,6 +487,7 @@ def generate_transitive_dependency_targets(
java_import(
name = "androidx_arch_core__core_common__2_0_0",
jars = ["@androidx_arch_core__core_common__2_0_0//file"],
testonly = False,
tags = [
"mabel_license_detected_type=Apache",
"mabel_license_name=The Apache Software License, Version 2.0",
Expand Down Expand Up @@ -511,6 +515,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_arch_core__core_runtime__2_0_0",
aar = "@androidx_arch_core__core_runtime__2_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.arch.core:core-runtime:2.0.0"],
deps = [
":androidx_annotation__annotation",
Expand All @@ -535,6 +540,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_asynclayoutinflater__asynclayoutinflater__1_0_0",
aar = "@androidx_asynclayoutinflater__asynclayoutinflater__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.asynclayoutinflater:asynclayoutinflater:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -563,6 +569,7 @@ def generate_transitive_dependency_targets(
java_import(
name = "androidx_collection__collection__1_0_0",
jars = ["@androidx_collection__collection__1_0_0//file"],
testonly = False,
tags = [
"mabel_license_detected_type=Apache",
"mabel_license_name=The Apache Software License, Version 2.0",
Expand All @@ -588,6 +595,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_coordinatorlayout__coordinatorlayout__1_0_0",
aar = "@androidx_coordinatorlayout__coordinatorlayout__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.coordinatorlayout:coordinatorlayout:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -640,6 +648,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_core__core__1_1_0_alpha01",
aar = "@androidx_core__core__1_1_0_alpha01//file",
testonly = False,
tags = ["maven_coordinates=androidx.core:core:1.1.0-alpha01"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -670,6 +679,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_cursoradapter__cursoradapter__1_0_0",
aar = "@androidx_cursoradapter__cursoradapter__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.cursoradapter:cursoradapter:1.0.0"],
deps = [":androidx_annotation__annotation"],
exports = [":androidx_annotation__annotation"],
Expand All @@ -696,6 +706,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_customview__customview__1_0_0",
aar = "@androidx_customview__customview__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.customview:customview:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand All @@ -720,6 +731,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_documentfile__documentfile__1_0_0",
aar = "@androidx_documentfile__documentfile__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.documentfile:documentfile:1.0.0"],
deps = [":androidx_annotation__annotation"],
exports = [":androidx_annotation__annotation"],
Expand All @@ -738,6 +750,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_drawerlayout__drawerlayout__1_0_0",
aar = "@androidx_drawerlayout__drawerlayout__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.drawerlayout:drawerlayout:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -766,6 +779,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_fragment__fragment__1_1_0_alpha02",
aar = "@androidx_fragment__fragment__1_1_0_alpha02//file",
testonly = False,
tags = ["maven_coordinates=androidx.fragment:fragment:1.1.0-alpha02"],
deps = [
":androidx_activity__activity",
Expand Down Expand Up @@ -800,6 +814,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_interpolator__interpolator__1_0_0",
aar = "@androidx_interpolator__interpolator__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.interpolator:interpolator:1.0.0"],
deps = [":androidx_annotation__annotation"],
exports = [":androidx_annotation__annotation"],
Expand All @@ -818,6 +833,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_legacy__legacy_support_core_ui__1_0_0",
aar = "@androidx_legacy__legacy_support_core_ui__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.legacy:legacy-support-core-ui:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -864,6 +880,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_legacy__legacy_support_core_utils__1_0_0",
aar = "@androidx_legacy__legacy_support_core_utils__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.legacy:legacy-support-core-utils:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -898,6 +915,7 @@ def generate_transitive_dependency_targets(
java_import(
name = "androidx_lifecycle__lifecycle_common__2_0_0",
jars = ["@androidx_lifecycle__lifecycle_common__2_0_0//file"],
testonly = False,
tags = [
"mabel_license_detected_type=Apache",
"mabel_license_name=The Apache Software License, Version 2.0",
Expand All @@ -923,6 +941,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_lifecycle__lifecycle_livedata_core__2_0_0",
aar = "@androidx_lifecycle__lifecycle_livedata_core__2_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.lifecycle:lifecycle-livedata-core:2.0.0"],
deps = [
":androidx_arch_core__core_common",
Expand All @@ -949,6 +968,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_lifecycle__lifecycle_livedata__2_0_0",
aar = "@androidx_lifecycle__lifecycle_livedata__2_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.lifecycle:lifecycle-livedata:2.0.0"],
deps = [
":androidx_arch_core__core_common",
Expand Down Expand Up @@ -977,6 +997,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_lifecycle__lifecycle_runtime__2_0_0",
aar = "@androidx_lifecycle__lifecycle_runtime__2_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.lifecycle:lifecycle-runtime:2.0.0"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -1007,6 +1028,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_lifecycle__lifecycle_viewmodel__2_0_0",
aar = "@androidx_lifecycle__lifecycle_viewmodel__2_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.lifecycle:lifecycle-viewmodel:2.0.0"],
deps = [":androidx_annotation__annotation"],
exports = [":androidx_annotation__annotation"],
Expand All @@ -1027,6 +1049,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_loader__loader__1_0_0",
aar = "@androidx_loader__loader__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.loader:loader:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand Down Expand Up @@ -1055,6 +1078,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_localbroadcastmanager__localbroadcastmanager__1_0_0",
aar = "@androidx_localbroadcastmanager__localbroadcastmanager__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.localbroadcastmanager:localbroadcastmanager:1.0.0"],
deps = [":androidx_annotation__annotation"],
exports = [":androidx_annotation__annotation"],
Expand All @@ -1073,6 +1097,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_print__print__1_0_0",
aar = "@androidx_print__print__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.print:print:1.0.0"],
deps = [":androidx_annotation__annotation"],
exports = [":androidx_annotation__annotation"],
Expand All @@ -1091,6 +1116,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_slidingpanelayout__slidingpanelayout__1_0_0",
aar = "@androidx_slidingpanelayout__slidingpanelayout__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.slidingpanelayout:slidingpanelayout:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand All @@ -1117,6 +1143,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_swiperefreshlayout__swiperefreshlayout__1_0_0",
aar = "@androidx_swiperefreshlayout__swiperefreshlayout__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand All @@ -1143,6 +1170,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_vectordrawable__vectordrawable_animated__1_0_0",
aar = "@androidx_vectordrawable__vectordrawable_animated__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.vectordrawable:vectordrawable-animated:1.0.0"],
deps = [
":androidx_legacy__legacy_support_core_ui",
Expand All @@ -1169,6 +1197,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_vectordrawable__vectordrawable__1_0_1",
aar = "@androidx_vectordrawable__vectordrawable__1_0_1//file",
testonly = False,
tags = ["maven_coordinates=androidx.vectordrawable:vectordrawable:1.0.1"],
deps = [
":androidx_annotation__annotation",
Expand All @@ -1193,6 +1222,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_versionedparcelable__versionedparcelable__1_1_0_alpha01",
aar = "@androidx_versionedparcelable__versionedparcelable__1_1_0_alpha01//file",
testonly = False,
tags = ["maven_coordinates=androidx.versionedparcelable:versionedparcelable:1.1.0-alpha01"],
deps = [
":androidx_annotation__annotation",
Expand All @@ -1219,6 +1249,7 @@ def generate_transitive_dependency_targets(
aar_import(
name = "androidx_viewpager__viewpager__1_0_0",
aar = "@androidx_viewpager__viewpager__1_0_0//file",
testonly = False,
tags = ["maven_coordinates=androidx.viewpager:viewpager:1.0.0"],
deps = [
":androidx_annotation__annotation",
Expand Down
Loading

0 comments on commit f05a194

Please sign in to comment.