Colin Cross | 8d0c8f8 | 2020-06-17 20:23:44 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | declare -A INNER |
| 4 | declare -A PARAMETER |
| 5 | declare -A IMPORT |
| 6 | |
| 7 | ANNOTATIONS=( |
| 8 | net.ltgt.gradle.incap.IncrementalAnnotationProcessor |
Colin Cross | a359f7e | 2022-03-04 22:42:06 -0800 | [diff] [blame] | 9 | org.checkerframework.checker.nullness.qual.Nullable |
Colin Cross | 8d0c8f8 | 2020-06-17 20:23:44 -0700 | [diff] [blame] | 10 | ) |
| 11 | |
| 12 | PARAMETER["net.ltgt.gradle.incap.IncrementalAnnotationProcessor"]="IncrementalAnnotationProcessorType" |
| 13 | IMPORT["net.ltgt.gradle.incap.IncrementalAnnotationProcessor"]="net.ltgt.gradle.incap.IncrementalAnnotationProcessorType" |
| 14 | |
| 15 | for a in ${ANNOTATIONS[@]}; do |
| 16 | package=${a%.*} |
| 17 | class=${a##*.} |
| 18 | dir=$(dirname $0)/src/${package//.//} |
| 19 | file=${class}.java |
| 20 | inner=${INNER[$a]} |
| 21 | parameter=${PARAMETER[$a]} |
| 22 | import= |
| 23 | |
| 24 | if [ -n "${parameter}" ]; then |
| 25 | parameter="${parameter} value();" |
| 26 | fi |
| 27 | |
| 28 | for i in ${IMPORT[$a]}; do |
| 29 | import="${import}import ${i};" |
| 30 | done |
| 31 | |
| 32 | mkdir -p ${dir} |
| 33 | sed -e"s/__PACKAGE__/${package}/" \ |
| 34 | -e"s/__CLASS__/${class}/" \ |
| 35 | -e"s/__INNER__/${inner}/" \ |
| 36 | -e"s/__PARAMETER__/${parameter}/" \ |
| 37 | -e"s/__IMPORT__/${import}/" \ |
| 38 | $(dirname $0)/tmpl.java > ${dir}/${file} |
| 39 | google-java-format -i ${dir}/${file} |
| 40 | done |
| 41 | |
| 42 | f=$(dirname $0)/src/net/ltgt/gradle/incap/IncrementalAnnotationProcessorType.java |
| 43 | cat > ${f} <<EOF |
| 44 | /* |
| 45 | * Copyright (C) 2019 The Android Open Source Project |
| 46 | * |
| 47 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 48 | * you may not use this file except in compliance with the License. |
| 49 | * You may obtain a copy of the License at |
| 50 | * |
| 51 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 52 | * |
| 53 | * Unless required by applicable law or agreed to in writing, software |
| 54 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 55 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 56 | * See the License for the specific language governing permissions and |
| 57 | * limitations under the License. |
| 58 | */ |
| 59 | |
| 60 | package net.ltgt.gradle.incap; |
| 61 | |
| 62 | import java.util.Locale; |
| 63 | |
| 64 | public enum IncrementalAnnotationProcessorType { |
| 65 | DYNAMIC, |
| 66 | ISOLATING, |
| 67 | AGGREGATING; |
| 68 | |
| 69 | public String getProcessorOption() { |
| 70 | return "org.gradle.annotation.processing." + name().toLowerCase(Locale.ROOT); |
| 71 | } |
| 72 | } |
| 73 | EOF |