Skip to content

Aspects do not work when using implicit output targets  #11545

@jagobagascon

Description

@jagobagascon

Description of the problem:

I don't know if this a problem with the android rules, with bazel or maybe I'm just not understanding something about how do aspects or implicit output targets work.

I'm trying to use aspects on a rule that depends on an android_library implicit output target: name.aar. This is the only way I know to generate an aar file but my aspect is not getting called.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

I tried using the example aspect from the documentation and it is behaving the same as mine: it never gets called. Having the following code

android_library(
    name = 'lib_name',
    srcs = glob(['*.java']),
    manifest = 'AndroidManifest.xml',
)

file_count_rule(
    name = 'count',
    deps = [':lib_name']
) # =>  WORKS FINE

file_count_rule(
    name = 'count_aar',
    deps = [':lib_name.aar']
) # => FAILS 

If I run bazel build //:count I get the number of files. But when I call bazel build //:count_aar I get the following error:
<output file target lib_name.aar> doesn't contain declared provider 'FileCountInfo'

I don't really understand what implicit output targets are, or how are they treated. Is this an expected behaviour?

What operating system are you running Bazel on?

Ubuntu 16.04 and Debian GNU/Linux 10 (buster)

What's the output of bazel info release?

release 3.2.0

Have you found anything relevant by searching the web?

nope

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-Configurabilityplatforms, toolchains, cquery, select(), config transitions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions