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

Set the compile jar to be the same as the output jar #479

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kotlin/internal/jvm/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def kt_jvm_produce_jar_actions(ctx, rule_kind):

java_info = JavaInfo(
output_jar = output_jar,
compile_jar = compile_jar,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to make the compile jar the same as the output jar which will break the whole header / ABI jars for compile avoidance optimization.

Are you expecting any auxiliary files to be included in the compile jars? Note that the final binary (e.g: {java,android}_binary) will link in the output jar for each target, not the compile jar. That is intended only for compilation and why we do this optimization.

A test case showing what is broken would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm expecting auxiliary files in the output_jar to be available for use by follow-on targets.

A specific example is doing a wire_proto compile which generates the jar containing the generated .class files as well as the .proto files.

A follow-on target uses takes as input this jar and requires both the .proto and .class files as input.

Without this PR, the .proto files get removed when the ijar / hjar file is generated prior to compiling the follow-on target.

An alternate solution would be to include the srcjar as an input to the follow-on target, but the output jar is really the proper generated target.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to force the output.jar to be used as a dep in a follow-on target build?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is wire_proto a Skylark rule?

I'm guessing that wire_proto invokes some tool to compile its local proto source into either Kotlin/Java source code or direct to JVM bytecode?

If the compiler needs access to transitive proto source, i.e: local proto source references protos in other libraries then you can make these protos available via a provider e.g: WireProtoInfo that your rule can then collect transitive instances of.

compile_jar = output_jar,
source_jar = source_jar,
jdeps = ctx.outputs.jdeps,
deps = compile_deps.deps,
Expand All @@ -633,7 +633,7 @@ def kt_jvm_produce_jar_actions(ctx, rule_kind):
jdeps = ctx.outputs.jdeps,
jars = [struct(
class_jar = output_jar,
ijar = compile_jar,
ijar = output_jar,
source_jars = [source_jar],
)],
),
Expand Down