Comments (9)
#97 is in. With v2.0.1, you can mark the javapoet as neverlink
, which should prevent the min-sdk issue. However, the issue with Epoxy's annotation processor not running still stands.
from rules_jvm_external.
Have you tried adding generates_api = 1
to the java_plugin
target?
Nevermind, just tried it, it doesn't work.
from rules_jvm_external.
I got slightly further by adding com.airbnb:epoxy-processor:3.3.1
to maven_install
and @maven//:com_airbnb_epoxy_processor
to the deps of the java_plugin
target. The BUILD file looks like this:
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library")
java_plugin(
name = "epoxy_plugin",
processor_class = "com.airbnb.epoxy.EpoxyProcessor",
generates_api = 1,
deps = [
"@maven//:com_airbnb_android_epoxy_processor",
],
)
java_library(
name = "epoxy_lib",
exported_plugins = ["epoxy_plugin"],
exports = [
"@maven//:com_airbnb_android_epoxy",
"@maven//:com_airbnb_android_epoxy_processor",
"@maven//:com_airbnb_android_epoxy_annotations",
]
)
android_library(
name = "resources",
manifest = "AndroidManifest.xml",
custom_package = "com.matthewcheok.bazeltest",
resource_files = glob(
["res/**"],
exclude=["res/.DS_Store"]
),
deps = [
"@maven//:androidx_appcompat_appcompat",
"@maven//:androidx_constraintlayout_constraintlayout",
],
)
kt_android_library(
name = "lib",
srcs = glob(["java/**/*.kt"]),
custom_package = "com.matthewcheok.bazeltest",
plugins = [":epoxy_plugin"],
deps = [
":resources",
":epoxy_lib",
"@maven//:androidx_constraintlayout_constraintlayout",
"@maven//:androidx_annotation_annotation",
"@maven//:androidx_appcompat_appcompat",
"@maven//:androidx_core_core",
"@maven//:androidx_core_core_ktx",
"@maven//:androidx_drawerlayout_drawerlayout",
"@maven//:androidx_lifecycle_lifecycle_common",
"@maven//:androidx_lifecycle_lifecycle_viewmodel",
"@maven//:androidx_fragment_fragment",
"@maven//:androidx_recyclerview_recyclerview",
],
visibility = ["//visibility:public"],
)
I'm now running into an SDK error with javapoet:
ERROR: /private/var/tmp/_bazel_jin/54321455f30132f9d0deb1ed5ef71a3e/external/maven/BUILD:798:1: Dexing external/maven/_dx/com_squareup_javapoet_1_11_1/javapoet-1.11.1.jar_desugared.jar with applicable dexopts [] failed (Exit 1)
java.util.concurrent.ExecutionException: com.android.dx.cf.code.SimException: ERROR in com.squareup.javapoet.CodeBlock.joining:(Ljava/lang/String;)Ljava/util/stream/Collector;: invoking a static interface method java.util.stream.Collector.of:(Ljava/util/function/Supplier;Ljava/util/function/BiConsumer;Ljava/util/function/BinaryOperator;Ljava/util/function/Function;[Ljava/util/stream/Collector$Characteristics;)Ljava/util/stream/Collector; strictly requires --min-sdk-version >= 24 (blocked at current API level 13)
at java.base/java.util.concurrent.FutureTask.report(Unknown Source)
at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
at com.google.devtools.build.android.dexer.DexBuilder.produceDexArchive(DexBuilder.java:253)
at com.google.devtools.build.android.dexer.DexBuilder.processRequest(DexBuilder.java:218)
at com.google.devtools.build.android.dexer.DexBuilder.runPersistentWorker(DexBuilder.java:173)
at com.google.devtools.build.android.dexer.DexBuilder.main(DexBuilder.java:121)
Caused by: com.android.dx.cf.code.SimException: ERROR in com.squareup.javapoet.CodeBlock.joining:(Ljava/lang/String;)Ljava/util/stream/Collector;: invoking a static interface method java.util.stream.Collector.of:(Ljava/util/function/Supplier;Ljava/util/function/BiConsumer;Ljava/util/function/BinaryOperator;Ljava/util/function/Function;[Ljava/util/stream/Collector$Characteristics;)Ljava/util/stream/Collector; strictly requires --min-sdk-version >= 24 (blocked at current API level 13)
at com.android.dx.cf.code.Simulator.fail(Simulator.java:947)
at com.android.dx.cf.code.Simulator.checkInvokeInterfaceSupported(Simulator.java:917)
at com.android.dx.cf.code.Simulator.access$500(Simulator.java:43)
at com.android.dx.cf.code.Simulator$SimVisitor.visitConstant(Simulator.java:687)
at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:764)
at com.android.dx.cf.code.Simulator.simulate(Simulator.java:117)
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:789)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:744)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:349)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:309)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:150)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:102)
at com.google.devtools.build.android.dexer.Dexing.addToDexFile(Dexing.java:198)
at com.google.devtools.build.android.dexer.DexConverter.toDexFile(DexConverter.java:31)
at com.google.devtools.build.android.dexer.DexConversionEnqueuer$ClassToDex.call(DexConversionEnqueuer.java:173)
at com.google.devtools.build.android.dexer.DexConversionEnqueuer$ClassToDex.call(DexConversionEnqueuer.java:156)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Target //:bazel_test failed to build
from rules_jvm_external.
It looks like we need to specify a min SDK version. But I'm not sure where we might do that.
from rules_jvm_external.
Usually dex options go into android_binary's dexopts
attribute. However, this seems like a bug because javapoet isn't supposed to go into the APK, let alone getting dexed and desugared. JakeWharton/butterknife#1234 (comment)
I think we'll need a way to specify neverlink
on specific dependencies in the tree to avoid bringing artifacts like javapoet into the runtime classpath.
from rules_jvm_external.
Just an update: the dexopt issue will be fixed by #97 by marking the javapoet artifact as neverlink = True
. I was able to reproduce the epoxy failures, but I believe this is due to an issue in the kt_android_library rule. I tried to use the Room annotation processor as well, and it worked on a regular android_library with Java sources, but not kt_android_library.
from rules_jvm_external.
I don't have bandwidth to work on this at the moment, may pick it up when the new Kotlin rules are released.
from rules_jvm_external.
Any update? I have same issue that bazel + Kotlin + epoxy not working
from rules_jvm_external.
We have been able to build our application with Bazel + Kotlin + epoxy using the following configuration:
WORKSPACE:
primary maven_install:
"com.airbnb.android:epoxy:3.9.0",
"com.airbnb.android:epoxy-processor:3.9.0",
"com.airbnb.android:epoxy-annotations:3.9.0",
"com.squareup.kotlinpoet.1.5.0",
"com.squareup.javapoet.1.13.0",
secondary maven_install:
maven_install(
name = "jetify",
artifacts = [
"com.google.android.material:material:1.1.0",
...
],
jetify = True,
excluded_artifacts = [
"com.android.support:*",
],
repositories = [
...
],
)
BUILD:
java_library(
name = "epoxy_compiler",
exported_plugins = [
":epoxy_plugin",
],
visibility = [
"//visibility:public",
],
)
java_plugin(
name = "epoxy_plugin",
generates_api = 1,
processor_class = "com.airbnb.epoxy.EpoxyProcessor",
deps = [
"@maven//:com_airbnb_android_epoxy",
"@maven//:com_airbnb_android_epoxy_processor",
"@maven//:com_airbnb_android_epoxy_annotations",
],
)
kt_android_library (
...
deps = [
...
":epoxy_compiler",
"@maven//:com_airbnb_android_epoxy",
"@maven//:com_airbnb_android_epoxy_processor",
"@maven//:com_squareup_javapoet",
"@maven//:com_squareup_kotlinpoet",
"@jetify//:com_google_android_material_material",
]
)
We shouldn't need that visibility reference. As you can see, we also do not seem to need to include neverlink for javapoet and kotlinpoet. We also needed to exclude the Google material library from our primary install and utilize a jetified version.
Good luck, hope this helps!
from rules_jvm_external.
Related Issues (20)
- java_export generated pom.xml does not include <classifier> property
- FR: Ability to customize the location of RJE_UNSAFE_CACHE
- FR: Info about the BOM providing the version in the pinned lock file
- FR: Warnings about deviations from the BOM HOT 2
- FR: A way to exclude deps from artifacts that are determining the versions from BOMs HOT 6
- Maven resolver creates diffs in the lock files even when nothing was changed HOT 3
- Stop including extra artifacts on maven.install() HOT 3
- bzlmod doesnot support "Exporting and consuming artifacts from external repositories" HOT 1
- coursier uses two different concepts of $HOME, then crashes by failing to relativize paths HOT 1
- Can not build small library after upgrade rules to 6.1 HOT 3
- In BzlMod, overrides are not repo-specific HOT 5
- Exported target pom does not include exclusions
- In bzlmod, composing modules is difficult HOT 3
- Support token-based auth in maven_export/MavenPublisher
- rules_jvm_external v6.1 creates duplicate jvm_import targets for binary and source JARs HOT 5
- Support in memory PGP signing HOT 1
- bzlmod: when root module overrides a namespace but doesn't change artifacts, do not emit a warning HOT 1
- Expose `PackageInfo` from imported packages
- Bzlmod: maven.artifact repositories argument is ignored HOT 1
- Bzlmod: maven.install repositories has silent last-wins semantics
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_jvm_external.