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

Adds warning when one defines a protoLibrary without source sets #2595

Merged
merged 1 commit into from
Aug 30, 2023

Conversation

oldergod
Copy link
Member

If we don't find a resources sets to add a dependency to, the :jar task or whatever it is will not emit the .proto files automatically.

Copy link
Collaborator

@martinbonnin martinbonnin left a comment

Choose a reason for hiding this comment

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

A few comments but LGTM overall 👍

if (sourceSets.isNotEmpty()) {
// TODO(Benoit) Probably should be checking for other names than `main`. As well, source
// sets might be created 'afterEvaluate'. Does that mean we should do this work in
// `afterEvaluate` as well? See: https://kotlinlang.org/docs/multiplatform-dsl-reference.html#source-sets
Copy link
Collaborator

Choose a reason for hiding this comment

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

afterEvaluate {} should be avoided overall. If for any reason "main" is created at a later point, you can use .all {}:

sourceSets.all {
  if (name == "main") {
    // do stuff
  }
}

But given this has been like this for a long time, I would say "main" is created when the plugin is applied so it's probably fine.

// TODO(Benoit) Probably should be checking for other names than `main`. As well, source
// sets might be created 'afterEvaluate'. Does that mean we should do this work in
// `afterEvaluate` as well? See: https://kotlinlang.org/docs/multiplatform-dsl-reference.html#source-sets
if (sourceSets.isNotEmpty() && sourceSets.findByName("main") != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need to check isNotEmpty() here?

sourceSets.getByName("main") { main: SourceSet ->
main.resources.srcDir(protoOutputDirectory)
}
} else {
project.logger.warn("${project.displayName} doesn't have a 'main' source sets. The .proto files will not automatically be added to the artifact. You have to manually add them.")
Copy link
Collaborator

@martinbonnin martinbonnin Aug 29, 2023

Choose a reason for hiding this comment

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

No need to tell users to add manually if the plugin is not going to be able to consume them afterwards?

Suggested change
project.logger.warn("${project.displayName} doesn't have a 'main' source sets. The .proto files will not automatically be added to the artifact. You have to manually add them.")
project.logger.warn("${project.displayName} doesn't have a 'main' source sets. The .proto files will not automatically be added to the artifact.")

@oldergod oldergod force-pushed the bquenaudon.2023-08-29.warning branch from abed2d7 to 527f584 Compare August 30, 2023 13:17
@oldergod oldergod merged commit c56b618 into master Aug 30, 2023
13 of 14 checks passed
@oldergod oldergod deleted the bquenaudon.2023-08-29.warning branch August 30, 2023 14:16
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