Reputation: 3945
I'm using Android Studio and building Android library project, so I distribute aar
file. And to be more specific I just distribute the jar inside (yes- customers still using Eclipse so I combine manually the jar
with manifest, res etc well known procedure).
This is my Gradle build script (regular default...):
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0"
lintOptions {
abortOnError false
}
defaultConfig {
// Ain't applicationIdNot
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/../lib'
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile '...'
}
The problem is that: Under one java package alongside regular java classes I have ttf
font files. This is due to historical reasons and now the project complexity not allowing to make changes and move them to where they actually need to be.
Well - The jar missing these files. How to implement the build process such the jar
inside the arr
will include these files - Because after all - It's regular archive and those file are in the file tree already compressed into the jar
.
Thanks,
Upvotes: 2
Views: 1128
Reputation: 11403
Just specify to include the files in your sourceSets
closure
// if you want to include the files in your aar
android {
...
sourceSets {
main {
resources.includes = [ '**/mySweetFont.ttf' ]
}
}
}
// to include in your jar
sourceSets {
main {
resources.includes = [ '**/mySweetFont.ttf' ]
}
}
This will place the files at the root of the artifact produced. For the jar
you may need to specify the sourceSets
closure twice once inside android
closure and again after the android
closure
Upvotes: 1