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鈥檒l 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

Merging #1214 (ded6419) into master (5db8508) will decrease coverage by 0.09%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            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     
Impacted Files Coverage 螖
lib/create.js 94.24% <酶> (-0.20%) 猬囷笍
lib/prepare.js 44.61% <0.00%> (-0.14%) 猬囷笍
lib/builders/ProjectBuilder.js 73.24% <100.00%> (+0.34%) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 5db8508...ded6419. Read the comment docs.

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