Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Change project.buildDir in standalone subprojects property #91030

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

Conversation

littleGnAl
Copy link
Contributor

@littleGnAl littleGnAl commented Sep 30, 2021

If there is a plugin project whose name is before 'app' (in lexicographical order), the project ':app' buildDir is not set correctly.

This PR revert the changes made by #77942, I'm not sure it's the right way to fix this issue, but I add a test for this case to ensure it works as expected.

List which issues are fixed by this PR. You must list at least one issue.

Fixed #91018

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) d: examples Sample code and demos f: integration_test The flutter/packages/integration_test plugin c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels Sep 30, 2021
@google-cla google-cla bot added the cla: yes label Sep 30, 2021
@jmagman
Copy link
Member

jmagman commented Sep 30, 2021

@blasten

@blasten
Copy link

blasten commented Oct 1, 2021

we need a test for this. would you be able to wire a plugin in the test that has the desired name?

The code below has an example about how to create a plugin in a test:

@littleGnAl
Copy link
Contributor Author

Hello @blasten, I have reused the android_plugin_example_app_build_test.dart, should I add a standalone integration.shard for this case?
https://github.com/flutter/flutter/pull/91030/files#diff-0a03b0a0c8e091b09635cd4d75bd08462084a15c4333fbc9fa95eab9bf2537e1R129-R130

_createAndBuildPlugin('plugin_test');
});

