Default properties of compile and link task should be defined on configuration
- Dominant language
- No language data
- Stars
- 94
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Given the following configuration script:
```
tasks.withType(CppCompile) {
if (toolChain instanceof Gcc) {
compilerArgs.add('--some-flag')
}
}
```
When the configuration closure runs, the `toolChain` property is `null` (no set). Because the binaries are created later in the process, the above closure is run before the creation configuration gets applied.
It is possible to workaround this issue using the provider API which may be the right solution in this case. However, the obvious solution will not work because of the ordering of the configuration.
### Expected Behaviours
We shouldn't expect the user to have deep knowledge of the inner working of the native plugin to get this configuration right. We can explicitly deny this syntax or provide an error message. The best solution would be one that allows the user to instinctively come up with the right solution the first time.
Contributor guide
Research direction
Start with the shown tasks.withType(CppCompile) configuration and trace when toolChain becomes available during native task setup. Done means the configuration behaves intuitively or provides an explicit error explaining the supported approach for compile and link task properties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100