Skip to content

Commit

Permalink
Update android_embedding_bundle CIPD instructions (flutter#44644)
Browse files Browse the repository at this point in the history
This PR updates the gradle build file for the android_embedding_bundle
cipd package to fetch license information about the dependencies listed
under `tools/androidx/files.json`. The README file for the
android_embedding_bundle now explains how to fetch the license
information and make sure it's correct in the cipd package.

This PR also pulls a new version of android_embedding_dependencies that
includes a `LICENSE` file.

It turns out that Flutter does not re-ship anything from the embedding
bundle to Flutter end-users. These dependencies are only used to create
a classpath against which we build the Android embedder and in-tree
tests. I've updated docs/comments to clarify that since I was initially
confused about how these were used.

I'm not adding a test that compares the license info fetched from maven
against a checked-in golden, yet. Still thinking about the most
effective way to do that in combination with the steps in the README.
  • Loading branch information
zanderso authored Aug 14, 2023
1 parent 3c88528 commit 1d63eec
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 42 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ deps = {
'packages': [
{
'package': 'flutter/android/embedding_bundle',
'version': 'last_updated:2021-11-23T12:31:07-0800'
'version': 'last_updated:2023-08-11T11:35:44-0700'
}
],
'condition': 'download_android_deps',
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: 1e4a09fc0f2117b53a35ad1bb8b9a08d
Signature: d8b5e1bcc7593e590ac227d01043c4a8

20 changes: 19 additions & 1 deletion tools/androidx/configure.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import groovy.json.JsonSlurper

// Configures the embedding dependencies.
ext.configureDependencies = { engineRootDir, add ->
ext.configureEmbedderDependencies = { engineRootDir, add ->
def filesJson = new File(engineRootDir, 'tools/androidx/files.json')
if (!filesJson.exists()) {
throw new Exception("${filesJson.absolutePath} not found. Did you provide the wrong engine root directory to configureDependencies?")
Expand All @@ -17,3 +17,21 @@ ext.configureDependencies = { engineRootDir, add ->
add(dependency.maven_dependency)
}
}

// Configures the embedding dependencies. To match the logic in
// generate_pom_file.py, this does not include transitive dependencies since
// they aren't used by the embedding.
ext.configureDependencies = { engineRootDir, add ->
def filesJson = new File(engineRootDir, 'tools/androidx/files.json')
if (!filesJson.exists()) {
throw new Exception("${filesJson.absolutePath} not found. Did you provide the wrong engine root directory to configureDependencies?")
}
def dependencies = new JsonSlurper().parseText(filesJson.text)
assert dependencies instanceof List
dependencies.each { dependency ->
assert dependency.maven_dependency instanceof String
if (dependency.provides) {
add(dependency.maven_dependency)
}
}
}
6 changes: 6 additions & 0 deletions tools/androidx/files.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,11 @@
"androidx.window.layout.WindowLayoutInfo",
"androidx.window.layout.WindowInfoRepository"
]
},
{
"url": "https://dl.google.com/android/maven2/com/google/android/play/core/1.8.0/core-1.8.0.aar",
"out_file_name": "core-1.8.0.aar",
"maven_dependency": "com.google.android.play:core:1.8.0",
"provides": []
}
]
1 change: 1 addition & 0 deletions tools/cipd/android_embedding_bundle/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Don't include the jars in the engine repo.
build/
lib/
.gradle
32 changes: 27 additions & 5 deletions tools/cipd/android_embedding_bundle/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
# Updating the Embedding Dependencies

The instructions in this README explain how to create a CIPD package that
contains the build-time dependencies of the Android embedding of the Engine,
and the dependencies of the in-tree testing framework. The Android embedder is
shipped to Flutter end-users, but these build-time dependencies are not.
Therefore, the license script can skip over the destination of the CIPD package
in an Engine checkout at `src/third_party/android_embedding_dependencies`.
Even so, the CIPD package should contain a LICENSE file, and the instructions
below explain how to fetch the license information for the dependencies.

## Requirements

1. Gradle. If you don't have Gradle installed, you can get it on [https://gradle.org/install/#manually](https://gradle.org/install/#manually).
2. [Depot tools](http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up).
1. If you have a flutter/engine checkout, then you should already have
[Depot tools](http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up) on your path.
1. You should have a copy of `gradle` in a flutter/engine checkout under
`src/third_party/gradle/bin/gradle`.

## Steps

1. Update tools/androidx/files.json. (This file includes the Maven dependencies used to build Flutter apps).
2. `cd` into this directory.
3. Run `./generate.sh`.
1. Update `src/flutter/tools/androidx/files.json`. (This file includes the Maven
dependencies used to build Flutter apps).
1. `cd` into this directory: `src/flutter/tools/cipd/android_embedding_bundle`.
1. Run `gradle downloadLicenses`
1. Run `gradle updateDependencies`
1. Examine the file `./build/reports/license/license-dependency.xml`. If it
contains licenses other than "The Apache License, Version 2.0" or something
very similar, STOP. Ask Hixie for adivce on how to proceed.
1. Copy or move the `lib/` directory to `src/third_party/android_embedding_dependencies/`,
overwriting its contents, and ensure the Android build still works.
1. Run `cipd create --pkg-def cipd.yaml -tag last_updated:"$version_tag"` where
`$version_tag` is the output of `date +%Y-%m-%dT%T%z`.
1. Update the `DEPS` file entry for `android_embedding_dependencies` with the
new tag: `last_updated:"$version_tag"`.
36 changes: 32 additions & 4 deletions tools/cipd/android_embedding_bundle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//
// This script downloads the embedding dependencies into a lib/ directory,
// extract jar files from AARs, so they can be used in gn.
def destinationDir = "lib"

buildscript {
repositories {
google()
Expand All @@ -19,6 +17,12 @@ buildscript {
}
}

plugins {
id "com.github.hierynomus.license-report" version "0.16.1"
}

def destinationDir = "lib"

allprojects {
repositories {
google()
Expand All @@ -36,9 +40,14 @@ configurations {
embedding
}

println project.buildDir

// Configure the embedding dependencies.
apply from: new File(rootDir, '../tools/androidx/configure.gradle').absolutePath;
configureDependencies(new File(rootDir, '../..')) { dependency ->
// NB: '../../androidx/configure.gradle' is expected to resolve to the path
// 'src/flutter/tools/androidx', and '../../..' is expected to resolve to the
// path 'src/flutter'.
apply from: new File(rootDir, '../../androidx/configure.gradle').absolutePath;
configureEmbedderDependencies(new File(rootDir, '../../..')) { dependency ->
dependencies {
embedding "$dependency"
}
Expand Down Expand Up @@ -76,3 +85,22 @@ task updateDependencies() {
}
}
}

downloadLicenses {
ext.apacheTwo = license(
'The Apache License, Version 2.0',
'http://www.apache.org/licenses/LICENSE-2.0.txt',
)
aliases = [
(apacheTwo) : [
'The Apache Software License, Version 2.0',
'Apache 2',
'Apache License Version 2.0',
'Apache License, Version 2.0',
'Apache License 2.0',
license('Apache License', 'http://www.apache.org/licenses/LICENSE-2.0'),
license('Apache License, Version 2.0', 'http://opensource.org/licenses/Apache-2.0'),
],
]
dependencyConfiguration = 'embedding'
}
29 changes: 0 additions & 29 deletions tools/cipd/android_embedding_bundle/generate.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tools/licenses/lib/paths.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final Set<String> skippedPaths = <String>{
r'fuchsia/sdk/mac/NOTICE.fuchsia',
r'fuchsia/sdk/mac/tools',
r'out', // output of build
r'third_party/android_embedding_dependencies', // testing framework for android
r'third_party/android_embedding_dependencies', // Not shipped. Used only for the build-time classpath, and for the in-tree testing framework for Android
r'third_party/android_tools', // excluded on advice
r'third_party/angle/android',
r'third_party/angle/doc',
Expand Down

0 comments on commit 1d63eec

Please sign in to comment.