def isWindowsBuild() {
// TODO The implementation of this function uses an internal Gradle feature
// this may become deprecated.
// This was the only clean solution that seems to consistently work
// for now.
return OperatingSystem.current().isWindows()
} // end of isWindowsBuild
This function is then called in each project that is only built on windows.
if (isWindowsBuild()) {
// Put your project build code here
apply plugin: ...
dependencies {
...
}
model {
...
}
}
The same function is added to the settings.gradle file, which now looks like
// needed for isWindowsBuild implementation
import org.gradle.internal.os.OperatingSystem
/**
* Check if the build is executed on Windows
*/
def isWindowsBuild() {
// TODO The implementation of this function uses an internal Gradle feature
// this may become deprecated.
// This was the only clean solution that seems to consistenly work
// for now.
return OperatingSystem.current().isWindows()
} // end of isWindowsBuild
def projects = [
<cross_platform_project_0>,
<cross_platform_project_1>,
]
if (isWindowsBuild()) {
projects.add(<windows_only_project_0>)
}
include projects as String[]
Having to use an internal function for this purpose is bad !!!
However no other function gave consistent results in both build.gradle and settings.gradle.
I think it should be possible to mark a project to be built only on specific platforms - the whole project, not just parts of the code or a build configuration.