mirror of
https://gitee.com/replugin/RePlugin.git
synced 2024-11-30 02:38:34 +08:00
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:
parent
2440dcab6d
commit
f16444edef
@ -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}"
|
||||
|
||||
|
@ -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 {
|
||||
//首字母大写进行拼接
|
||||
|
Loading…
Reference in New Issue
Block a user