android eclipse gradle project,Gradle 配置Eclipse中的add project方式

Project 目录的build.gradle内容:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {

jcenter()

}

dependencies {

classpath 'com.android.tools.build:gradle:2.1.0'

// NOTE: Do not place your application dependencies here; they belong

// in the individual module build.gradle files

}

}

allprojects {

repositories {

jcenter()

}

//把相应的module下面的class文件打包成jar包

task buildPluginLib (type: Jar, dependsOn:'compileDebugJavaWithJavac') {

from (project.buildDir.toString()+'/intermediates/classes/debug')

}

}

task clean(type: Delete) {

delete rootProject.buildDir

}

主工程里面的Gradle

apply plugin: 'com.android.application'

//apply plugin: 'android-library'

buildscript {

repositories {

jcenter()

}

// dependencies {

// classpath 'com.android.tools.build:gradle:1.3.0'

// }

}

dependencies {

compile fileTree(dir: 'libs', include: '*.jar')

//compile 'com.android.support:multidex:1.0.0'

}

/*afterEvaluate {

tasks.matching {

it.name.startsWith('dex')

}.each { dx ->

if (dx.additionalParameters == null) {

dx.additionalParameters = ['--multi-dex']

} else {

dx.additionalParameters += '--multi-dex'

}

// optional

// dx.additionalParameters += "--main-dex-list=$projectDir/".toString() // enable the main-dex-list

}

}*/

android {

dexOptions {

jumboMode true

//preDexLibraries = false

//javaMaxHeapSize "2g"

}

signingConfigs {

config {

keyAlias 'smarthome'

keyPassword 'xxxx'

storeFile file('E:/StudioWork/MyApplication4/SmartHome2.0/key/smarthome.keystore')

storePassword 'xxxxx'

}

}

defaultConfig {

applicationId "com.suning.smarthome"

minSdkVersion 14

targetSdkVersion 19

versionCode 218

versionName "2.1.8"

// dex突破65535的限制

//multiDexEnabled true

// AndroidManifest.xml 里面UMENG_CHANNEL的value为 ${APP_CHANNEL_VALUE}

// manifestPlaceholders = [APP_CHANNEL_VALUE: "channel_name"]

}

compileSdkVersion 19

buildToolsVersion "23.0.2"

/*defaultConfig {

// Enabling multidex support.

multiDexEnabled true

}*/

sourceSets {

main {

manifest.srcFile 'AndroidManifest.xml'

java.srcDirs = ['src']

resources.srcDirs = ['src']

aidl.srcDirs = ['src']

renderscript.srcDirs = ['src']

res.srcDirs = ['res']

assets.srcDirs = ['assets']

jniLibs.srcDirs = ['libs']

}

// Move the tests to tests/java, tests/res, etc...

instrumentTest.setRoot('tests')

// Move the build types to build-types/

// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...

// This moves them out of them default location under src//... which would

// conflict with src/ being used by the main source set.

// Adding new build types or product flavors should be accompanied

// by a similar customization.

debug.setRoot('build-types/debug')

release.setRoot('build-types/release')

}

buildTypes {

debug {

signingConfig signingConfigs.config

debuggable true

}

release {

// 移除无用的resource文件

// shrinkResources true

debuggable true

signingConfig signingConfigs.config

debuggable false

proguardFile 'E:/StudioWork/MyApplication4/SmartHome2.0/proguard.cfg'

minifyEnabled true

zipAlignEnabled true

}

}

/*

android:name="SUNING_CHANNEL"

android:value="${SUNING_CHANNEL_VALUE}" />*/

/*productFlavors {

wandoujia {}

baidu {}

c360 {}

uc {}

productFlavors.all { flavor ->

flavor.manifestPlaceholders = [SUNING_CHANNEL_VALUE: name]

}

}*/

}

插件工程,依赖主工程的配置方式:

apply plugin: 'com.android.application'

//apply plugin: 'android-library'

buildscript {

repositories {

jcenter()

}

// dependencies {

// classpath 'com.android.tools.build:gradle:1.3.0'

// }

}

dependencies {

compile fileTree(dir: 'libs', include: '*.jar')

//compile project(':SmartHome2.0')

//provided project(':SmartHome2.0')

provided files('../../SmartHome2.0/build/libs/SmartHome2.0.jar')

provided fileTree(include: ['*.jar'], dir: '../../SmartHome2.0/libs')

}

android {

compileSdkVersion 19

buildToolsVersion "23.0.2"

sourceSets {

main {

manifest.srcFile 'AndroidManifest.xml'

java.srcDirs = ['src']

resources.srcDirs = ['src']

aidl.srcDirs = ['src']

renderscript.srcDirs = ['src']

res.srcDirs = ['res']

assets.srcDirs = ['assets']

jniLibs.srcDirs = ['libs']

}

// Move the tests to tests/java, tests/res, etc...

instrumentTest.setRoot('tests')

// Move the build types to build-types/

// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...

// This moves them out of them default location under src//... which would

// conflict with src/ being used by the main source set.

// Adding new build types or product flavors should be accompanied

// by a similar customization.

debug.setRoot('build-types/debug')

release.setRoot('build-types/release')

}

}

task beforeBuild(dependsOn: [':SmartHome2.0:buildPluginLib']) << {

println 'do it before build'

}

preBuild.dependsOn beforeBuild

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值