Skip to content

Commit

Permalink
Merge pull request Meituan-Dianping#322 from OstAlex/master
Browse files Browse the repository at this point in the history
Support Application Variants
  • Loading branch information
achellies committed Dec 11, 2020
2 parents 1f1cbbf + 94a841b commit f78edcf
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -15,6 +19,10 @@ allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}

tasks.withType(Javadoc).all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,36 @@ class ChannelMaker extends DefaultTask {
}

generateChannelApkByChannelFile(extension.channelFile, apkFile, channelOutputFolder, nameVariantMap)
} else if (extension.variantConfigFileName != null && extension.variantConfigFileName.length() > 0) {
List<File> 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)
}

}
}
}

Expand Down
11 changes: 11 additions & 0 deletions plugin/src/main/groovy/com/meituan/android/walle/Extension.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ class Extension {
*/
File configFile;

/**
* <p/>Config file name.
* <p/>Will find the file in the following locations:
* <p/> /src/{@link com.android.build.gradle.api.BaseVariant#getName() variantName}/
* <p/> /src/{@link com.android.build.gradle.api.BaseVariant#getFlavorName() flavor}/
* <p/> /src/{@link com.android.builder.model.BuildType#getName() buildType}/
* <p/> /src/main/
* <p/>
*/
String variantConfigFileName;

Extension(Project project) {
apkOutputFolder = null;
apkFileNameFormat = DEFAULT_APK_FILE_NAME_TEMPLATE;
Expand Down

0 comments on commit f78edcf

Please sign in to comment.