Skip to content

Commit

Permalink
Better build.gradle configuration
Browse files Browse the repository at this point in the history
Based on Roman Nurik's own Gradle configurations. Now supports better
versioning (as metadata in the version.properties files) and better
release signing configuration (in the keystore.properties file).

Also fixed gradlew permissions (was missing the executable flag)
  • Loading branch information
rock3r committed Mar 30, 2014
1 parent f6d5f55 commit e0994ff
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 87 deletions.
36 changes: 34 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/
out/
build/
.gradle/

# Project files
*.iml
.gradle
.idea
# .idea/workspace.xml

# Local configuration file (sdk path, etc)
local.properties
/local.properties
keystore.properties

# Configuration files
Config.java

# Windows thumbnail db
.DS_Store

# Idea non-crucial project fileS
*.iws

# Sandbox stuff
_sandbox
42 changes: 38 additions & 4 deletions GlowPadBackport-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,58 @@ apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
buildToolsVersion "19.0.3"

def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(file('version.properties')))

defaultConfig {
minSdkVersion 4
targetSdkVersion 19
versionCode 2
versionName "2.0"

versionName versionProps['name']
versionCode versionProps['code'].toInteger()
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

signingConfigs {
release {
def Properties localProps = new Properties()
localProps.load(new FileInputStream(file('../local.properties')))
def Properties keyProps = new Properties()
assert localProps['keystore.props.file'];
keyProps.load(new FileInputStream(file(localProps['keystore.props.file'])))
storeFile file(keyProps["store"])
keyAlias keyProps["alias"]
storePassword keyProps["storePass"]
keyPassword keyProps["pass"]
}
}

buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.txt')
signingConfig signingConfigs.release
}

publicBeta.initWith(buildTypes.release)
publicBeta {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.txt')
versionNameSuffix " " + versionProps['betaNumber']
}

publicDebug.initWith(buildTypes.publicBeta)
publicDebug {
debuggable true
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.txt')
versionNameSuffix " Debug " + versionProps['betaNumber']
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions GlowPadBackport-sample/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

code = 2000
name = 2.0

# Latest beta number for this version. Only applies to beta builds.
betaNumber = Beta 1
77 changes: 0 additions & 77 deletions GlowPadBackport/GlowPadBackport.iml

This file was deleted.

42 changes: 38 additions & 4 deletions GlowPadBackport/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,58 @@ apply plugin: 'android-library'

android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
buildToolsVersion "19.0.3"

def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(file('version.properties')))

defaultConfig {
minSdkVersion 4
targetSdkVersion 19
versionCode 2
versionName "2.0"

versionName versionProps['name']
versionCode versionProps['code'].toInteger()
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

signingConfigs {
release {
def Properties localProps = new Properties()
localProps.load(new FileInputStream(file('../local.properties')))
def Properties keyProps = new Properties()
assert localProps['keystore.props.file'];
keyProps.load(new FileInputStream(file(localProps['keystore.props.file'])))
storeFile file(keyProps["store"])
keyAlias keyProps["alias"]
storePassword keyProps["storePass"]
keyPassword keyProps["pass"]
}
}

buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.txt')
signingConfig signingConfigs.release
}

publicBeta.initWith(buildTypes.release)
publicBeta {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.txt')
versionNameSuffix " " + versionProps['betaNumber']
}

publicDebug.initWith(buildTypes.publicBeta)
publicDebug {
debuggable true
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.txt')
versionNameSuffix " Debug " + versionProps['betaNumber']
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions GlowPadBackport/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright 2014 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

code = 2000
name = 2.0

# Latest beta number for this version. Only applies to beta builds.
betaNumber = Beta 1
Empty file modified gradlew
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions keystore.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This is an example keystore.properties file.
store=mykeystore.keystore
alias=keyname
pass=keyPassword
storePass=keystorePassword
12 changes: 12 additions & 0 deletions local.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sun Feb 16 13:39:45 GMT 2014
sdk.dir=/your/path/to/android-sdk
keystore.props.file=../keystore.properties

0 comments on commit e0994ff

Please sign in to comment.