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
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,15 @@ class WirePlugin : Plugin<Project> {
if (extension.protoLibrary) {
val sourceSets = project.extensions.getByType(SourceSetContainer::class.java)
// Note that there are no source sets for some platforms such as native.
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.

if (sourceSets.findByName("main") != null) {
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.")
}
}

Expand Down
Loading