test('plugin example android/app/build should not exists after flutter build', () async {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@blasten I have added a new test case here, should I move it to a standalone test file?

@blasten
Copy link

blasten commented Oct 1, 2021

ah - that should work. does the test fail if you revert the changes to the template?

@littleGnAl
Copy link
Contributor Author

ah - that should work. does the test fail if you revert the changes to the template?

@blasten It seems no

Copy link

@blasten blasten left a comment

Choose a reason for hiding this comment

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

I see. Please verify the test fail without the fix

@littleGnAl
Copy link
Contributor Author

@blasten The test fails without the fix.

➜  flutter_tools git:(littlegnal/fix-subprojects-builddir-not-correct-2) ../../bin/cache/dart-sdk/bin/pub run test /Users/fenglang/codes/source/flutter/packages/flutter_tools/test/integration.shard/android_plugin_example_app_build_test.dart
The top level `pub` command is deprecated. Use `dart pub` instead.
01:49 +1 -1: plugin example android/app/build should not exists after flutter build [E]
  Expected: false
    Actual: <true>

  package:test_api                                                          expect
  test/integration.shard/android_plugin_example_app_build_test.dart 72:5    main._createAndBuildPlugin
  test/integration.shard/android_plugin_example_app_build_test.dart 130:5   main.<fn>
  test/integration.shard/android_plugin_example_app_build_test.dart 129:82  main.<fn>
  test/src/common.dart 163:18                                               test.<fn>
  test/src/common.dart 159:5                                                test.<fn>

01:49 +1 -1: loading /Users/fenglang/codes/source/flutter/packages/flutter_tools/test/integration.shard/android_plugin_example_app_build_test.dart
Consider enabling the flag chain-stack-traces to receive more detailed exceptions.
For example, 'dart test --chain-stack-traces'.
01:49 +1 -1: Some tests failed.
diff --git a/packages/flutter_tools/templates/app_shared/android-kotlin.tmpl/build.gradle b/packages/flutter_tools/templates/app_shared/android-kotlin.tmpl/build.gradle
index 24047dce5d..ed45c65885 100644
--- a/packages/flutter_tools/templates/app_shared/android-kotlin.tmpl/build.gradle
+++ b/packages/flutter_tools/templates/app_shared/android-kotlin.tmpl/build.gradle
@@ -21,8 +21,6 @@ allprojects {
 rootProject.buildDir = '../build'
 subprojects {
     project.buildDir = "${rootProject.buildDir}/${project.name}"
-}
-subprojects {
     project.evaluationDependsOn(':app')
 }

@littleGnAl littleGnAl force-pushed the littlegnal/fix-subprojects-builddir-not-correct-2 branch from a6b5f9f to 4b5df4a Compare October 1, 2021 03:18
@littleGnAl
Copy link
Contributor Author

@blasten I finally move the test to a standalone file to fill more test cases, pls take a look again, thanks.

@littleGnAl
Copy link
Contributor Author

The tests fail without this fix.

➜  flutter_tools git:(littlegnal/fix-subprojects-builddir-not-correct-2) ✗ ../../bin/cache/dart-sdk/bin/pub run test /Users/fenglang/codes/source/flutter/packages/flutter_tools/test/integration.shard/flutter_build_android_app_project_builddir_test.dart
The top level `pub` command is deprecated. Use `dart pub` instead.
01:08 +0 -1: android/app/build should not exists after flutter build apk [E]
  Expected: not a file system entity that exists
    Actual: LocalDirectory:<LocalDirectory: '/private/var/folders/gk/3g8dn2ys3nv01yxsd0j_1cz00000gr/T/flutter_flutter_plugin_test.tUCf5b/aaa/example/android/app/build'>

  package:test_api                                                                  expect
  test/integration.shard/flutter_build_android_app_project_builddir_test.dart 55:5  main._checkBuildDir
  test/integration.shard/flutter_build_android_app_project_builddir_test.dart 68:7  main.<fn>
  test/integration.shard/flutter_build_android_app_project_builddir_test.dart 60:5  main.<fn>
  test/src/common.dart 163:18                                                       test.<fn>
  test/src/common.dart 159:5                                                        test.<fn>

01:08 +0 -1: loading /Users/fenglang/codes/source/flutter/packages/flutter_tools/test/integration.shard/flutter_build_android_app_project_builddir_test.dart
Consider enabling the flag chain-stack-traces to receive more detailed exceptions.
For example, 'dart test --chain-stack-traces'.
01:47 +0 -2: android/app/build should not exists after flutter build appbundle [E]
  Expected: not a file system entity that exists
    Actual: LocalDirectory:<LocalDirectory: '/private/var/folders/gk/3g8dn2ys3nv01yxsd0j_1cz00000gr/T/flutter_flutter_plugin_test.D0m6sd/aaa/example/android/app/build'>

  package:test_api                                                                  expect
  test/integration.shard/flutter_build_android_app_project_builddir_test.dart 55:5  main._checkBuildDir
  test/integration.shard/flutter_build_android_app_project_builddir_test.dart 82:7  main.<fn>
  test/integration.shard/flutter_build_android_app_project_builddir_test.dart 74:5  main.<fn>
  test/src/common.dart 163:18                                                       test.<fn>
  test/src/common.dart 159:5                                                        test.<fn>

01:47 +0 -2: loading /Users/fenglang/codes/source/flutter/packages/flutter_tools/test/integration.shard/flutter_build_android_app_project_builddir_test.dart
Consider enabling the flag chain-stack-traces to receive more detailed exceptions.
For example, 'dart test --chain-stack-traces'.
01:47 +0 -2: Some tests failed.
diff --git a/packages/flutter_tools/templates/app_shared/android-kotlin.tmpl/build.gradle b/packages/flutter_tools/templates/app_shared/android-kotlin.tmpl/build.gradle
index 24047dce5d..ed45c65885 100644
--- a/packages/flutter_tools/templates/app_shared/android-kotlin.tmpl/build.gradle
+++ b/packages/flutter_tools/templates/app_shared/android-kotlin.tmpl/build.gradle
@@ -21,8 +21,6 @@ allprojects {
 rootProject.buildDir = '../build'
 subprojects {
     project.buildDir = "${rootProject.buildDir}/${project.name}"
-}
-subprojects {
     project.evaluationDependsOn(':app')
 }

Copy link

@blasten blasten left a comment

Choose a reason for hiding this comment

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

nice! LGTM

@fluttergithubbot fluttergithubbot merged commit 1b73a35 into flutter:master Oct 2, 2021
@gspencergoog
Copy link
Contributor

This appears to have broken the build. I'm going to try and revert and see if it fixes this.

gspencergoog added a commit to gspencergoog/flutter that referenced this pull request Oct 2, 2021
…lutter#91030)"

This reverts commit 1b73a35 because it appears to have broken the build.
@gspencergoog
Copy link
Contributor

Actually, it doesn't appear to be the case: the revert PR failed too. Probably an infra issue.

gspencergoog added a commit to gspencergoog/flutter that referenced this pull request Oct 2, 2021
@littleGnAl littleGnAl deleted the littlegnal/fix-subprojects-builddir-not-correct-2 branch October 7, 2021 04:41
clocksmith pushed a commit to clocksmith/flutter that referenced this pull request Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) c: contributor-productivity Team-specific productivity, code health, technical debt. d: examples Sample code and demos f: integration_test The flutter/packages/integration_test plugin tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

android/app module's project buildDir not correct after subprojects block merged
5 participants