gradle ignore all but one folder

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

gradle ignore all but one folder

Phil Dougherty
In my build.gradle, I have the following snippet:
  
sourceSets {
    main {
      manifest.srcFile 'AndroidManifest.xml'
      assets.srcDirs 'C:\\Users\\phildo\\Desktop\\projects\\gnometower\\build\\resources'
    }
  }

With this snippet, in order to access `C:\Users\phildo\Desktop\projects\gnometower\build\resources\my_asset.png`, I reference `"my_asset.png"` (via AAssetManager). This works fine.

However, in the PC version of my codebase, all my asset filepaths would access the above via `"resources\my_asset.png"`. So, in order to keep it consistent, I could simply remove the `resources` appendation from the assets.srcDirs gradle build snippet. The issue there is that the `build` folder contains a bunch of other noise I would not want to include in my APK.

So: how can I include the resources folder, while keeping the root as the folder ABOVE that, and without including anything else?

I assume there is something like

      assets.srcDirs 'C:\\Users\\phildo\\Desktop\\projects\\gnometower\\build'
      assets.ignore '*'
      assets.add 'resources'

or something?

though I can't find the syntax for any such thing.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/e9baa16f-71ed-40bf-83d2-425c1da1cef7n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: gradle ignore all but one folder

Alex Cohn
You can do that, but not in the sourceSets section. In your build.gradle, you can have 

android {
  packagingOptions {
    exclude 'assets/unused1'
    exclude 'assets/unused2'
  }
}

Unfortunately, with PackagingOptions you cannot exclude everything, and on top of that add only resources. But if you can find a pattern, e.g. assets/unused*, then it will probably help to make your script shorter.

BR,
Alex Cohn
On Saturday, September 12, 2020 at 1:22:54 AM UTC+3 [hidden email] wrote:
In my build.gradle, I have the following snippet:
  
sourceSets {
    main {
      manifest.srcFile 'AndroidManifest.xml'
      assets.srcDirs 'C:\\Users\\phildo\\Desktop\\projects\\gnometower\\build\\resources'
    }
  }

With this snippet, in order to access `C:\Users\phildo\Desktop\projects\gnometower\build\resources\my_asset.png`, I reference `"my_asset.png"` (via AAssetManager). This works fine.

However, in the PC version of my codebase, all my asset filepaths would access the above via `"resources\my_asset.png"`. So, in order to keep it consistent, I could simply remove the `resources` appendation from the assets.srcDirs gradle build snippet. The issue there is that the `build` folder contains a bunch of other noise I would not want to include in my APK.

So: how can I include the resources folder, while keeping the root as the folder ABOVE that, and without including anything else?

I assume there is something like

      assets.srcDirs 'C:\\Users\\phildo\\Desktop\\projects\\gnometower\\build'
      assets.ignore '*'
      assets.add 'resources'

or something?

though I can't find the syntax for any such thing.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/5d91cebb-1fe4-4ea4-bd3b-6156a76edf87n%40googlegroups.com.