optimize a piece of code and repair one bug about compatibility of path separators for window and Linux (#212)

Compatible with path separators for window and Linux, and fit split param based on 'Pattern.quote'

* Compatible with path separators for window and Linux, and fit split param based on 'Pattern.quote'

* add import package

* add import package
This commit is contained in:
osan 2017-07-17 18:26:06 +08:00 committed by 王玉鹏
parent 2440dcab6d
commit f16444edef
2 changed files with 9 additions and 5 deletions

View File

@ -27,6 +27,9 @@ import javassist.ClassPool
import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.io.FileUtils
import org.gradle.api.Project
import java.util.regex.Pattern
/**
* @author RePlugin Team
*/
@ -66,10 +69,8 @@ public class ReClassTransform extends Transform {
def config = project.extensions.getByName('repluginPluginConfig')
File rootLocation = outputProvider.rootLocation
// Windows \split \
// 使 getName()+File.separatorChar便使 name
//
def variantDir = rootLocation.absolutePath.split(getName())[1].substring(1)
// Compatible with path separators for window and Linux, and fit split param based on 'Pattern.quote'
def variantDir = rootLocation.absolutePath.split(getName() + Pattern.quote(File.separator))[1]
println ">>> variantDir: ${variantDir}"

View File

@ -19,6 +19,8 @@ package com.qihoo360.replugin.gradle.plugin.manifest
import org.gradle.api.Project
import java.util.regex.Pattern
/**
* @author RePlugin Team
*/
@ -37,7 +39,8 @@ public class ManifestAPI {
* AndroidManifest.xml
*/
def static manifestPath(Project project, String variantDir) {
def variantDirArray = variantDir.split("/")
// Compatible with path separators for window and Linux, and fit split param based on 'Pattern.quote'
def variantDirArray = variantDir.split(Pattern.quote(File.separator))
String variantName = ""
variantDirArray.each {
//