Commit 0803a8bb authored by Paul Jensen's avatar Paul Jensen Committed by Commit Bot

[Cronet] Remove unused maven building logic

Building maven modules is no longer done in Chromium so this
code is dead.

Change-Id: I7828ce3ce1ed42ebd9c923c428385c97661c6621
Reviewed-on: https://chromium-review.googlesource.com/c/1351369Reviewed-by: default avatarMisha Efimov <mef@chromium.org>
Commit-Queue: Paul Jensen <pauljensen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610896}
parent 2bcc1089
......@@ -1646,199 +1646,4 @@ if (!is_component_build) {
]
}
}
_maven_dir = "$_package_dir/maven-$current_cpu"
_maven_modules_dir = "$_maven_dir/org/chromium/net"
_maven_test_dir = "$_maven_dir/test"
_maven_version =
"$chrome_version_major.$chrome_version_build.$chrome_version_patch"
copy("cronet_maven_test_copy") {
sources = [
"maven/build.gradle",
"maven/local.properties",
"maven/settings.gradle",
]
outputs = [
"$_maven_test_dir/{{source_file_part}}",
]
}
process_version("cronet_maven_build_embedded_copy") {
template_file = "maven/test/build_embedded.gradle.template"
sources = [
"//chrome/VERSION",
lastchange_file,
]
output = "$_maven_test_dir/test_embedded/build.gradle"
}
process_version("cronet_maven_build_fallback_copy") {
template_file = "maven/test/build_fallback.gradle.template"
sources = [
"//chrome/VERSION",
lastchange_file,
]
output = "$_maven_test_dir/test_fallback/build.gradle"
}
if (use_platform_icu_alternatives) {
action("cronet_maven_test_build") {
script = "maven/test/build_with_gradle.py"
depfile = "$target_gen_dir/$target_name.d"
deps = [
":cronet_maven_build_embedded_copy",
":cronet_maven_build_fallback_copy",
":cronet_maven_modules",
":cronet_maven_test_copy",
# These deps ensure all source files of the sample app are deps.
":cronet_sample_apk",
":cronet_sample_test_apk",
]
_stamp_file = "$target_gen_dir/$target_name.stamp"
outputs = [
_stamp_file,
"$_maven_test_dir/build/outputs/apk/debug/test-debug.apk",
"$_maven_test_dir/build/outputs/apk/androidTest/debug/test-debug-androidTest.apk",
]
args = [
"--project-dir",
rebase_path("$_maven_test_dir"),
"--depfile",
rebase_path(depfile, root_build_dir),
"--stamp",
rebase_path(_stamp_file, root_build_dir),
]
testonly = true
}
}
# Builds a maven module.
template("cronet_maven_module") {
_module_name = invoker.module_name
# Build POM file.
_pom_target_name = "pom_$target_name"
_deps = [ ":$_pom_target_name" ]
process_version(_pom_target_name) {
template_file = "maven/$_module_name.pom.template"
sources = [
"//chrome/VERSION",
lastchange_file,
]
output = "$_maven_modules_dir/$_module_name/$_maven_version/$_module_name-$_maven_version.pom"
}
if (defined(invoker.resource_dir)) {
android_resources(invoker.module_name + "_resources") {
resource_dirs = [ invoker.resource_dir ]
android_manifest = "../../../build/android/AndroidManifest.xml"
}
}
# Build AAR file.
_aar_target_name = "aar_$target_name"
dist_aar(_aar_target_name) {
deps = [
":cronet_package_copy",
invoker.aar_jar_dep,
]
direct_deps_only = true
if (defined(invoker.aar_proguard_config)) {
proguard_configs = [ invoker.aar_proguard_config ]
}
if (defined(invoker.aar_native_lib_dep)) {
native_libraries = get_target_outputs(invoker.aar_native_lib_dep)
deps += [ invoker.aar_native_lib_dep ]
}
if (defined(invoker.resource_dir)) {
deps += [ ":" + invoker.module_name + "_resources" ]
}
output = "$root_build_dir/$_aar_target_name.aar"
}
_aar_copy_target_name = "$target_name.aar"
_deps += [ ":$_aar_copy_target_name" ]
copy(_aar_copy_target_name) {
sources = get_target_outputs(":$_aar_target_name")
outputs = [
"$_maven_modules_dir/$_module_name/$_maven_version/$_module_name-$_maven_version.aar",
]
deps = [
":$_aar_target_name",
]
}
if (defined(invoker.src_jar_dep)) {
_copy_target_name = "$target_name-sources.jar"
_deps += [ ":$_copy_target_name" ]
copy(_copy_target_name) {
sources = get_target_outputs(invoker.src_jar_dep)
outputs = [
"$_maven_modules_dir/$_module_name/$_maven_version/$_module_name-$_maven_version-sources.jar",
]
deps = [
invoker.src_jar_dep,
]
}
}
if (defined(invoker.javadoc_jar_dep)) {
_copy_target_name = "$target_name-javadoc.jar"
_deps += [ ":$_copy_target_name" ]
copy(_copy_target_name) {
sources = get_target_outputs(invoker.javadoc_jar_dep)
outputs = [
"$_maven_modules_dir/$_module_name/$_maven_version/$_module_name-$_maven_version-javadoc.jar",
]
deps = [
invoker.javadoc_jar_dep,
]
}
}
group(target_name) {
deps = _deps
}
}
cronet_maven_module("cronet_maven_api_module") {
module_name = "cronet-api"
aar_jar_dep = ":package_api_java"
src_jar_dep = ":jar_cronet_api_source"
javadoc_jar_dep = ":generate_javadoc"
resource_dir = "api/res"
}
cronet_maven_module("cronet_maven_impl_common_module") {
module_name = "cronet-common"
aar_jar_dep = ":package_impl_common_java"
aar_proguard_config = "$_package_dir/cronet_impl_common_proguard.cfg"
src_jar_dep = ":jar_cronet_impl_common_java_source"
}
cronet_maven_module("cronet_maven_impl_native_module") {
module_name = "cronet-embedded"
aar_jar_dep = ":package_impl_native_java"
aar_proguard_config = "$_package_dir/cronet_impl_native_proguard.cfg"
aar_native_lib_dep = ":cronet_package_copy_native_lib"
src_jar_dep = ":jar_cronet_impl_native_java_source"
}
cronet_maven_module("cronet_maven_impl_platform_module") {
module_name = "cronet-fallback"
aar_jar_dep = ":package_impl_platform_java"
aar_proguard_config = "$_package_dir/cronet_impl_platform_proguard.cfg"
src_jar_dep = ":jar_cronet_impl_platform_java_source"
}
group("cronet_maven_modules") {
deps = [
":cronet_maven_api_module",
":cronet_maven_impl_common_module",
":cronet_maven_impl_native_module",
":cronet_maven_impl_platform_module",
]
}
}
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@.@BUILD@.@PATCH@</version>
<packaging>aar</packaging>
<name>Cronet</name>
<description>Cronet API. Does not contain implementation.</description>
<licenses>
<license>
<name>Chromium and built-in dependencies</name>
<url>https://storage.cloud.google.com/chromium-cronet/android/@MAJOR@.@MINOR@.@BUILD@.@PATCH@/Release/cronet/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
</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@.@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>
<licenses>
<license>
<name>Chromium and built-in dependencies</name>
<url>https://storage.cloud.google.com/chromium-cronet/android/@MAJOR@.@MINOR@.@BUILD@.@PATCH@/Release/cronet/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
</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@.@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>
<licenses>
<license>
<name>Chromium and built-in dependencies</name>
<url>https://storage.cloud.google.com/chromium-cronet/android/@MAJOR@.@MINOR@.@BUILD@.@PATCH@/Release/cronet/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
</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@.@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>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<licenses>
<license>
<name>Chromium and built-in dependencies</name>
<url>https://storage.cloud.google.com/chromium-cronet/android/@MAJOR@.@MINOR@.@BUILD@.@PATCH@/Release/cronet/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>
sdk.dir=../../../../../third_party/android_tools/sdk
include ':test_embedded'
include ':test_fallback'
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@.@BUILD@.@PATCH@'
androidTestUtil 'com.android.support.test:orchestrator:1.0.1'
}
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-fallback:@MAJOR@.@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.**
#!/usr/bin/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.
"""combine_maven_modules.py - Combine Cronet maven modules together."""
import fileinput
import optparse
import os
import shutil
import sys
import tempfile
import zipfile
REPOSITORY_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__), '..', '..', '..'))
ANDROID_MANIFEST = os.path.join(REPOSITORY_ROOT, 'build', 'android',
'AndroidManifest.xml')
VERSION_SCRIPT = os.path.join(REPOSITORY_ROOT, 'build', 'util', 'version.py')
KEEP_RESOURCE = os.path.join(REPOSITORY_ROOT, 'components', 'cronet', 'android',
'api', 'res', 'raw', 'keep_cronet_api.xml')
def zipdir(path, zip_file):
ziph = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED)
for root, _, files in os.walk(path):
for file_to_zip in files:
filename = os.path.join(root, file_to_zip)
ziph.write(filename, filename[len(path):])
ziph.close()
class ModuleBuilder(object):
def __init__(self, work_dir, version, suffix):
"""ModuleBuilder builds Maven modules.
Args:
work_dir: Working directory to build Maven modules.
version: Chromium version (e.g. 66.0.3359.126).
suffix: Maven module version suffix (e.g. -alpha).
"""
self._build_dir = os.path.join(work_dir, 'Release', 'cronet')
self._version_file = os.path.join(work_dir, 'Release', 'VERSION')
self._modules_dir = os.path.join(work_dir, 'org', 'chromium', 'net')
# Convert from Chromium's four number version (e.g. 66.0.3359.126) to a
# three number version more compatible with Maven version comparing.
# Remove the second number from Chromium's which is always 0.
version = version.split('.')
del version[1]
version = '.'.join(version)
self._version_without_suffix = version
self._version = '%s%s' % (version, suffix)
self._suffix = suffix
def make_module(self, module_name, aar_jar, include_javadocs=False,
include_keep_resource=False, aar_proguard_config=None,
aar_native_lib=None):
"""Make a Maven module.
Args:
module_name: Maven module name (e.g. cronet-api).
aar_jar: Name of jar to include in aar.
include_javadocs: Boolean indicating if javadocs should be put in aar.
include_keep_resource: Boolean indicating if keep_cronet_api.xml
resource should be included in aar.
aar_proguard_config: Proguard config file to include in aar.
aar_native_lib: Native library name to include in aar.
"""
aar_jar = os.path.join(self._build_dir, aar_jar)
module_dir = os.path.join(self._modules_dir, module_name, self._version)
os.makedirs(module_dir)
module_prefix = '%s-%s' % (module_name, self._version)
aar_dir = tempfile.mkdtemp()
shutil.copyfile(aar_jar, os.path.join(aar_dir, 'classes.jar'))
open(os.path.join(aar_dir, 'public.txt'), 'a').close()
shutil.copy(ANDROID_MANIFEST, aar_dir)
manifest = fileinput.FileInput(os.path.join(aar_dir, 'AndroidManifest.xml'),
inplace=True)
for line in manifest:
print line.replace('org.dummy', 'org.chromium.net'),
if aar_proguard_config:
aar_proguard_config = os.path.join(self._build_dir, aar_proguard_config)
shutil.copyfile(aar_proguard_config, os.path.join(aar_dir,
'proguard.txt'))
if aar_native_lib:
for arch in ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']:
lib_dir = os.path.join(aar_dir, 'jni', arch)
os.makedirs(lib_dir)
shutil.copyfile(os.path.join(self._build_dir, 'libs', arch,
aar_native_lib),
os.path.join(lib_dir, aar_native_lib))
with open(os.path.join(aar_dir, 'R.txt'), 'a') as r_file:
if include_keep_resource:
r_file.write('int raw keep_cronet_api 0x7f020000\n')
res_dir = os.path.join(aar_dir, 'res', 'raw')
os.makedirs(res_dir)
shutil.copy(KEEP_RESOURCE, res_dir)
zipdir(aar_dir, os.path.join(module_dir, '%s.aar' % module_prefix))
shutil.rmtree(aar_dir)
shutil.copyfile(aar_jar.replace('.jar', '-src.jar'),
os.path.join(module_dir, '%s-sources.jar' % module_prefix))
pom_template = os.path.join(REPOSITORY_ROOT, 'components', 'cronet',
'android', 'maven',
'%s.pom.template' % module_name)
pom_file = os.path.join(module_dir, '%s.pom' % module_prefix)
if os.system('%s -f %s -i %s -o %s' % (VERSION_SCRIPT, self._version_file,
pom_template, pom_file)):
sys.stderr.write('version.py failed.')
exit(1)
if self._suffix != '':
pom_file = fileinput.FileInput(pom_file, inplace=True)
for line in pom_file:
print line.replace('%s</version>' % self._version_without_suffix,
'%s</version>' % self._version),
if include_javadocs:
javadoc_dir = os.path.join(self._build_dir, 'javadoc')
# 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(javadoc_dir, 'reference', 'index.html'), 'r') as \
old_index, open(os.path.join(javadoc_dir, 'index.html'), 'w') as \
new_index:
for line in old_index:
new_index.write(line.replace('classes.html',
'reference/classes.html'))
zipdir(javadoc_dir, os.path.join(module_dir,
'%s-javadoc.jar' % module_prefix))
def main():
parser = optparse.OptionParser()
parser.add_option('--version',
help='Version of Cronet to download (e.g. 66.0.3359.126).')
parser.add_option('--suffix',
help='The suffix to add. Must be alpha or beta.')
options, _ = parser.parse_args()
if not options.version:
parser.error('Version not provided.')
suffix = options.suffix
if suffix:
if suffix != 'alpha' and suffix != 'beta':
parser.error('Suffix must be alpha or beta')
suffix = '-%s' % suffix
else:
suffix = ''
work_dir = tempfile.mkdtemp()
if os.system(
'cd %s && gsutil -m cp -R gs://chromium-cronet/android/%s/Release .'
% (work_dir, options.version)):
sys.stderr.write('Google cloud storage download failed.')
exit(1)
module_builder = ModuleBuilder(work_dir, options.version, suffix)
module_builder.make_module(
module_name="cronet-api",
aar_jar="cronet_api.jar",
include_javadocs=True,
include_keep_resource=True,
)
module_builder.make_module(
module_name="cronet-common",
aar_jar="cronet_impl_common_java.jar",
aar_proguard_config="cronet_impl_common_proguard.cfg",
)
module_builder.make_module(
module_name="cronet-embedded",
aar_jar="cronet_impl_native_java.jar",
aar_proguard_config="cronet_impl_native_proguard.cfg",
aar_native_lib="libcronet.%s.so" % options.version
)
module_builder.make_module(
module_name="cronet-fallback",
aar_jar="cronet_impl_platform_java.jar",
aar_proguard_config="cronet_impl_platform_proguard.cfg"
)
shutil.rmtree(os.path.join(work_dir, 'Release'))
print 'Maven modules in: %s' % work_dir
if __name__ == '__main__':
main()
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