Update generate_gradle.py to support Java 8.
Adds support for Java 8 using Desugar. Android Studio 3.0 is required for Desugar. enforceUniquePackageName is no longer needed by the new gradle version. This feature is behind "--canary" flag for now. Bug: webrtc:8084, chromium:730711 Change-Id: Iba24880fef303aa627307356f2e26b78e153a960 Reviewed-on: https://chromium-review.googlesource.com/609066 Reviewed-by: Peter Wen <wnwen@chromium.org> Commit-Queue: Sami Kalliomäki <sakal@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#493418} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 8f75411b306ddbb870d85c39dc03024b7bd5ec74
This commit is contained in:
Родитель
ac4744f4b0
Коммит
fbfaa84241
|
@ -50,12 +50,19 @@ android {
|
|||
compileSdkVersion "{{ compile_sdk_version }}"
|
||||
buildToolsVersion "{{ build_tools_version }}"
|
||||
publishNonDefault true
|
||||
{% if not canary %}
|
||||
// Multiple targets use the package name "org.dummy"
|
||||
enforceUniquePackageName false
|
||||
{% endif %}
|
||||
|
||||
compileOptions {
|
||||
{% if canary %}
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
{% else %}
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
{% endif %}
|
||||
{% if variables.android_project_deps is defined %}
|
||||
{% for proj in variables.android_project_deps %}
|
||||
{% if canary %}
|
||||
{{ prefix }} project(path: ":{{ proj }}")
|
||||
{% else %}
|
||||
{{ prefix }} project(path: ":{{ proj }}", configuration: "debug")
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -246,12 +246,13 @@ class _ProjectEntry(object):
|
|||
class _ProjectContextGenerator(object):
|
||||
"""Helper class to generate gradle build files"""
|
||||
def __init__(self, project_dir, build_vars, use_gradle_process_resources,
|
||||
jinja_processor, split_projects):
|
||||
jinja_processor, split_projects, canary):
|
||||
self.project_dir = project_dir
|
||||
self.build_vars = build_vars
|
||||
self.use_gradle_process_resources = use_gradle_process_resources
|
||||
self.jinja_processor = jinja_processor
|
||||
self.split_projects = split_projects
|
||||
self.canary = canary
|
||||
self.processed_java_dirs = set()
|
||||
self.processed_prebuilts = set()
|
||||
self.processed_res_dirs = set()
|
||||
|
@ -504,6 +505,7 @@ def _GenerateBaseVars(generator, build_vars, source_properties):
|
|||
'android-%s' % build_vars['android_sdk_version'])
|
||||
variables['use_gradle_process_resources'] = (
|
||||
generator.use_gradle_process_resources)
|
||||
variables['canary'] = generator.canary
|
||||
return variables
|
||||
|
||||
|
||||
|
@ -593,9 +595,9 @@ def _GenerateModuleAll(gradle_output_dir, generator, build_vars,
|
|||
os.path.join(gradle_output_dir, _MODULE_ALL, _GRADLE_BUILD_FILE), data)
|
||||
|
||||
|
||||
def _GenerateRootGradle(jinja_processor):
|
||||
def _GenerateRootGradle(jinja_processor, canary):
|
||||
"""Returns the data for the root project's build.gradle."""
|
||||
return jinja_processor.Render(_TemplatePath('root'))
|
||||
return jinja_processor.Render(_TemplatePath('root'), {'canary': canary})
|
||||
|
||||
|
||||
def _GenerateSettingsGradle(project_entries, add_all_module):
|
||||
|
@ -713,6 +715,10 @@ def main():
|
|||
action='store_true',
|
||||
help='Split projects by their gn deps rather than '
|
||||
'combining all the dependencies of each target')
|
||||
parser.add_argument('--canary',
|
||||
action='store_true',
|
||||
help='Generate a project that is compatible with '
|
||||
'Android Studio 3.0 Canary.')
|
||||
args = parser.parse_args()
|
||||
if args.output_directory:
|
||||
constants.SetOutputDirectory(args.output_directory)
|
||||
|
@ -733,7 +739,8 @@ def main():
|
|||
_RebasePath(os.path.join(build_vars['android_sdk_build_tools'],
|
||||
'source.properties')))
|
||||
generator = _ProjectContextGenerator(_gradle_output_dir, build_vars,
|
||||
args.use_gradle_process_resources, jinja_processor, args.split_projects)
|
||||
args.use_gradle_process_resources, jinja_processor, args.split_projects,
|
||||
args.canary)
|
||||
logging.warning('Creating project at: %s', generator.project_dir)
|
||||
|
||||
if args.all:
|
||||
|
@ -801,7 +808,7 @@ def main():
|
|||
source_properties, jinja_processor)
|
||||
|
||||
_WriteFile(os.path.join(generator.project_dir, _GRADLE_BUILD_FILE),
|
||||
_GenerateRootGradle(jinja_processor))
|
||||
_GenerateRootGradle(jinja_processor, args.canary))
|
||||
|
||||
_WriteFile(os.path.join(generator.project_dir, 'settings.gradle'),
|
||||
_GenerateSettingsGradle(project_entries, add_all_module))
|
||||
|
@ -819,7 +826,9 @@ def main():
|
|||
_ExtractZips(generator.project_dir, zip_tuples)
|
||||
|
||||
logging.warning('Project created!')
|
||||
logging.warning('Generated projects work with Android Studio 2.3')
|
||||
logging.warning('Generated projects work with %s',
|
||||
'Android Studio 3.0 Canary 9' if args.canary
|
||||
else 'Android Studio 2.3')
|
||||
logging.warning('For more tips: https://chromium.googlesource.com/chromium'
|
||||
'/src.git/+/master/docs/android_studio.md')
|
||||
|
||||
|
|
|
@ -18,8 +18,13 @@ sourceSets {
|
|||
}
|
||||
}
|
||||
|
||||
{% if canary %}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
{% else %}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
{% endif %}
|
||||
|
||||
{% if template_type == 'java_binary' %}
|
||||
mainClassName = "{{ main_class }}"
|
||||
|
|
|
@ -6,8 +6,17 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
{% if canary %}
|
||||
maven {
|
||||
url 'https://maven.google.com'
|
||||
}
|
||||
{% endif %}
|
||||
}
|
||||
dependencies {
|
||||
{% if canary %}
|
||||
classpath "com.android.tools.build:gradle:3.0.0-beta1"
|
||||
{% else %}
|
||||
classpath "com.android.tools.build:gradle:2.3.3"
|
||||
{% endif %}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче