Skip to content

Commit

Permalink
Grab applicationId from product flavor (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Driller committed May 3, 2016
1 parent 6cf7217 commit 842d5ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class BuildConstantsPlugin implements Plugin<Project> {
def generateConstantsTask = project.tasks.create([name : "generate${variantName}BuildConstants",
description: "Generates both Java and XML build constants",
type : BuildConstantsTask], {
appId = variant.applicationId
variantDir = variant.dirName
constants = project.buildConstants.constants
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.gradle.api.tasks.TaskAction

class BuildConstantsTask extends DefaultTask {

@Input String appId
@Input String variantDir
@Input Map<String, Object> constants

Expand Down Expand Up @@ -43,7 +44,7 @@ class BuildConstantsTask extends DefaultTask {
private File createJavaFile() {
String fileNameInput = project.buildConstants.javaFileName
String fileName = javaFileName = new JavaFileNameSanitizer().sanitize fileNameInput
new JavaFileFactory(appId(), project.buildDir.path, variantDir, new AppIdToPathMapper()).create fileName
new JavaFileFactory(appId, project.buildDir.path, variantDir, new AppIdToPathMapper()).create fileName
}

@NonNull
Expand All @@ -54,15 +55,10 @@ class BuildConstantsTask extends DefaultTask {
}

private void brewJava() {
new JavaConstantsWriter(javaFile, appId(), javaFileName).write constants
new JavaConstantsWriter(javaFile, appId, javaFileName).write constants
}

private void brewXml() {
new XmlConstantsWriter(xmlFile).write constants
}

@NonNull
private String appId() {
project.android.defaultConfig.applicationId
}
}

0 comments on commit 842d5ae

Please sign in to comment.