1*333d2b36SAndroid Build Coastguard Worker// Copyright 2019 Google Inc. All rights reserved. 2*333d2b36SAndroid Build Coastguard Worker// 3*333d2b36SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 4*333d2b36SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 5*333d2b36SAndroid Build Coastguard Worker// You may obtain a copy of the License at 6*333d2b36SAndroid Build Coastguard Worker// 7*333d2b36SAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 8*333d2b36SAndroid Build Coastguard Worker// 9*333d2b36SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*333d2b36SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 11*333d2b36SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*333d2b36SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 13*333d2b36SAndroid Build Coastguard Worker// limitations under the License. 14*333d2b36SAndroid Build Coastguard Worker 15*333d2b36SAndroid Build Coastguard Workerpackage java 16*333d2b36SAndroid Build Coastguard Worker 17*333d2b36SAndroid Build Coastguard Workerimport ( 18*333d2b36SAndroid Build Coastguard Worker "android/soong/android" 19*333d2b36SAndroid Build Coastguard Worker) 20*333d2b36SAndroid Build Coastguard Worker 21*333d2b36SAndroid Build Coastguard Workerfunc init() { 22*333d2b36SAndroid Build Coastguard Worker registerJavaPluginBuildComponents(android.InitRegistrationContext) 23*333d2b36SAndroid Build Coastguard Worker} 24*333d2b36SAndroid Build Coastguard Worker 25*333d2b36SAndroid Build Coastguard Workerfunc registerJavaPluginBuildComponents(ctx android.RegistrationContext) { 26*333d2b36SAndroid Build Coastguard Worker ctx.RegisterModuleType("java_plugin", PluginFactory) 27*333d2b36SAndroid Build Coastguard Worker ctx.RegisterModuleType("kotlin_plugin", KotlinPluginFactory) 28*333d2b36SAndroid Build Coastguard Worker} 29*333d2b36SAndroid Build Coastguard Worker 30*333d2b36SAndroid Build Coastguard Workerfunc PluginFactory() android.Module { 31*333d2b36SAndroid Build Coastguard Worker module := &Plugin{} 32*333d2b36SAndroid Build Coastguard Worker 33*333d2b36SAndroid Build Coastguard Worker module.addHostProperties() 34*333d2b36SAndroid Build Coastguard Worker module.AddProperties(&module.pluginProperties) 35*333d2b36SAndroid Build Coastguard Worker 36*333d2b36SAndroid Build Coastguard Worker InitJavaModule(module, android.HostSupported) 37*333d2b36SAndroid Build Coastguard Worker 38*333d2b36SAndroid Build Coastguard Worker return module 39*333d2b36SAndroid Build Coastguard Worker} 40*333d2b36SAndroid Build Coastguard Worker 41*333d2b36SAndroid Build Coastguard Workerfunc KotlinPluginFactory() android.Module { 42*333d2b36SAndroid Build Coastguard Worker module := &KotlinPlugin{} 43*333d2b36SAndroid Build Coastguard Worker 44*333d2b36SAndroid Build Coastguard Worker module.addHostProperties() 45*333d2b36SAndroid Build Coastguard Worker 46*333d2b36SAndroid Build Coastguard Worker InitJavaModule(module, android.HostSupported) 47*333d2b36SAndroid Build Coastguard Worker 48*333d2b36SAndroid Build Coastguard Worker return module 49*333d2b36SAndroid Build Coastguard Worker} 50*333d2b36SAndroid Build Coastguard Worker 51*333d2b36SAndroid Build Coastguard Worker// Plugin describes a java_plugin module, a host java library that will be used by javac as an annotation processor. 52*333d2b36SAndroid Build Coastguard Workertype Plugin struct { 53*333d2b36SAndroid Build Coastguard Worker Library 54*333d2b36SAndroid Build Coastguard Worker 55*333d2b36SAndroid Build Coastguard Worker pluginProperties PluginProperties 56*333d2b36SAndroid Build Coastguard Worker} 57*333d2b36SAndroid Build Coastguard Worker 58*333d2b36SAndroid Build Coastguard Workertype PluginProperties struct { 59*333d2b36SAndroid Build Coastguard Worker // The optional name of the class that javac will use to run the annotation processor. 60*333d2b36SAndroid Build Coastguard Worker Processor_class *string 61*333d2b36SAndroid Build Coastguard Worker 62*333d2b36SAndroid Build Coastguard Worker // If true, assume the annotation processor will generate classes that are referenced from outside the module. 63*333d2b36SAndroid Build Coastguard Worker // This necessitates disabling the turbine optimization on modules that use this plugin, which will reduce 64*333d2b36SAndroid Build Coastguard Worker // parallelism and cause more recompilation for modules that depend on modules that use this plugin. 65*333d2b36SAndroid Build Coastguard Worker Generates_api *bool 66*333d2b36SAndroid Build Coastguard Worker} 67*333d2b36SAndroid Build Coastguard Worker 68*333d2b36SAndroid Build Coastguard Worker// Plugin describes a kotlin_plugin module, a host java/kotlin library that will be used by kotlinc as a compiler plugin. 69*333d2b36SAndroid Build Coastguard Workertype KotlinPlugin struct { 70*333d2b36SAndroid Build Coastguard Worker Library 71*333d2b36SAndroid Build Coastguard Worker} 72