How to determine if project.version is set?

I’d like to know if there is a better way to determine if a project has a version specified. I’m currently using the following, but it seems kind of gross:

allprojects { proj ->
    if("$proj.version" != "unspecified") {
        ...
    }
}

Thanks, Chris

You can simplify the syntax a bit:

allprojects {
  if (version != "unspecified") { ... }
}

Note that, depending on where you put this check, it may come too early.

Ok, I was hoping there was a better way then comparing to the fixed string “unspecified”, just because it feels fragile.

In this case I am accessing the version in a closure I’ve added to Gradle.projectsEvaluated(), so I hope it won’t happen too early. So far things are working.

Thanks Peter.