Last active
November 27, 2023 13:40
-
-
Save MarkMjw/7998381 to your computer and use it in GitHub Desktop.
Revisions
-
xiangmao revised this gist
Mar 3, 2014 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' } } @@ -15,7 +15,7 @@ dependencies { android { compileSdkVersion 19 buildToolsVersion "19.0.2" compileOptions.encoding = "UTF-8" signingConfigs { @@ -43,11 +43,11 @@ android { productFlavors { google { packageName = 'com.markmao.demo.play' } samsung { packageName = 'com.markmao.demo.samsung' } } -
xiangmao revised this gist
Jan 10, 2014 . 1 changed file with 14 additions and 64 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,28 +39,17 @@ android { signingConfig signingConfigs.myConfig } } productFlavors { google { packageName = 'com.sina.book.play' } samsung { packageName = 'com.sina.book.samsung' } } sourceSets { main { @@ -88,38 +77,14 @@ android { } //================================================================ // replace meta-data in AndroidManifest.xml // the regex like this: // <meta-data android:name="CHANNEL" android:value="*" /> //================================================================ android.applicationVariants.all { variant -> // rename out apk file renameApk(variant) // modify AndroidManifest.xml variant.processManifest.doLast { copy { @@ -128,14 +93,13 @@ android.applicationVariants.all { variant -> } into("${buildDir}/manifests/$variant.name") def channelName = variant.productFlavors[0].name; println "[Channel]: ${channelName}" filter { String line -> line.replaceAll("<meta-data android:name=\"CHANNEL\" android:value=\".*\"/>", "<meta-data android:name=\"CHANNEL\" android:value=\"${channelName}\"/>") } // set the path to the modified Manifest: @@ -165,29 +129,15 @@ def renameApk(variant) { // println "[App_Name]: ${appName}" // println "[App_Version]: ${versionName}" def channelName = variant.productFlavors[0].name; if (variant.zipAlign) { def oldFile = variant.outputFile; def newFile = appName + "-v" + versionName + "-" + channelName + ".apk" variant.outputFile = new File(oldFile.parent, newFile) } // def oldFile = variant.packageApplication.outputFile; // def newFile = appName + "-v" + versionName +"-" + versionNameSuffix + "-unaligned.apk" // variant.packageApplication.outputFile = new File(oldFile.parent, newFile) } -
MarkMjw revised this gist
Dec 26, 2013 . 1 changed file with 1 addition and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -190,26 +190,4 @@ def readBuildTypes(variant) { println "[Key]: ${key}" println "[Value]: ${value}" } } -
MarkMjw revised this gist
Dec 26, 2013 . 1 changed file with 74 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.7.+' } } @@ -12,19 +12,15 @@ apply plugin: 'android' dependencies { compile fileTree(dir: 'libs', include: '*.jar') } android { compileSdkVersion 19 buildToolsVersion "19.0.1" compileOptions.encoding = "UTF-8" signingConfigs { myConfig{ storeFile file("debug.keystore") storePassword "123456" keyAlias "debug" keyPassword "123456" @@ -36,30 +32,33 @@ android { signingConfig signingConfigs.myConfig runProguard true zipAlign true proguardFile getDefaultProguardFile('proguard-android.txt') } debug { signingConfig signingConfigs.myConfig } samsung { initWith release versionNameSuffix ".1.0" packageNameSuffix ".samsung" } google { initWith release versionNameSuffix ".1.0" packageNameSuffix ".play" } } // different package name // productFlavors { // google { // packageName = 'com.sina.book.play' // } // samsung { // packageName = 'com.sina.book.samsung' // } // } @@ -102,6 +101,7 @@ android.applicationVariants.all { variant -> // read property from file def variantProperties = new Properties() propertyList.reverse().each { property -> // channel.properties def by user def propFile = "channel.properties" try { file(propFile).withReader { reader -> @@ -113,7 +113,7 @@ android.applicationVariants.all { variant -> println "[${variant.name}] Failed to load ${propFile}" } } // println "[${variant.name}] manifest properties: ${variantProperties}" // default channel value is SinaDown def defaultValue = "16" def channel = variant.buildType.name @@ -147,21 +147,69 @@ android.applicationVariants.all { variant -> def renameApk(variant) { // get data for apk renaming def appName def versionName // local.properties def by user def propsFile = rootProject.file('local.properties') if (propsFile.exists()) { def props = new Properties() props.load(new FileInputStream(propsFile)) appName = props['app_name'] android.defaultConfig.versionName = props['app_version'] versionName = android.defaultConfig.versionName } else { appName = "TestGradle" versionName = "1.0" } // println "[App_Name]: ${appName}" // println "[App_Version]: ${versionName}" def buildTypeName = variant.buildType.name if (variant.zipAlign) { def oldFile = variant.outputFile; def newFile = appName + "-v" + versionName + "-" + buildTypeName + ".apk" variant.outputFile = new File(oldFile.parent, newFile) } // def oldFile = variant.packageApplication.outputFile; // def newFile = appName + "-v" + versionName +"-" + versionNameSuffix + "-unaligned.apk" // variant.packageApplication.outputFile = new File(oldFile.parent, newFile) } def readBuildTypes(variant) { def channelsProps = new Properties() // channel.properties def by user def channelsFile = rootProject.file('channel.properties') if (channelsFile.exists()) { channelsProps.load(new FileInputStream(channelsFile)) } channelsProps.each { key, value -> println "[Key]: ${key}" println "[Value]: ${value}" } } //allprojects { // afterEvaluate { project -> // // channel.properties def by user // def propsFile = rootProject.file('local.properties') // def configName = 'release' // // if (propsFile.exists() && android.signingConfigs.hasProperty(configName)) { // def props = new Properties() // props.load(new FileInputStream(propsFile)) // android.signingConfigs[configName].storeFile = file(props['key.store']) // android.signingConfigs[configName].storePassword = props['key.store.password'] // android.signingConfigs[configName].keyAlias = props['key.alias'] // android.signingConfigs[configName].keyPassword = props['key.alias.password'] // // println "[storeFile]: ${android.signingConfigs[configName].storeFile}" // println "[storePassword]: ${android.signingConfigs[configName].storePassword}" // println "[keyAlias]: ${android.signingConfigs[configName].keyAlias}" // println "[keyPassword]: ${android.signingConfigs[configName].keyPassword}" // } // } //} -
MarkMjw revised this gist
Dec 17, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ android { compileOptions.encoding = "UTF-8" defaultConfig { versionName "1.0.0" } signingConfigs { @@ -39,7 +39,7 @@ android { proguardFiles files('proguard.cfg', getDefaultProguardFile('proguard-android.txt')) } samsung { initWith release versionNameSuffix "samsung" // packageNameSuffix ".samsung" -
MarkMjw revised this gist
Dec 17, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ android { } signingConfigs { myConfig{ storeFile file("debug.store") storePassword "123456" keyAlias "debug" @@ -33,7 +33,7 @@ android { buildTypes{ release { signingConfig signingConfigs.myConfig runProguard true zipAlign true proguardFiles files('proguard.cfg', getDefaultProguardFile('proguard-android.txt')) -
MarkMjw created this gist
Dec 17, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,167 @@ buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.6.+' } } apply plugin: 'android' dependencies { compile fileTree(dir: 'libs', include: '*.jar') } android { compileSdkVersion 15 buildToolsVersion "18.1.1" compileOptions.encoding = "UTF-8" defaultConfig { versionName "1.7.5" } signingConfigs { sinaAndroid{ storeFile file("debug.store") storePassword "123456" keyAlias "debug" keyPassword "123456" } } buildTypes{ release { signingConfig signingConfigs.sinaAndroid runProguard true zipAlign true proguardFiles files('proguard.cfg', getDefaultProguardFile('proguard-android.txt')) } samsung { initWith release versionNameSuffix "samsung" // packageNameSuffix ".samsung" } google { initWith release versionNameSuffix "google" // packageNameSuffix ".google" } } // different package name // productFlavors { // google { // packageName = 'com.xxx.xxx.play' // } // samsung { // packageName = 'com.xxx.xxx.samsung' // } // } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } // Move the tests to tests/java, tests/res, etc... instrumentTest.setRoot('tests') // Move the build types to build-types/<type> // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... // This moves them out of them default location under src/<type>/... 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') } } //================================================================ // Modify AndroidManifest.xml // <meta-data android:name="CHANNEL" android:value="*" /> //================================================================ android.applicationVariants.all { variant -> // rename out apk file renameApk(variant) def propertyList = variant.productFlavors*.name propertyList.add(variant.buildType.name) // read property from file def variantProperties = new Properties() propertyList.reverse().each { property -> def propFile = "channel.properties" try { file(propFile).withReader { reader -> def tmpProps = new Properties() tmpProps.load(reader) variantProperties.putAll(tmpProps) } } catch(e) { println "[${variant.name}] Failed to load ${propFile}" } } println "[${variant.name}] manifest properties: ${variantProperties}" // default channel value is SinaDown def defaultValue = "16" def channel = variant.buildType.name def value = variantProperties.getProperty("${channel}", defaultValue) println "[Channel]: ${channel} [Value]: ${value}" // modify AndroidManifest.xml variant.processManifest.doLast { copy { from("${buildDir}/manifests") { include "${variant.dirName}/AndroidManifest.xml" } into("${buildDir}/manifests/$variant.name") // get the channel value def channelValue = variantProperties.getProperty("${channel}", defaultValue) println "[Channel]: ${channel} [Value]: ${channelValue}" filter { String line -> line.replaceAll("<meta-data android:name=\"CHANNEL\" android:value=\".*\"/>", "<meta-data android:name=\"CHANNEL\" android:value=\"${channelValue}\"/>") } // set the path to the modified Manifest: def manifestPath = "${buildDir}/manifests/${variant.name}/${variant.dirName}/AndroidManifest.xml" variant.processResources.manifestFile = file(manifestPath) } } } def renameApk(variant) { // get data for apk renaming def appName = "TestGradle" def versionName = android.defaultConfig.versionName def versionNameSuffix = variant.buildType.versionNameSuffix if (versionNameSuffix.toString().equals("null")) { def buildTypeName = variant.buildType.name versionNameSuffix = buildTypeName.toLowerCase() } if (variant.zipAlign) { def oldFile = variant.outputFile; def newFile = appName + "-v" + versionName + "-" + versionNameSuffix + ".apk" variant.outputFile = new File(oldFile.parent, newFile) } // def oldFile = variant.packageApplication.outputFile; // def newFile = appName + "-v" + versionName +"-" + versionNameSuffix + "-unaligned.apk" // variant.packageApplication.outputFile = new File(oldFile.parent, newFile) }