Remove native build tasks

Hey,

in my project I want to remove the generated native build tasks but I can’t seem to get anywhere.

To explain what I’m doing, this is my build file, its a subproject of a larger set of projects: https://github.com/jMonkeyEngine/jmonkeyengine/blob/ec183e1eeaa44706ba8c6c78eebb23a7d7c7a139/jme3-bullet-native/build.gradle

It uses the java and cpp plugins and I want to enable only the shared library builds as well as selectively be able to skip single native builds when a property is set in the gradle.properties file.

The way I solved it atm is that I use gradle.startParameter.excludedTaskNames and add the names of the generated platform tasks (e.g. windows_x86BulletjmeStaticLibrary etc.). The problem with that is when I build another subproject it complains that “Task ‘windows_x86BulletjmeStaticLibrary’ not found in project ‘:jme3-android’.”. When I build the main project the result is exactly what I want though.

I already tried to use tasks.remove(taskname) in various combinations (in a task to be run at config time, in the root of the build file etc.) but because the task is being generated by the cpp plugin it cannot be found for removal.

Any ideas on what I could do here? I also generally didn’t find a way to completely disable the build of static libraries with the native compilation, the use of gradle.startParameter.excludedTaskNames seemed to be the only way for that as well but also leads to the aforementioned issues.

Thanks for any help, Normen

What you can do is set the unwanted binaries to not be buildable. For instance:

binaries.withType(StaticLibraryBinarySpec) {
    buildable = false
}

setBuildable is an internal interface right now, but in the future, it will go away and there will be some sort of public interface for a binary that allows you to disable building it (e.g. something like “enabled = false”).

Ah, thanks, going that route works, I can disable all static libs with that and when I don’t want the shared libs to be built according to the gradle.properties setting I simply set this to false for the shared libs too.

For reference, this is my build file after the changes.

https://github.com/jMonkeyEngine/jmonkeyengine/blob/98f0d2c08ac7994a856b03a4a01e108ff3a17510/jme3-bullet-native/build.gradle

Thanks again, Normen