-
Notifications
You must be signed in to change notification settings - Fork 574
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.") |
There was a problem hiding this comment.
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?
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.") |
abed2d7
to
527f584
Compare
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.