Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions build-artifacts/project-template-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,26 @@ copyTypings.onlyIf({
generateTypescriptDefinitions.didWork;
})

task validateAppIdMatch {
doLast {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if the build is happening in debug or release - https://github.com/NativeScript/android-runtime/blob/b74218bfd5d0e57087dcc0473366f76d34ff6433/build-artifacts/project-template-gradle/build.gradle#L84

There is no point in the user seeing the warning if they are preparing to release their app with an applicationId they themselves put in the app.gradle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. :)

def packageJsonFile = new File("$projectDir/../../package.json");
def lineSeparator = System.getProperty("line.separator");

if (packageJsonFile.exists() && !project.hasProperty("release")) {
String content = packageJsonFile.getText("UTF-8")
def jsonSlurper = new JsonSlurper()
def packageJsonMap = jsonSlurper.parseText(content)

if (packageJsonMap.nativescript.id != android.defaultConfig.applicationId) {
def errorMessage = "${lineSeparator}WARNING: The Application identifier is different from the one inside 'package.json' file.$lineSeparator" +
"NativeScript CLI might not work properly.$lineSeparator" +
"Update the application identifier in package.json and app.gradle so that they match.";
logger.error(errorMessage);
}
}
}
}

////////////////////////////////////////////////////////////////////////////////////
////////////////////////////// OPTIONAL TASKS //////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -801,6 +821,7 @@ task deleteGeneratedBindings(type: Delete) {
delete "$projectDir/src/main/java/com/tns/gen"
}

buildapk.finalizedBy("validateAppIdMatch");
deleteMetadata.dependsOn(":asbg:clean")
deleteFlavors.dependsOn(deleteMetadata)
deleteConfigurations.dependsOn(deleteFlavors)
Expand Down