Hi Daniel,
Apologies for the delay in response, and thank you for getting back to me.
I may not have explained my need clearly or I am not understanding your suggestion.
Currently within gradle we create two NativeLibrarySpecs, one representing a normal binary and another that represents a metrics version (the metrics are induced outside of gradle as part of the compiler). These binaries effectively share all the same configuration and dependencies from a gradle perspective.
At the linking stage we can choose between these two binaries dependent on whether we want metrics or not.
In order to reduce the user workload we have created some helper functions that allow us to choose when to create the special libs and also when configuring dependencies or paths etc.
It looks a little like this;
-- HelperFunctionA (name , addMetricVersion) --
model
{
components
{
name (NativeLibrarySpec)
{
//initial config
}
if (addMetricVersion)
{
name+metric (NativeLibrarySpec)
{
//initial config
}
}
}
}
-- End HelperFunctionA () --
And separately:
-- HelperFunctionB (name, dependencies) --
model
{
components
{
name
{
//updateConfig based on dependencies
}
if ("name+metric" exists) <--- **point of problem**.
{
name+metric
{
//updateConfig based on dependencies
}
}
}
}
-- End HelperFunctionB () --
In our build.gradle files we will do something equavalent to;
HelperFunctionA (libA, true)
HelperFunctionB (libA, SomeDependencyX)
HelperFunctionB (libA, SomeDependencyY)
HelperFunctionB (libA, SomeDependencyZ)
HelperFunctionA (libB, false)
model
{
components
{
normalExecutable (NativeExecutableSpec)
{
// set a dependency on libA
// set a dependency on libB
}
metricExecutable (NativeExecutableSpec)
{
// set a dependency on libA+metric
// set a dependency on libB
}
}
}
So the issue I was trying to solve was how to check if a BinaryComponentSpec item existed within the components closure, allowing the user to call one function that optionally updated a binary if it existed. Having tried things like model.components.contains() etc I can only find decorated named items and nothing that links back to “liba-metric” for example.
We had considered flavors previously, however as you state, you cannot mix and match and that is exactly what we are trying to do.
Any help appreciated.
Thanks,
Shaun