Skip to content

Instantly share code, notes, and snippets.

@dmytrodanylyk
Last active January 4, 2017 07:14
Show Gist options
  • Save dmytrodanylyk/0294108d0817f46ad207 to your computer and use it in GitHub Desktop.
Save dmytrodanylyk/0294108d0817f46ad207 to your computer and use it in GitHub Desktop.
Android Gradle
apply plugin: 'android-library'
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
// flavornameDebug_1.0_1_24_10_2014.apk
applicationVariants.all { variant ->
def oldFile = variant.outputFile
def newPath = "${variant.name}" + "_" + "${variant.versionName}" + "_" + "${variant.versionCode}" + "_" + getDate() + ".apk";
variant.outputFile = new File(oldFile.parentFile, newPath)
}
def getDate() {
def formatter = new SimpleDateFormat('dd_MM_yyyy');
def date = new Date();
return formatter.format(date);
}
apply plugin: 'android'
android {
compileSdkVersion Integer.parseInt(project.COMPILE_SDK_VERSION)
buildToolsVersion project.BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.TARGET_SDK_VERSION)
}
signingConfigs {
release {
storeFile file(project.STORE_FILE)
storePassword project.STORE_PASSWORD
keyAlias project.KEY_ALIAS
keyPassword project.KEY_PASSWORD
}
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
productFlavors {
Demo {
packageName "com.dd.demo"
defaultConfig {
versionCode 1
versionName "1.0.0"
}
}
Production {
packageName "com.dd.production"
defaultConfig {
versionCode 1
versionName "1.0.1"
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:library1')
compile project(':libraries:library2')
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
BUILD_TOOLS_VERSION=20
COMPILE_SDK_VERSION=19
MIN_SDK_VERSION=10
TARGET_SDK_VERSION=19
STORE_FILE=../keystor.jks
STORE_PASSWORD=1234567
KEY_ALIAS=Test Alias
KEY_PASSWORD=1234567
// build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'com.android.tools.build', name: "gradle", version: getBuildscript().toolsVersion
}
}
// settings.gradle
include ':app', ':some-library'
project(':some-library').projectDir = new File('libraries/some-library')
import org.gradle.api.internal.initialization.DefaultScriptHandler
boolean isIdea13 = System.properties["idea.version"]?.toString()?.equals("13")
DefaultScriptHandler.metaClass.toolsVersion = isIdea13 ? "0.10.+" : "0.12.+"
// Gradle VM Options
-Didea.version=13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment