diff options
author | Colin Cross <ccross@android.com> | 2020-06-19 05:52:55 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-19 05:52:55 +0000 |
commit | 160c53955ea1b17f87cc77bf433acb220a556341 (patch) | |
tree | ca4afc3cdb8f94e616df4a7d19ee5f5333f82961 | |
parent | b5645b299dc827248e8d5b05cc26a04cdbeb360d (diff) | |
parent | 0d08709b7174035ecaf3a81660ccf6ee2019c5dd (diff) | |
download | google-java-format-160c53955ea1b17f87cc77bf433acb220a556341.tar.gz |
Add Android files for google-java-format am: 7aef6bcfd3 am: 0d08709b71r_aml_301500702android-mainline-12.0.0_r55android-mainline-11.0.0_r9android-mainline-11.0.0_r8android-mainline-11.0.0_r7android-mainline-11.0.0_r6android-mainline-11.0.0_r5android-mainline-11.0.0_r45android-mainline-11.0.0_r44android-mainline-11.0.0_r43android-mainline-11.0.0_r42android-mainline-11.0.0_r41android-mainline-11.0.0_r40android-mainline-11.0.0_r4android-mainline-11.0.0_r39android-mainline-11.0.0_r38android-mainline-11.0.0_r37android-mainline-11.0.0_r36android-mainline-11.0.0_r35android-mainline-11.0.0_r34android-mainline-11.0.0_r33android-mainline-11.0.0_r32android-mainline-11.0.0_r31android-mainline-11.0.0_r30android-mainline-11.0.0_r3android-mainline-11.0.0_r29android-mainline-11.0.0_r28android-mainline-11.0.0_r27android-mainline-11.0.0_r26android-mainline-11.0.0_r25android-mainline-11.0.0_r24android-mainline-11.0.0_r23android-mainline-11.0.0_r22android-mainline-11.0.0_r21android-mainline-11.0.0_r20android-mainline-11.0.0_r19android-mainline-11.0.0_r18android-mainline-11.0.0_r17android-mainline-11.0.0_r16android-mainline-11.0.0_r15android-mainline-11.0.0_r14android-mainline-11.0.0_r13android-mainline-11.0.0_r12android-mainline-11.0.0_r10android11-mainline-tethering-releaseandroid11-mainline-sparse-2021-jan-releaseandroid11-mainline-sparse-2020-dec-releaseandroid11-mainline-releaseandroid11-mainline-permission-releaseandroid11-mainline-os-statsd-releaseandroid11-mainline-networkstack-releaseandroid11-mainline-media-swcodec-releaseandroid11-mainline-media-releaseandroid11-mainline-extservices-releaseandroid11-mainline-documentsui-releaseandroid11-mainline-conscrypt-releaseandroid11-mainline-cellbroadcast-releaseandroid11-mainline-captiveportallogin-release
Original change: https://android-review.googlesource.com/c/platform/external/google-java-format/+/1342208
Change-Id: I2e16bfc65793e48dac731c7d4c61b8b2fc013f6a
-rw-r--r-- | Android.bp | 56 | ||||
-rw-r--r-- | METADATA | 17 | ||||
-rw-r--r-- | MODULE_LICENSE_APACHE2 | 0 | ||||
-rwxr-xr-x | android-annotation-stubs/gen_annotations.sh | 15 | ||||
-rw-r--r-- | android-annotation-stubs/src/org/checkerframework/checker/nullness/qual/Nullable.java | 39 | ||||
-rw-r--r-- | android-annotation-stubs/tmpl.java | 39 |
6 files changed, 166 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp new file mode 100644 index 0000000..b5cc060 --- /dev/null +++ b/Android.bp @@ -0,0 +1,56 @@ +java_library_host { + name: "google_java_format_android_annotation_stubs", + srcs: ["android-annotation-stubs/src/**/*.java"], +} + +filegroup { + name: "google_java_format_main_srcs", + srcs: [ + "core/src/main/java/com/google/googlejavaformat/java/Main.java", + "core/src/main/java/com/google/googlejavaformat/java/UsageException.java", + ], +} + +java_library_host { + name: "google_java_format", + srcs: ["core/src/main/java/**/*.java"], + exclude_srcs: [ + ":google_java_format_main_srcs", + "core/src/main/java/com/google/googlejavaformat/java/java14/Java14InputAstVisitor.java", + ], + libs: [ + "error_prone_annotations", + "google_java_format_android_annotation_stubs", + "guava", + ], + javacflags: [ + "--add-modules=jdk.compiler", + "--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ], +} + +java_library_host { + name: "google_java_format_filer", + srcs: ["core/src/main/java/filer/*.java"], + libs: [ + "error_prone_annotations", + "google_java_format_android_annotation_stubs", + "guava", + ], + javacflags: [ + "--add-modules=jdk.compiler", + "--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ], +} diff --git a/METADATA b/METADATA new file mode 100644 index 0000000..dc78f17 --- /dev/null +++ b/METADATA @@ -0,0 +1,17 @@ +name: "google-java-format" +description: + "Reformats Java source code to comply with Google Java Style." + +third_party { + url { + type: HOMEPAGE + value: "https://github.com/google/google-java-format" + } + url { + type: GIT + value: "https://github.com/google/google-java-format" + } + version: "google-java-format-1.8" + last_upgrade_date { year: 2020 month: 6 day: 12 } + license_type: NOTICE +} diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/MODULE_LICENSE_APACHE2 diff --git a/android-annotation-stubs/gen_annotations.sh b/android-annotation-stubs/gen_annotations.sh new file mode 100755 index 0000000..5af699a --- /dev/null +++ b/android-annotation-stubs/gen_annotations.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +ANNOTATIONS=( + org.checkerframework.checker.nullness.qual.Nullable +) + +for a in ${ANNOTATIONS[@]}; do + package=${a%.*} + class=${a##*.} + dir=$(dirname $0)/src/${package//.//} + file=${class}.java + + mkdir -p ${dir} + sed -e"s/__PACKAGE__/${package}/" -e"s/__CLASS__/${class}/" tmpl.java > ${dir}/${file} +done diff --git a/android-annotation-stubs/src/org/checkerframework/checker/nullness/qual/Nullable.java b/android-annotation-stubs/src/org/checkerframework/checker/nullness/qual/Nullable.java new file mode 100644 index 0000000..21e2cb9 --- /dev/null +++ b/android-annotation-stubs/src/org/checkerframework/checker/nullness/qual/Nullable.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.checkerframework.checker.nullness.qual; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/* This is an annotation stub to avoid dependencies on annotations that aren't + * in the Android platform source tree. */ + +@Target({ + ElementType.ANNOTATION_TYPE, + ElementType.CONSTRUCTOR, + ElementType.FIELD, + ElementType.LOCAL_VARIABLE, + ElementType.METHOD, + ElementType.PACKAGE, + ElementType.PARAMETER, + ElementType.TYPE, + ElementType.TYPE_PARAMETER, + ElementType.TYPE_USE}) +@Retention(RetentionPolicy.SOURCE) +public @interface Nullable {} diff --git a/android-annotation-stubs/tmpl.java b/android-annotation-stubs/tmpl.java new file mode 100644 index 0000000..814c143 --- /dev/null +++ b/android-annotation-stubs/tmpl.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package __PACKAGE__; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/* This is an annotation stub to avoid dependencies on annotations that aren't + * in the Android platform source tree. */ + +@Target({ + ElementType.ANNOTATION_TYPE, + ElementType.CONSTRUCTOR, + ElementType.FIELD, + ElementType.LOCAL_VARIABLE, + ElementType.METHOD, + ElementType.PACKAGE, + ElementType.PARAMETER, + ElementType.TYPE, + ElementType.TYPE_PARAMETER, + ElementType.TYPE_USE}) +@Retention(RetentionPolicy.SOURCE) +public @interface __CLASS__ {} |