-
-
Notifications
You must be signed in to change notification settings - Fork 136
Take applicationId from package.json #848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Take applicationId from package.json #848
Conversation
@@ -724,18 +736,20 @@ copyTypings.onlyIf({ | |||
|
|||
task validateAppIdMatch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This task appears to be almost identical to setAppIdentifier. You can either extract the common logic in a static function used by both tasks. Or think whether setAppIdentifier should be so early in the configuration phase, because at that point another gradle configuration may overwrite the id.
I'd consider calling setAppIdentifier's code implicitly only on debug builds (meaning put it in a debug-build check) - replacing the app identifier automatically with what's in the package.json, informing the user of the implicit actions, while leaving the application identifier untouched otherwise, if it has already been set someplace else in Gradle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will extract the 4 common lines of the tasks in a static function.
The behavior you describe is almost the total opposite of what we've decided on the meeting for this feature and what has been approved in the meeting notes from you, @rosen-vladimirov, @PanayotCankov, @Plamen5kov and other teem members.
We set application identifier that early so that we keep our current behavior and don't force the configuration on the user. If the configuration from package.json is overwritten in later configuration stages the user will get a fair warning that this is not the recommended way and that Livesync will not work properly.
Having the app identifier set one way in debug and another way (and from another place) in release build sounds strange to me. I'd never expect a tooling to behave this way.
def appIdentifier = ""; | ||
if(packageJsonMap){ | ||
appIdentifier = packageJsonMap.nativescript.id; | ||
if (!(appIdentifier instanceof String)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does CLI check if appIdentifier object is valid? if not please do some kind of a check here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes there is validation for the id property inside CLI:
https://github.com/NativeScript/nativescript-cli/blob/master/lib/services/android-project-service.ts#L474
https://github.com/NativeScript/nativescript-cli/blob/master/lib/services/android-project-service.ts#L95
https://github.com/NativeScript/nativescript-cli/blob/master/lib/commands/run.ts#L40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, look at the comments.
94d98cb
to
fb06ea6
Compare
@KristianDD you need to rebase to master for the CI to run |
fb06ea6
to
4e95aa6
Compare
💚 |
4e95aa6
to
d62ef74
Compare
💚 |
Task |
@KristianDD I've changed the if statement to be backward compatible, so it should match both |
@KristianDD please don't change the if-statement for the time being, currently it can pick up all flavors of assemble, while assembleDebug/Release will only conform to these two. |
d62ef74
to
ccbed06
Compare
run ci |
💚 |
💚 |
💚 |
@@ -56,6 +56,48 @@ def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileS | |||
def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk : 26 } | |||
def computeBuildToolsVersion = { -> project.hasProperty("buildToolsVersion") ? buildToolsVersion : "26.0.1" } | |||
|
|||
def getAppIdentifier = { packageJsonMap -> | |||
def appIdentifier = ""; | |||
if(packageJsonMap){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indents please
} | ||
|
||
def getProjectName = { -> | ||
if(project.hasProperty("nsApplicationIdentifier")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent + format indentation
println "\t + setting applicationId"; | ||
File packageJsonFile = new File("$rootDir/../../package.json"); | ||
|
||
if(packageJsonFile.exists()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
def packageJsonMap = jsonSlurper.parseText(content); | ||
def appIdentifier = getAppIdentifier(packageJsonMap); | ||
|
||
if(appIdentifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
def lineSeparator = System.getProperty("line.separator") | ||
|
||
if (project.hasProperty("nsApplicationIdentifier") && !project.hasProperty("release")) { | ||
if(project.nsApplicationIdentifier != android.defaultConfig.applicationId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
def errorMessage = "${lineSeparator}WARNING: The Application identifier is different from the one inside \"package.json\" file.$lineSeparator" + | ||
"NativeScript CLI might not work properly.$lineSeparator" + | ||
"Remove applicationId from app.gradle and update the \"nativescript.id\" in package.json.$lineSeparator" + | ||
"Actual: ${android.defaultConfig.applicationId}$lineSeparator" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
💚 |
fix(build.gradle): warning for different indentifiers not shown
248332f
to
24e77aa
Compare
test-app/app/build.gradle
Outdated
def getAppIdentifier = { packageJsonMap -> | ||
def appIdentifier = ""; | ||
if (packageJsonMap) { | ||
appIdentifier = packageJsonMap.nativescript.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about testing for packageJsonMap.nativescript
Take applicationId from package.json
Description
While still overwrite of applicationId from app.gradle is possible, user is able to specify a platform specific identifier inside package.json. This addresses problems related to livesync not working when applicationId is changed inside app.gradle
Does your commit message include the wording below to reference a specific issue in this repo?
Fixes NativeScript/nativescript-cli#3040.
Related Pull Requests
NativeScript/nativescript-cli#3120
Does your pull request have [unit tests]