• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3declare -A INNER
4declare -A PARAMETER
5declare -A IMPORT
6
7ANNOTATIONS=(
8    net.ltgt.gradle.incap.IncrementalAnnotationProcessor
9)
10
11PARAMETER["net.ltgt.gradle.incap.IncrementalAnnotationProcessor"]="IncrementalAnnotationProcessorType"
12IMPORT["net.ltgt.gradle.incap.IncrementalAnnotationProcessor"]="net.ltgt.gradle.incap.IncrementalAnnotationProcessorType"
13
14for 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}
39done
40
41f=$(dirname $0)/src/net/ltgt/gradle/incap/IncrementalAnnotationProcessorType.java
42cat > ${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
59package net.ltgt.gradle.incap;
60
61import java.util.Locale;
62
63public 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}
72EOF
73