Let's say in a build.gradle file I want to do something like:
ext.sharepointBuildDir = project(":MainProject:sharepoint").buildDir.path
But in certain configurations that project may not exist.
How can I check "does a gradle project exist"?
You can use a findProject
method, which is according to it's description
Locates a project by path. If the path is relative, it is interpreted relative to this project.
Returns: The project with the given path. Returns null if no such project exists.
So, you can simply use it as follows:
if (findProject(':MainProject:sharepoint') != null) {
println 'project exists'
} else {
println 'project does not exist'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With