Changes between Version 12 and Version 13 of gradle
- Timestamp:
- 10/16/2014 05:56:46 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
gradle
v12 v13 131 131 } 132 132 133 134 133 instrumentTest.setRoot('tests') 135 134 … … 145 144 signingConfigs { 146 145 myConfig{ 147 storeFile file(" ../keystore/xxxx.keystore")146 storeFile file("${rootDir}/keystore/xxxxx.keystore") 148 147 storePassword "xxxxx" 149 148 keyAlias "pcgroup" … … 159 158 } 160 159 } 160 161 def markets = (new File("${rootDir}/keystore/market.config").text).split("\n") 162 productFlavors { 163 markets.each { name -> 164 "$name" { 165 } 166 } 167 } 168 169 String fileContents = new File("${projectDir}/AndroidManifest.xml").text 170 def m = fileContents =~ /android:versionName="(.*)"/ 171 def version = m[0][1] 172 //println version 173 174 applicationVariants.all{ variant -> 175 def market = variant.productFlavors[0].name; 176 variant.processManifest.doLast{ 177 copy{ 178 from("${projectDir}/AndroidManifest.xml") 179 into("${buildDir}/manifests/$variant.name") 180 181 filter{ 182 String line -> line.replaceAll("MOFANG_CHANNEL_VALUE", "$market") 183 } 184 variant.processResources.manifestFile = file("${buildDir}/manifests/${variant.name}/AndroidManifest.xml") 185 } 186 } 187 188 def apk = variant.packageApplication.outputFile; 189 def newName = apk.name.replace("-" + market, "_" + version + "_" + market); 190 newName = newName.replace("-release", ""); 191 192 variant.packageApplication.outputFile = new File(apk.parentFile, newName); 193 if (variant.zipAlign) { 194 newName = newName.replace("unaligned//", ""); 195 variant.zipAlign.outputFile = new File(apk.parentFile, newName.replace("-unaligned", "")); 196 } 197 } 161 198 } 162 199 … … 164 201 compile fileTree(dir: 'libs', include: '*.jar') 165 202 compile project(':pcgCommon') 166 } aidl.srcDirs = ['src'] 167 renderscript.srcDirs = ['src'] 168 res.srcDirs = ['res'] 169 assets.srcDirs = ['assets'] 170 } 171 172 173 instrumentTest.setRoot('tests') 174 175 debug.setRoot('build-types/debug') 176 release.setRoot('build-types/release') 177 } 178 179 lintOptions { 180 abortOnError false 181 } 182 } 183 184 dependencies { 185 compile fileTree(dir: 'libs', include: '*.jar') 186 compile project(':pcgCommon') 187 } 203 } 204 188 205 }}} 189 206 207 ''注意事项'' 190 208 * 要注意有些旧项目的AndroidManifest.xml不符合新的规范要加上 useOldManifestMerger true 这个参数 [[BR]] 191 209 … … 193 211 194 212 * runProguard true 代码混淆的选项 [http://www.cnblogs.com/blfshiye/p/3796384.html 参考] [[BR]] 213 214 * 市场列表文件用Unix回车分割,用其他分割修改这里 split("\n")[[BR]] 215 216 * 版本信息用正则匹配 AndroidManifest.xml 这个文件 [[BR]] 217 218 * 市场替换的代码 line.replaceAll("MOFANG_CHANNEL_VALUE", "$market"),设置manifestFile文件 variant.processResources.manifestFile [[BR]] 219 220 * 只编译release 可以采用 gradle assembleRelease 221
![(please configure the [header_logo] section in trac.ini)](http://www1.pconline.com.cn/hr/2009/global/images/logo.gif)