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

Skip to content

Add Gradle lockfiles and tool to generate them #83067

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

Merged
merged 11 commits into from
May 21, 2021

Conversation

blasten
Copy link

@blasten blasten commented May 21, 2021

Related issue: #82745

Checks in the .lockfiles and adds a tool to generate them across the Flutter repo.

To regenerate these files, run find . -type d -name 'android' | dart dev/tools/bin/generate_gradle_lockfiles.dart
from the root of the Flutter repo.

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 feature I am adding, or Hixie said the 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 c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels May 21, 2021
@google-cla google-cla bot added the cla: yes label May 21, 2021
@@ -2,14 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file is auto generated.
// To update all the build.gradle files in the Flutter repo,
// See dev/tools/bin/generate_gradle_lockfiles.dart.
Copy link
Author

Choose a reason for hiding this comment

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

The root build.gradle file will be auto-generated after this PR, and every plugin with Gradle dependency will also have its own lockfile. See https://github.com/flutter/flutter/tree/46d887f30003b5843911cf665af942c9c37fb23b/dev/benchmarks/complex_layout/android

@blasten blasten requested review from dnfield and godofredoc May 21, 2021 02:31
@blasten blasten force-pushed the gradle_managment branch from 0ab882d to 59f5065 Compare May 21, 2021 02:42
Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

Style nits. I think making the script work on Windows would be beneficial.

Please revert the unrelated files (*.xcconfig, *.h, *.cc).

Consider landing this in two steps: one where we just update all the gradle deps, and one where we actually add the lock files (or vice versa). Right now doing both may make it harder to bisect if anything goes wrong in devicelab.

@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems unrelated to this PR.

Copy link
Author

Choose a reason for hiding this comment

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

@jmagman would it be ok to add this file to .gitignore?

Copy link
Author

Choose a reason for hiding this comment

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

These files were created after flutter pub get, which is required prior to creating the lockfiles.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should just go through and update all of these then in a separate pr. Or alternatively gitignore them and remove them

Copy link
Member

Choose a reason for hiding this comment

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

These xcconfigs should be checked into the project, not gitignored. I'm not sure why it's not already for dev/benchmarks/complex_layout. I can look into that in another PR.


void main(List<String> arguments) {
print(
"Usage: find . -type d -name 'android' | dart dev/tools/bin/generate_gradle_lockfiles.dart\n\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: no newline.

Copy link
Contributor

Choose a reason for hiding this comment

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

also nit: this makes it harder for developers on windows to run this script. Consider changing this to a file path argument where we just read the file.

Copy link
Author

Choose a reason for hiding this comment

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

what would be the issue? I have added a section about how to enter the files manually to write to the stdin pipe.

FWIW, the blaze command (internally) works this way for running multiple targets at once. I don't know what part wouldn't work on Windows since powershell also has support for the pipe operator.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh ok, so I guess on Windows you could just use something like gci -Recurse -Directory -Name "android" | dart .... That should be fine then.

Copy link
Author

Choose a reason for hiding this comment

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

🎉

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM

Emmanuel Garcia added 2 commits May 21, 2021 10:41
@blasten
Copy link
Author

blasten commented May 21, 2021

@godofredoc I'd like to see if this change also makes Gradle builds fasters. Is there a SQL I could run to see the before/after of this change?

@@ -1 +0,0 @@
#include "Generated.xcconfig"
Copy link
Member

Choose a reason for hiding this comment

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

Don't delete this file.

@@ -1 +0,0 @@
#include "Generated.xcconfig"
Copy link
Member

Choose a reason for hiding this comment

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

Or this one.

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

LGTM

When will generate_gradle_lockfiles need to be run?

@blasten
Copy link
Author

blasten commented May 21, 2021

@jmagman it would need to be run if a Gradle dependencies is added or modified from these apps. That includes modifying Flutter plugins. I've added a custom Gradle error to https://github.com/flutter/flutter/pull/83067/files#diff-c0a1cddc5ca2d811173e4bd32e800ed637b1203c37a22907703b2eaa00899dbb to guide folks on how to resolve this issue on their own.

@blasten
Copy link
Author

blasten commented May 21, 2021

Here:

final GradleHandledError lockFileDepMissing = GradleHandledError(
test: (String line) {
return line.contains('which is not part of the dependency lock state');
},
handler: ({
String line,
FlutterProject project,
bool usesAndroidX,
bool shouldBuildPluginAsAar,
}) async {
final File gradleFile = project.directory
.childDirectory('android')
.childFile('build.gradle');
globals.printStatus(
'\nYou need to update the lockfile, or disable Gradle dependency locking.\n'+
globals.logger.terminal.bolden(
'To regenerate the lockfiles run: `./gradlew :generateLockfiles` in ${gradleFile.path}\n'
'To remove dependency locking, remove the `dependencyLocking` from ${gradleFile.path}\n'
)
);
return GradleBuildStatus.exit;
},
eventLabel: 'lock-dep-issue',

@fluttergithubbot fluttergithubbot merged commit fa5883b into flutter:master May 21, 2021
@blasten blasten deleted the gradle_managment branch May 21, 2021 20:27
Gustl22 added a commit to Gustl22/flutter that referenced this pull request Dec 13, 2023
…restore testing deprecated (plugins.each) state
auto-submit bot pushed a commit that referenced this pull request Dec 20, 2023
…each) (#140037)

Restore testing deprecated settings.gradle (plugins.each).

Updated presumably by accident in #83067

Split from #137115
See also #137115 (comment)
CoderDake pushed a commit to CoderDake/flutter that referenced this pull request Dec 28, 2023
…each) (flutter#140037)

Restore testing deprecated settings.gradle (plugins.each).

Updated presumably by accident in flutter#83067

Split from flutter#137115
See also flutter#137115 (comment)
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 tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants