diff --git a/build.gradle b/build.gradle index 1761502..dcda098 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,10 @@ buildscript { repositories { mavenLocal() jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } dependencies { classpath 'com.android.tools.build:gradle:2.2.0' @@ -15,6 +19,10 @@ allprojects { repositories { mavenLocal() jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } tasks.withType(Javadoc).all { diff --git a/plugin/src/main/groovy/com/meituan/android/walle/ChannelMaker.groovy b/plugin/src/main/groovy/com/meituan/android/walle/ChannelMaker.groovy index f2047ad..a94c11d 100644 --- a/plugin/src/main/groovy/com/meituan/android/walle/ChannelMaker.groovy +++ b/plugin/src/main/groovy/com/meituan/android/walle/ChannelMaker.groovy @@ -157,6 +157,36 @@ class ChannelMaker extends DefaultTask { } generateChannelApkByChannelFile(extension.channelFile, apkFile, channelOutputFolder, nameVariantMap) + } else if (extension.variantConfigFileName != null && extension.variantConfigFileName.length() > 0) { + List locations = new ArrayList<>() + locations.add(new File(project.projectDir, "src" + File.separator + variant.name)) + locations.add(new File(project.projectDir, "src" + File.separator + variant.flavorName)) + locations.add(new File(project.projectDir, "src" + File.separator + variant.buildType.name)) + locations.add(new File(project.projectDir, "src" + File.separator + "main")) + + + boolean isFindConfigFile = false + locations.each { file -> + if (isFindConfigFile){ + return true + } + if (file.exists()) { + File configFile = new File(file, extension.variantConfigFileName) + if (configFile.exists()) { + generateChannelApkByConfigFile(configFile, apkFile, channelOutputFolder, nameVariantMap) + isFindConfigFile = true + project.logger.error("[Walle] Using config file : " + configFile) + } + } + } + if (!isFindConfigFile) { + project.logger.error("[Walle] config file does not exist") + project.logger.error("[Walle] please put the file in the follow locations [Descending order of priority]") + locations.each { file -> + project.logger.error("[Walle] " + file.absolutePath) + } + + } } } diff --git a/plugin/src/main/groovy/com/meituan/android/walle/Extension.groovy b/plugin/src/main/groovy/com/meituan/android/walle/Extension.groovy index 7288fd6..b580bcc 100644 --- a/plugin/src/main/groovy/com/meituan/android/walle/Extension.groovy +++ b/plugin/src/main/groovy/com/meituan/android/walle/Extension.groovy @@ -41,6 +41,17 @@ class Extension { */ File configFile; + /** + *

Config file name. + *

Will find the file in the following locations: + *

/src/{@link com.android.build.gradle.api.BaseVariant#getName() variantName}/ + *

/src/{@link com.android.build.gradle.api.BaseVariant#getFlavorName() flavor}/ + *

/src/{@link com.android.builder.model.BuildType#getName() buildType}/ + *

/src/main/ + *

+ */ + String variantConfigFileName; + Extension(Project project) { apkOutputFolder = null; apkFileNameFormat = DEFAULT_APK_FILE_NAME_TEMPLATE;