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

Remove generate proto task link to compile on #586

Closed
wants to merge 2 commits into from

Conversation

rougsig
Copy link
Collaborator

@rougsig rougsig commented Jul 17, 2022

Java/kotlin: compile task implicit depends on generate proto task via source sets
Android: compile tasks depends on generate proto task via registerJavaGeneratingTask

Now:
Java/kotlin: compile task implicit depends on generate proto task via source sets
Android: compile tasks depends on generate proto task via registerJavaGeneratingTask
@rougsig rougsig force-pushed the remove-compile-depends-on branch from ca818fd to f4f6689 Compare July 17, 2022 21:48
@rougsig rougsig force-pushed the remove-compile-depends-on branch 2 times, most recently from 1a668b2 to e24e2f2 Compare July 17, 2022 22:27
@@ -258,11 +256,6 @@ public abstract class GenerateProtoTask extends DefaultTask {
this.outputBaseDir = outputBaseDir
}

@OutputDirectory
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you remove this, then you need to add in OutputFiles for the descriptor and for .zip outputs. The way I did that before:

  • For DescriptorSetOptions, make path an @Input and make a new method that returns the non-null output file name. That new method gets @OutputFile.
  • I made PluginOptions non-static which requires passing a factory method to domainObjectContainer for builtins and plugins. Then I made two @Optional methods in PluginOptions, one that was OutputFile and one that was `OutputDirectory. This approach takes some refactoring, but overall seemed cleaner
    • The quicker approach is to add a new method getOutputSourceFiles() that has @OutputFiles and returns the files filtered during getOutputSourceDirectories()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What problem are we trying to solve with this logic? Looks too complicated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

All the outputs need to be tracked. If you remove the output base dir as an output, then you must track all the individual files/directories. But getOutputSourceDirectories() doesn't return any of the files. Thus you need some other mechanism to expose the output files. There's multiple ways to do that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Plugins/Buildins generate files in subfolders. Descriptor is tracked by getDescriptorSetOptionsForCaching. Does anything write files directly to outputBaseDir?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Plugins/Buildins generate files in subfolders

Often. But protoc can also generate a zip or jar file directly. Those outputs are filtered out from getOutputSourceDirectories().

Descriptor is tracked by getDescriptorSetOptionsForCaching

Not entirely. DescriptorSetOptions.path is an @OutputFile, but it is only used if the user overrides the path. If the user uses the default path then that path would be untracked.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see comments in the code

protoc is capable of output generated files directly to a JAR file or ZIP archive if the output location ends with .jar/.zip

However, I do not see any documentation of this feature in the protobuf-gradle-plugin. I also do not see any tests for this feature.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not entirely. DescriptorSetOptions.path is an @OutputFile, but it is only used if the user overrides the path. If the user uses the default path then that path would be untracked.

Sounds like a bug, doesn't it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not see any documentation of this feature in the protobuf-gradle-plugin

All the background I see: #480 and #533 .

Sounds like a bug, doesn't it?

Not on master. If there is an output descriptor, then it is either a child of the base directory or it is the user-configured name. This PR removes the base directory as an output so that introduces a bug.

@rougsig rougsig closed this Jul 23, 2022
@rougsig rougsig deleted the remove-compile-depends-on branch September 29, 2022 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants