Skip to content

Commit ebe6e74

Browse files
KristianDDPlamen5kov
authored andcommitted
Add warning for difference of application identifier. (#810)
* Add warning for difference of application identifier. * Fix comments
1 parent 94c14b4 commit ebe6e74

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

build-artifacts/project-template-gradle/build.gradle

+21
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,26 @@ copyTypings.onlyIf({
722722
generateTypescriptDefinitions.didWork;
723723
})
724724

725+
task validateAppIdMatch {
726+
doLast {
727+
def packageJsonFile = new File("$projectDir/../../package.json");
728+
def lineSeparator = System.getProperty("line.separator");
729+
730+
if (packageJsonFile.exists() && !project.hasProperty("release")) {
731+
String content = packageJsonFile.getText("UTF-8")
732+
def jsonSlurper = new JsonSlurper()
733+
def packageJsonMap = jsonSlurper.parseText(content)
734+
735+
if (packageJsonMap.nativescript.id != android.defaultConfig.applicationId) {
736+
def errorMessage = "${lineSeparator}WARNING: The Application identifier is different from the one inside 'package.json' file.$lineSeparator" +
737+
"NativeScript CLI might not work properly.$lineSeparator" +
738+
"Update the application identifier in package.json and app.gradle so that they match.";
739+
logger.error(errorMessage);
740+
}
741+
}
742+
}
743+
}
744+
725745
////////////////////////////////////////////////////////////////////////////////////
726746
////////////////////////////// OPTIONAL TASKS //////////////////////////////////////
727747
////////////////////////////////////////////////////////////////////////////////////
@@ -802,6 +822,7 @@ task deleteGeneratedBindings(type: Delete) {
802822
delete "$projectDir/src/main/java/com/tns/gen"
803823
}
804824

825+
buildapk.finalizedBy("validateAppIdMatch");
805826
deleteMetadata.dependsOn(":asbg:clean")
806827
deleteFlavors.dependsOn(deleteMetadata)
807828
deleteConfigurations.dependsOn(deleteFlavors)

0 commit comments

Comments
 (0)