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