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

Replace transitive_*_jars in java_common.create_provider with deps #3769

Closed
iirina opened this issue Sep 20, 2017 · 18 comments
Closed

Replace transitive_*_jars in java_common.create_provider with deps #3769

iirina opened this issue Sep 20, 2017 · 18 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) type: feature request

Comments

@iirina
Copy link
Contributor

iirina commented Sep 20, 2017

The current transitive_*_jars arguments in java_common.create_provider are hard to understand and present some shortcomings. For example, you cannot create a provider with transitive source jars or other transitive information that JavaInfo encapsulates (and might not even be exposed).

The current (old) API:

java_common.create_provider(
  actions,
  use_ijar = ...,
  compile_jars = [...],
  runtime_jars = [...],
  source_jars = [...],
  transitive_compile_time_jars = [...], 
  transitive_runtime_jars = [...],
  java_toolchain = ....
)

should be replaced by this:

java_common.create_provider(
  actions,
  use_ijar = ...,
  compile_jars = [...],
  runtime_jars = [...],
  source_jars = [...],
  deps = [...], # this should be a list/set of JavaInfo, to encapsulate the transitive information
  java_toolchain = ....
)
@iirina iirina added category: rules > java P2 We'll consider working on this in future. (Assignee optional) type: feature request labels Sep 20, 2017
@iirina iirina self-assigned this Sep 20, 2017
@iirina
Copy link
Contributor Author

iirina commented Sep 20, 2017

cc: @ittaiz

@ittaiz
Copy link
Member

ittaiz commented Sep 20, 2017 via email

@ittaiz
Copy link
Member

ittaiz commented Oct 15, 2017

Friendly ping

@ittaiz
Copy link
Member

ittaiz commented Oct 29, 2017

@iirina Stumbled on to a problem and I'm not sure if it should be a new issue or an expansion of this one.
The use_ijar=True in java_common.create_provider is currently unusable if one needs exports.
Tried a few alternatives and all of them failed:

  1. compile_time_jars = outputs.full_jars, #error since provider doesn't propagate exports
  2. compile_time_jars = outputs.full_jars + exports_jars.compile_jars.to_list(), #error since provider ijars existing ijars (e.g.g foo-ijar-ijar.jar)
  3. compile_time_jars = outputs.full_jars + exports_jars.full_compile_jars.to_list(),# If passing full compile jars of the exports it fails since we generate outputs for a different target
    #Output artifact 'external/com_twitter__scalding_date/jar/scalding-date_2.11-0.17.0-ijar.jar' not under package directory 'test' for target '//test:jar_export'.
    #ERROR: Analysis of target '//test:jar_export' failed; build aborted: Analysis of target '//test:jar_export' failed; build aborted.

The reason I think this is related to this issue is because I think the real problem is the level of abstraction the current provider allows. Ideally I think it should support the API you mentioned above but also include runtime_deps, exports and neverlink.

WDYT?

You can see my attempt of using this feature in the following rules_scala branch

@iirina
Copy link
Contributor Author

iirina commented Dec 12, 2017

@dbabkin is currently implementing this.

@ittaiz
Copy link
Member

ittaiz commented Dec 12, 2017 via email

@ittaiz
Copy link
Member

ittaiz commented Dec 24, 2017

Hi,
Any idea if this will hit the 0.10.0 release?

@dbabkin
Copy link
Contributor

dbabkin commented Jan 9, 2018

Hi,
Bazel contributor here :) Terribly sorry for delay in reply.

This task is in the progress right now.
First, very limited part of new API is about to be finished. Commit will be pushed today or tomorrow.
I'm not sure about release 0.10.0. Please follow the status of release 0.10 cut on this ticket:
#3958

New API supports creating JavaInfo with JavaCompilationArgsProvider only.
The next sub-task in scope of this story is to implement the list of all others providers.

@ittaiz
Copy link
Member

ittaiz commented Jan 9, 2018 via email

@iirina
Copy link
Contributor Author

iirina commented Jan 10, 2018

No, it's not. It's just an implementation detail, meaning more work will be needed to make the new API 100% reliable.

I cannot tell right now if this will make the release, since it seems difficult to even cut an RC right now.

@dbabkin
Copy link
Contributor

dbabkin commented Jan 10, 2018

Hi Ittai,

We do not expose JavaCompilationArgsProvider itself.
If you take a look at JavaInfo class [1], it has 4 methods based on JavaCompilationArgsProvider
getCompileTimeJars()
getFullCompileTimeJars()
getTransitiveDeps()
getTransitiveRuntimeDeps()
This methods are exported already. And during creating JavaInfo using new API, JavaCompilationArgsProvider is populated now. So you can use this four methods now.

To create JavaInfo, you need to use constructor [2]. Please refer our tests for example [3]

javaInfo = JavaInfo(
    output_jar = ctx.file.output_jar,
    use_ijar = False,
    runtime_deps = dp
)
javaInfo.transitive_runtime_deps

Others methods from JavaInfo returns empty result now. To fix that I need to implement other providers. This is my priority at the moment.

[1] https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java;l=335

[2] https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java;l=113

[3] https://source.bazel.build/bazel/+/master:src/test/java/com/google/devtools/build/lib/rules/java/JavaSkylarkApiTest.java;l=1593

@dbabkin
Copy link
Contributor

dbabkin commented Jan 17, 2018

Hi,
Small update from my side:
JavaSourceJarsProvider had been created inside JavaInfo
source_jars - added to JavaSourceJarsProvider
sources - ignored at the moment.

@dbabkin
Copy link
Contributor

dbabkin commented Jan 30, 2018

Hi,
Update from my side:
Recently added JavaRuleOutputJarsProvider, JavaExportsProvider , JavaSourceJarsProvider.
Added support for 'exports' parameter.
I think we are pretty finish with functionality except minor things:

  1. Input parameter 'sources' is ignored at the moment. ETA ~ few weeks
  2. merge function for JavaInfo doesn't merge all providers. ETA ~1-2 days

@johnynek
Copy link
Member

johnynek commented Feb 4, 2018

@dbabkin Thanks a lot! It sounds like there are a lot more moving pieces now. Will the documentation be updated when this ships?

@dbabkin
Copy link
Contributor

dbabkin commented Feb 12, 2018

Hi Oscar,

Yes I will add documentation to bazel.build web site after I finish implementation.

@dbabkin
Copy link
Contributor

dbabkin commented Mar 7, 2018

changes pushed.

@dbabkin dbabkin closed this as completed Mar 7, 2018
@ittaiz
Copy link
Member

ittaiz commented Mar 8, 2018

Thanks!
Any chance for a link to the commit?

@dbabkin
Copy link
Contributor

dbabkin commented Mar 8, 2018

bb64d2f

cf79305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) type: feature request
Projects
None yet
Development

No branches or pull requests

4 participants