Skip to content
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

fix: display project name in Android Studio #1214

Merged
merged 5 commits into from
Aug 13, 2021

Conversation

ath0mas
Copy link
Contributor

@ath0mas ath0mas commented Apr 18, 2021

Platforms affected

Android

Motivation and Context

fixes #1209

(Android Studio resets project name on Gradle reload)

Description

Add rootProject.name = "Hello World" inside settings.gradle at root.

Remove .idea/.name file previously added with #1173 and v9.1.0

Testing

npm test success + project creation, open and run from IDE into emulator

Fine on 10.0.0-dev and same for 9.2.0-dev 👍 (would be nice to backport this into a 9.x fix release)

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@codecov-commenter
Copy link

codecov-commenter commented Apr 18, 2021

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 73.15%. Comparing base (5db8508) to head (ded6419).
Report is 106 commits behind head on master.

Files with missing lines Patch % Lines
lib/prepare.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1214      +/-   ##
==========================================
- Coverage   73.25%   73.15%   -0.10%     
==========================================
  Files          21       21              
  Lines        1645     1643       -2     
==========================================
- Hits         1205     1202       -3     
- Misses        440      441       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@breautek breautek left a comment

Choose a reason for hiding this comment

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

(would be nice to backport this into a 9.x fix release)

Unlikely this will happen unfortunately.

@breautek breautek added the bug label Apr 19, 2021
@breautek breautek requested a review from erisu April 19, 2021 01:10
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

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

  • PR needs to be rebased with master.
  • rootProject.name becomes undefined when you run cordova build android.
  • If I change the project name in config.xml the project name is not updated.

@ath0mas ath0mas changed the title Fix how project name is set for Android Studio WIP Fix how project name is set for Android Studio Aug 1, 2021
@ath0mas ath0mas changed the title WIP Fix how project name is set for Android Studio (WIP) Fix how project name is set for Android Studio Aug 1, 2021
@ath0mas
Copy link
Contributor Author

ath0mas commented Aug 1, 2021

* PR needs to be rebased with master.
* `rootProject.name` becomes `undefined` when you run `cordova build android`.
* If I change the project name in `config.xml` the project name is not updated.
  • now rebased
  • good catch, I will look at it (caused by changes merged recently)
  • is that the case with the .idea/.name file on current master? can you describe the steps you follow please

@erisu
Copy link
Member

erisu commented Aug 2, 2021

(caused by changes merged recently)

Not sure what you mean by this because the issue existed in the PR, not from master or the rebase.

All you need to do is create a project with your PR and then run cordova build android. You will see it becomes undefined.

@ath0mas
Copy link
Contributor Author

ath0mas commented Aug 2, 2021

You are right, it seems I missed ProjectBuilder constructor is more central than I thought and should not be modified.
I started to rework this PR to consider build and prepare, as much as create 👍 .

@ath0mas ath0mas changed the title (WIP) Fix how project name is set for Android Studio Fix how project name is set for Android Studio Aug 2, 2021
@ath0mas ath0mas requested a review from erisu August 2, 2021 14:53
@ath0mas
Copy link
Contributor Author

ath0mas commented Aug 2, 2021

I push a new cdv-gradle-name.gradle file next to settings.gradle, that loads it,
and updated on prepare (so for create and build too) with every <name> change made in config.xml.

It deals with forbidden characters in gradle project name to prevent error.

@erisu erisu changed the title Fix how project name is set for Android Studio fix: display project name in Android Studio Aug 13, 2021
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

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

LGTM

I tested the following steps:

  • cordova create
  • cordova platform add
  • confirmed cdv-gradle-name.gradle was created with project name added.
  • confirmed settings.gradle contained the apply to cdv-gradle-name.gradle file.
  • cordova build successfully
  • confirmed cdv-gradle-name.gradle continued to show correct project name.
  • confirmed settings.gradle continued to apply to cdv-gradle-name.gradle file.
  • confirmed that Android Studio displayed project name in project list & project view.
  • updated project name in config.xml
  • cordova prepare (part of build command but ran as a separate test)
  • confirmed cdv-gradle-name.gradle updated with the new project name.
  • confirmed settings.gradle continued to apply to cdv-gradle-name.gradle file.
  • cordova build successfully
  • confirmed that Android Studio displayed updated project name in project list & project view after performing the Gradle Sync process.

@erisu erisu merged commit 09c7523 into apache:master Aug 13, 2021
@ath0mas ath0mas deleted the fix/ide-project-name branch August 19, 2021 21:25
wedgberto pushed a commit to wedgberto/cordova-android that referenced this pull request May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android Studio resets project name on Gradle reload
4 participants