blob: 4766af97efb02f86e39fa681c406e1e056932878 [file] [log] [blame]
Colin Cross8d0c8f82020-06-17 20:23:44 -07001#!/bin/bash
2
3declare -A INNER
4declare -A PARAMETER
5declare -A IMPORT
6
7ANNOTATIONS=(
8 net.ltgt.gradle.incap.IncrementalAnnotationProcessor
Colin Crossa359f7e2022-03-04 22:42:06 -08009 org.checkerframework.checker.nullness.qual.Nullable
Colin Cross8d0c8f82020-06-17 20:23:44 -070010)
11
12PARAMETER["net.ltgt.gradle.incap.IncrementalAnnotationProcessor"]="IncrementalAnnotationProcessorType"
13IMPORT["net.ltgt.gradle.incap.IncrementalAnnotationProcessor"]="net.ltgt.gradle.incap.IncrementalAnnotationProcessorType"
14
15for 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}
40done
41
42f=$(dirname $0)/src/net/ltgt/gradle/incap/IncrementalAnnotationProcessorType.java
43cat > ${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
60package net.ltgt.gradle.incap;
61
62import java.util.Locale;
63
64public 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}
73EOF