Search code examples
androidc++android-studioandroid-ndkgradle-experimental

gradle experimental ndk build only subset of directory


I am using gradle2.9 with the gradle-experimental-0.6.0-alpha3 plugin for android studio and I have a problem I cannot seem to solve.

This is my directory structure:

  • TopDir
    • fileA.cpp
    • dirA
      • fileA1.cpp
      • fileA2.cpp

I want to compile fileA.cpp, fileA1.cpp but not fileA2.cpp

1°) I tried using selective dir includes:

android.sources {
    main {
        jni {
            source {
               srcDirs = ["dirA","dirA1/fileA1.cpp"]
            }
        }
    }
}

but I got the error that dirA1/fileA1.cpp is not a directory, and I can't find a way to include a file.

2°) I tried using selective dir excludes:

android.sources {
    main {
        jni {
            source {
               srcDirs = ["TopDir"]
               exclude "fileA2.cpp"
            }
        }
    }
}

but that didn't work either, because exclude waits for a directory. Even using wildcards (like "exclude *A2*") doesn't seems to work.

Does anyone knows a way to do this (even if it requires including file one by one) using the new gradle experimental tools?


Solution

  • For exclude, you can use wildcards, e.g

    exclude "**/*A2.cpp"