您的位置:首页 > 产品设计 > UI/UE

打jar包的脚本存放在build.gradle

2015-12-01 14:50 337 查看
apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion android_build_tools

defaultConfig {
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
}

lintOptions {
abortOnError false
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

tasks.whenTaskAdded { task ->
if (task.name == "compileDebugJavaWithJavac") {
task << {
def file1 = new File('build/intermediates/classes/debug/cn/richinfo/plugin/stub/AbstractServiceStub.class');
def file2 = new File('build/intermediates/classes/debug/cn/richinfo/plugin/stub/AbstractServiceStub$1.class');
if (file1 != null && file1.exists()) {
file1.delete()
file2.delete()
}
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided fileTree(dir: 'lib', include: '*.jar')
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${android_support_lib_version}"
}

task toAssets {
doLast {
copy {
delete 'richplugin.jar'
from('build/intermediates/bundles/debug/')
into('.')
include('classes.jar')
rename('classes.jar', 'richplugin.jar')
}

exec {
commandLine "/Users/blue/Library/Android/sdk/build-tools/23.0.2/dx", '--dex', '--output=richplugin_dex.jar', 'richplugin.jar'
}

copy {
delete '../example/src/main/assets/richplugin_dex.jar'
from('.')
into('../example/src/main/assets')
include('richplugin_dex.jar')
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: