Skip to content

Commit

Permalink
add gradle build support
Browse files Browse the repository at this point in the history
  • Loading branch information
振理 committed Aug 8, 2014
1 parent 481b6e6 commit 06ba4f5
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ proguard/
*.ipr
*.iws
.idea/

.gradle/
build/
.DS_Store
33 changes: 33 additions & 0 deletions ResideMenu/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apply plugin: 'android-library'

repositories {
mavenCentral()
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
useOldManifestMerger true
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
43 changes: 43 additions & 0 deletions ResideMenuDemo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apply plugin: 'android'

configurations {
provided
compile.exclude module: 'support-v4' //避免preDex时候有多个项目的support-v4.jar依赖进来
}

sourceSets {
main {
compileClasspath += configurations.provided
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':ResideMenu')
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
useOldManifestMerger true

dexOptions {
jumboMode = true
}

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
aidl.srcDirs = ['src']
jniLibs.srcDirs = ['libs']
}
}
}
36 changes: 36 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
println "-------------------------------------------------"
println "Build ResideMenu with:\n\tbuildToolsVersion = " + System.properties['buildToolsVersion']
println "\tandroidGradlePluginVersion = " + System.properties['androidGradlePluginVersion']
println "\tfile.encoding = " + System.properties['file.encoding']
println "\tCharset.defaultCharset() = " + java.nio.charset.Charset.defaultCharset().toString()
println "-------------------------------------------------\n"


//配置extra属性之后,后面的子project需要用到这些属性的地方都直接调用rootProject.ext.XXX,避免修改的时候需要每个project里面都需要去检查、修改

ext {
compileSdkVersion = 19
buildToolsVersion = System.properties['buildToolsVersion']
minSdkVersion = 9
targetSdkVersion = 14
}


//每个project构建过程中,都需要依赖gradle构建工具,所以在rootProject里面写一次就好了。
buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:' + System.properties['androidGradlePluginVersion']
}
}

allprojects {

//指定编码类型
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
}
11 changes: 11 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include ':ResideMenu', ':ResideMenuDemo'

//override your build tools version in gradle.properties

if (!System.properties['buildToolsVersion']) {
System.properties['buildToolsVersion'] = "19.1.0"
}

if (!System.properties['androidGradlePluginVersion']) {
System.properties['androidGradlePluginVersion'] = "0.12.+"
}

0 comments on commit 06ba4f5

Please sign in to comment.