Skip to content

Instantly share code, notes, and snippets.

@gipi
Last active December 20, 2015 19:19
Show Gist options
  • Save gipi/6182731 to your computer and use it in GitHub Desktop.
Save gipi/6182731 to your computer and use it in GitHub Desktop.
#gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile project(':actionbarsherlock')
compile project(':viewpagerindicator')
compile project(':facebook')
compile project(':dragdrop')
compile fileTree('libs')
compile 'com.android.support:support-v4:13.0.+'
}
android {
signingConfigs {
release {
keyAlias = "miao"
}
}
// BuildConfig.DEBUG is not reliable, we define our own variable
buildTypes {
debug {
buildConfig "public final static boolean TEST = true;"
}
release {
buildConfig "public final static boolean TEST = false;"
signingConfig signingConfigs.release
}
}
if (project.hasProperty('storeFile') &&
project.hasProperty('storePassword') &&
project.hasProperty('keyPassword')) {
android.signingConfigs.release.storeFile = file(storeFile)
android.signingConfigs.release.storePassword = storePassword
android.signingConfigs.release.keyPassword = keyPassword
} else {
buildTypes.release.signingConfig = null
}
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
}
buildscript {
repositories {
mavenCentral()
}
}
apply plugin: 'java'
sourceSets {
main {
java {
srcDir 'src'
}
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
def gitSha(File rootDir) {
def res = 'git describe --tags --always --dirty'.execute([], rootDir).text.trim()
return res
}
// http://groovy.codehaus.org/Process+Management
// http://groovy.codehaus.org/Executing+External+Processes+From+Groovy
def gitRef(File rootDir) {
def remotes = 'git remote -v'.execute([], rootDir)
def cutOnlyRepository = ['awk', '{print $2}'].execute()
def firstLine = 'head -n 1'.execute()
remotes | cutOnlyRepository | firstLine
firstLine.waitFor()
return firstLine.text.trim()
}
allprojects {
task repoDependencies << {task ->
print "$task.project.name\t$task.project.projectDir\t"
print "${gitRef(task.project.projectDir)}\t"
println "${gitSha(task.project.projectDir)}"
}
}
allprojects {
task hello << {task -> println "I'm $task.project.name in $task.project.projectDir" }
}
def gitSha() {
def res = 'git describe --tags --always --dirty'.execute([], project.rootDir).text.trim()
def diff = 'git diff'.execute([], project.rootDir).text.trim()
if (diff != null && diff.length() > 0) {
res += "-dirty"
}
return res
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 18
versionName "${gitSha()}"
}
}
include ':Miao'
include 'actionbarsherlock', 'viewpagerindicator', 'facebook', 'dragdrop'
project(':actionbarsherlock').projectDir = new File(settingsDir, '../JakeWharton-ActionBarSherlock-071a61c/actionbarsherlock/')
project(':viewpagerindicator').projectDir = new File(settingsDir, '../JakeWharton-Android-ViewPagerIndicator-8cd549f/library/')
project(':facebook').projectDir = new File(settingsDir, '../facebook-android-sdk-3.0.1/facebook/')
project(':dragdrop').projectDir = new File(settingsDir, '../DragNDropList/')
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
// this creates a maven repository in the /tmp directory
apply plugin: 'maven'
uploadArchives {
repositories.mavenDeployer {
repository(url: "file:///tmp/")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment