Commit 5ff41595 authored by Paul Jensen's avatar Paul Jensen Committed by Commit Bot

Reland "[Cronet] Build maven modules and test by building sample app with gradle"

This is a reland of 10f4dd89

I disabled the gradle build when !use_platform_icu_alternatives so Android bots
continue to build successfully.  I also moved cronet_maven/ output directory to
cronet/maven/ so it can be uploaded by the bots.

Original change's description:
> [Cronet] Build maven modules and test by building sample app with gradle
>
> This change builds maven modules for Cronet.
> Each maven module includes:
>   1. POM file defining module and listing dependent modules
>   2. Jars
>   3. Proguard files (optional)
>   4. Native libraries (optional)
>   5. Resources (optional)
>   6. Javadocs (optional)
> We build four maven modules:
>   1. cronet-api: the Cronet API
>   2. cronet-embedded: the Cronet native implementation
>   3. cronet-fallback: the Cronet fallback implementation
>   4. cronet-common: Cronet implementation in common with #3 and #4
>
> To test the maven modules, this change builds the Cronet sample app using gradle.
> You can install and run the resulting app by:
>   ninja -C out/Debug cronet_maven_test_build
>   adb install -r out/Debug/cronet_maven/test/build/outputs/apk/debug/test-debug.apk
>   adb install -r out/Debug/cronet_maven/test/build/outputs/apk/androidTest/debug/test-debug-androidTest.apk
>   adb shell am instrument -w org.chromium.cronet_sample_apk.test/android.support.test.runner.AndroidJUnitRunner
>
> Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet
> Change-Id: I5ed27e86f3e01dc3a6441ab449bbe942553343af
> Reviewed-on: https://chromium-review.googlesource.com/998019
> Commit-Queue: Paul Jensen <pauljensen@chromium.org>
> Reviewed-by: Andrei Kapishnikov <kapishnikov@chromium.org>
> Reviewed-by: Eric Stevenson <estevenson@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#554608}

Change-Id: Ieba6842b48d0b8e97ca1dc6686080cb31a87ed95
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet

TBR=estevenson@chromium.org
Eric already approved the build/ change in https://chromium-review.googlesource.com/998019

Change-Id: Ieba6842b48d0b8e97ca1dc6686080cb31a87ed95
Reviewed-on: https://chromium-review.googlesource.com/1037723
Commit-Queue: Paul Jensen <pauljensen@chromium.org>
Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Reviewed-by: default avatarAndrei Kapishnikov <kapishnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555157}
parent 5e1c7c43
...@@ -1510,6 +1510,7 @@ if (enable_java_templates) { ...@@ -1510,6 +1510,7 @@ if (enable_java_templates) {
# proguard_configs: List of proguard configs (optional). # proguard_configs: List of proguard configs (optional).
# android_manifest: Path to AndroidManifest.xml (optional). # android_manifest: Path to AndroidManifest.xml (optional).
# native_libraries: list of native libraries (optional). # native_libraries: list of native libraries (optional).
# direct_deps_only: Do not recurse on deps. (optional, defaults false).
# #
# Example # Example
# dist_aar("my_aar") { # dist_aar("my_aar") {
...@@ -1524,6 +1525,9 @@ if (enable_java_templates) { ...@@ -1524,6 +1525,9 @@ if (enable_java_templates) {
_deps = invoker.deps _deps = invoker.deps
} }
_direct_deps_only =
defined(invoker.direct_deps_only) && invoker.direct_deps_only
_build_config = "$target_gen_dir/$target_name.build_config" _build_config = "$target_gen_dir/$target_name.build_config"
_build_config_target_name = "${target_name}__build_config" _build_config_target_name = "${target_name}__build_config"
...@@ -1566,11 +1570,15 @@ if (enable_java_templates) { ...@@ -1566,11 +1570,15 @@ if (enable_java_templates) {
rebase_path(depfile, root_build_dir), rebase_path(depfile, root_build_dir),
"--output", "--output",
rebase_path(invoker.output, root_build_dir), rebase_path(invoker.output, root_build_dir),
"--jars=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)",
"--dependencies-res-zips=@FileArg($_rebased_build_config:resources:dependency_zips)", "--dependencies-res-zips=@FileArg($_rebased_build_config:resources:dependency_zips)",
"--r-text-files=@FileArg($_rebased_build_config:resources:extra_r_text_files)", "--r-text-files=@FileArg($_rebased_build_config:resources:extra_r_text_files)",
"--proguard-configs=@FileArg($_rebased_build_config:deps_info:proguard_all_configs)", "--proguard-configs=@FileArg($_rebased_build_config:deps_info:proguard_all_configs)",
] ]
if (_direct_deps_only) {
args += [ "--jars=@FileArg($_rebased_build_config:javac:classpath)" ]
} else {
args += [ "--jars=@FileArg($_rebased_build_config:deps_info:javac_full_classpath)" ]
}
if (defined(invoker.android_manifest)) { if (defined(invoker.android_manifest)) {
args += [ args += [
"--android-manifest", "--android-manifest",
......
This diff is collapsed.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.chromium.net</groupId>
<artifactId>cronet-api</artifactId>
<version>@MAJOR@.@MINOR@.@BUILD@.@PATCH@</version>
<packaging>aar</packaging>
<name>Cronet</name>
<description>Cronet API. Does not contain implementation.</description>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.chromium.net</groupId>
<artifactId>cronet-common</artifactId>
<version>@MAJOR@.@MINOR@.@BUILD@.@PATCH@</version>
<packaging>aar</packaging>
<name>Cronet</name>
<description>Cronet shared implementation. Not a complete implementation; apps and libraries should not depend on this target directly.</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cronet-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.chromium.net</groupId>
<artifactId>cronet-embedded</artifactId>
<version>@MAJOR@.@MINOR@.@BUILD@.@PATCH@</version>
<packaging>aar</packaging>
<name>Cronet</name>
<description>High performance implementation of Cronet using native libraries.</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cronet-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.chromium.net</groupId>
<artifactId>cronet-fallback</artifactId>
<version>@MAJOR@.@MINOR@.@BUILD@.@PATCH@</version>
<packaging>aar</packaging>
<name>Cronet</name>
<description>Low performance fallback Cronet implementation based on Android system HttpURLConnection implementation. Should only be used as a backup when Cronet native library implementation fails to load.</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cronet-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
sdk.dir=../../../../../third_party/android_tools/sdk
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
def cronet_dir = "../../../../../../components/cronet/android"
buildTypes {
release {
minifyEnabled true
testProguardFiles "$cronet_dir/maven/test/proguard.cfg"
}
debug {
minifyEnabled true
testProguardFiles "$cronet_dir/maven/test/proguard.cfg"
}
}
// Cronet jars contain Java 8 bytecodes.
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
defaultConfig {
applicationId "org.chromium.cronet_sample_apk"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
sourceSets {
main {
manifest.srcFile "$cronet_dir/sample/AndroidManifest.xml"
java.srcDirs = [ "$cronet_dir/sample/src" ]
res.srcDirs = [ "$cronet_dir/sample/res" ]
}
androidTest {
manifest.srcFile "$cronet_dir/sample/javatests/AndroidManifest.xml"
java.srcDirs = [ "$cronet_dir/sample/javatests/src" ]
}
}
}
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
maven {
url '../..'
}
}
dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'org.chromium.net:cronet-embedded:@MAJOR@.@MINOR@.@BUILD@.@PATCH@'
androidTestUtil 'com.android.support.test:orchestrator:1.0.1'
}
#!/usr/bin/env python
#
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import optparse
import os
import sys
REPOSITORY_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__), '..', '..', '..', '..', '..'))
sys.path.append(os.path.join(REPOSITORY_ROOT, 'build', 'android', 'gyp',
'util'))
import build_utils
def BuildWithGradle(options):
gradle_path = os.path.join(REPOSITORY_ROOT, 'third_party', 'gradle_wrapper',
'gradlew')
gradle_cmd = [gradle_path, 'assembleDebug', 'assembleAndroidTest']
build_utils.CheckOutput(gradle_cmd, cwd=options.project_dir)
def main():
parser = optparse.OptionParser()
build_utils.AddDepfileOption(parser)
parser.add_option('--project-dir', help='Gradle project directory.')
parser.add_option('--stamp', help='Path to touch on success.')
options, _ = parser.parse_args()
BuildWithGradle(options)
if options.depfile:
assert options.stamp
build_utils.WriteDepfile(options.depfile, options.stamp)
if options.stamp:
build_utils.Touch(options.stamp)
if __name__ == '__main__':
sys.exit(main())
# This is needed to avoid proguard warnings like:
# library class android.content.Intent depends on program class org.xmlpull.v1.XmlPullParser
-dontwarn org.xmlpull.v1.*
# This is needed to avoid proguard warnings like:
# com.google.devtools.build.android.desugar.runtime.ThrowableExtension is not being kept as
# 'com.google.devtools.build.android.desugar.runtime.ThrowableExtension', but remapped to
# 'a.a.a.a.a.a.a.a'
-dontwarn com.google.devtools.build.android.desugar.runtime.**
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import optparse import optparse
import os import os
import shutil
import sys import sys
import tempfile import tempfile
...@@ -33,8 +34,7 @@ class CronetExtension(Extension): ...@@ -33,8 +34,7 @@ class CronetExtension(Extension):
CronetPostprocessor(md), '_end') CronetPostprocessor(md), '_end')
def GenerateJavadoc(options, src_dir): def GenerateJavadoc(options, src_dir, output_dir):
output_dir = os.path.abspath(os.path.join(options.output_dir, 'javadoc'))
working_dir = os.path.join(options.input_dir, 'android', 'api') working_dir = os.path.join(options.input_dir, 'android', 'api')
overview_file = os.path.abspath(options.overview_file) overview_file = os.path.abspath(options.overview_file)
...@@ -72,6 +72,14 @@ def GenerateJavadoc(options, src_dir): ...@@ -72,6 +72,14 @@ def GenerateJavadoc(options, src_dir):
build_utils.DeleteDirectory(output_dir) build_utils.DeleteDirectory(output_dir)
raise raise
# Create an index.html file at the root as this is the accepted format.
# Do this by copying reference/index.html and adjusting the path.
with open(os.path.join(output_dir, 'reference', 'index.html'), 'r') as \
old_index, open(os.path.join(output_dir, 'index.html'), 'w') as new_index:
for line in old_index:
new_index.write(line.replace('classes.html',
os.path.join('reference', 'classes.html')))
def main(): def main():
parser = optparse.OptionParser() parser = optparse.OptionParser()
...@@ -81,7 +89,7 @@ def main(): ...@@ -81,7 +89,7 @@ def main():
parser.add_option('--input-src-jar', help='Cronet api source jar') parser.add_option('--input-src-jar', help='Cronet api source jar')
parser.add_option('--overview-file', help='Path of the overview page') parser.add_option('--overview-file', help='Path of the overview page')
parser.add_option('--readme-file', help='Path of the README.md') parser.add_option('--readme-file', help='Path of the README.md')
parser.add_option('--stamp', help='Path to touch on success.') parser.add_option('--zip-file', help='Path to ZIP archive of javadocs.')
parser.add_option('--android-sdk-jar', help='Path to android.jar') parser.add_option('--android-sdk-jar', help='Path to android.jar')
options, _ = parser.parse_args() options, _ = parser.parse_args()
...@@ -96,16 +104,18 @@ def main(): ...@@ -96,16 +104,18 @@ def main():
net_docs.ProcessDocs([options.readme_file], options.input_dir, net_docs.ProcessDocs([options.readme_file], options.input_dir,
options.output_dir, extensions=[CronetExtension()]) options.output_dir, extensions=[CronetExtension()])
GenerateJavadoc(options, os.path.abspath(unzipped_jar_path)) output_dir = os.path.abspath(os.path.join(options.output_dir, 'javadoc'))
GenerateJavadoc(options, os.path.abspath(unzipped_jar_path), output_dir)
if options.stamp: if options.zip_file:
build_utils.Touch(options.stamp) assert options.zip_file.endswith('.zip')
shutil.make_archive(options.zip_file[:-4], 'zip', output_dir)
if options.depfile: if options.depfile:
assert options.stamp assert options.zip_file
deps = [] deps = []
for root, _, filenames in os.walk(options.input_dir): for root, _, filenames in os.walk(options.input_dir):
deps.extend(os.path.join(root, f) for f in filenames) deps.extend(os.path.join(root, f) for f in filenames)
build_utils.WriteDepfile(options.depfile, options.stamp, deps) build_utils.WriteDepfile(options.depfile, options.zip_file, deps)
# Clean up temporary output directory. # Clean up temporary output directory.
build_utils.DeleteDirectory(unzipped_jar_path) build_utils.DeleteDirectory(unzipped_jar_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment