I would like to change the type of compile dependency based on the property passed during build.
dependencies {
createServiceDependency()
}
def createServiceDependency(){
if ( inputProperty.equals("true") )
{
project.dependencies.add("compile","module:component:$version")
}
else
{
project.dependencies.add("compile","project(:component)")
}
}
Based on the input property passed ( inputProperty ) , I want to decide whether it should be simple dependency or a compile project dependency . The if loop works. But the else fails. How can we dynamically add a compile project dependency ?
Also another question : not related to this issue - If the input property is not passed , then the build throws error . Is there any graceful way of handling the case when input is not passed and I don’t get a property not found error.