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