[flutter_tools] rename output LICENSE file to NOTICES and support loading either (#57871)
Work towards #16723 This is only safe to land after #58131 lands in google3. Only build NOTICES in asset manfiest, and load either LICENSE or NOTICES from pubspec dependencies.
This commit is contained in:
@@ -211,14 +211,14 @@ assets:
|
||||
as DevFSStringContent;
|
||||
final DevFSStringContent fontManifest = bundle.entries['FontManifest.json']
|
||||
as DevFSStringContent;
|
||||
final DevFSStringContent license = bundle.entries['LICENSE']
|
||||
final DevFSStringContent license = bundle.entries['NOTICES']
|
||||
as DevFSStringContent;
|
||||
|
||||
await bundle.build(manifestPath: 'pubspec.yaml');
|
||||
|
||||
expect(assetManifest, bundle.entries['AssetManifest.json']);
|
||||
expect(fontManifest, bundle.entries['FontManifest.json']);
|
||||
expect(license, bundle.entries['LICENSE']);
|
||||
expect(license, bundle.entries['NOTICES']);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
|
||||
@@ -89,7 +89,7 @@ flutter:
|
||||
|
||||
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/AssetManifest.json'), exists);
|
||||
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/FontManifest.json'), exists);
|
||||
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/LICENSE'), exists);
|
||||
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/NOTICES'), exists);
|
||||
// See https://github.com/flutter/flutter/issues/35293
|
||||
expect(fileSystem.file('${environment.buildDir.path}/flutter_assets/assets/foo/bar.png'), exists);
|
||||
// See https://github.com/flutter/flutter/issues/46163
|
||||
|
||||
@@ -249,12 +249,16 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('processes dependent licenses according to instructions', () async {
|
||||
fileSystem.file('foo/LICENSE')
|
||||
fileSystem.file('foo/NOTICES')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(_kMitLicense);
|
||||
fileSystem.file('bar/LICENSE')
|
||||
fileSystem.file('bar/NOTICES')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(_kApacheLicense);
|
||||
// NOTICES is preferred over LICENSE
|
||||
fileSystem.file('bar/LICENSE')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('SHOULD NOT BE INCLUDED');
|
||||
fileSystem.file('fizz/LICENSE')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(_kMitLicense); // intentionally a duplicate
|
||||
@@ -292,14 +296,17 @@ void main() {
|
||||
expect(result.combinedLicenses, contains(_kApacheLicense));
|
||||
expect(result.combinedLicenses, contains(_kMitLicense));
|
||||
|
||||
// String from LICENSE file was not included when NOTICES exists.
|
||||
expect(result.combinedLicenses, isNot(contains('SHOULD NOT BE INCLUDED')));
|
||||
|
||||
// Licenses are de-duplicated correctly.
|
||||
expect(result.combinedLicenses.split(LicenseCollector.licenseSeparator), hasLength(2));
|
||||
|
||||
// All input licenses included in result.
|
||||
final Iterable<String> filePaths = result.dependencies.map((File file) => file.path);
|
||||
expect(filePaths, unorderedEquals(<String>[
|
||||
'/foo/LICENSE',
|
||||
'/bar/LICENSE',
|
||||
'/foo/NOTICES',
|
||||
'/bar/NOTICES',
|
||||
'/fizz/LICENSE'
|
||||
]));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user