blob: 610c9fd11d6da623a6c2315aea551e1b67fef2ff [file] [log] [blame]
Colin Crossbe9cdb82019-01-21 21:37:16 -08001// 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
15package java
16
Sam Delmericoc06ea032022-01-28 21:11:03 +000017import (
18 "android/soong/android"
Sam Delmericoc06ea032022-01-28 21:11:03 +000019)
Colin Crossbe9cdb82019-01-21 21:37:16 -080020
21func init() {
Paul Duffinc029c432021-03-22 15:00:28 +000022 registerJavaPluginBuildComponents(android.InitRegistrationContext)
23}
24
25func registerJavaPluginBuildComponents(ctx android.RegistrationContext) {
26 ctx.RegisterModuleType("java_plugin", PluginFactory)
Luca Stefani50098f72024-10-12 17:55:31 +020027 ctx.RegisterModuleType("kotlin_plugin", KotlinPluginFactory)
Colin Crossbe9cdb82019-01-21 21:37:16 -080028}
29
Colin Crossbe9cdb82019-01-21 21:37:16 -080030func PluginFactory() android.Module {
31 module := &Plugin{}
32
Colin Crossce6734e2020-06-15 16:09:53 -070033 module.addHostProperties()
34 module.AddProperties(&module.pluginProperties)
Colin Crossbe9cdb82019-01-21 21:37:16 -080035
36 InitJavaModule(module, android.HostSupported)
Sam Delmericoc06ea032022-01-28 21:11:03 +000037
Colin Crossbe9cdb82019-01-21 21:37:16 -080038 return module
39}
40
Luca Stefani50098f72024-10-12 17:55:31 +020041func KotlinPluginFactory() android.Module {
42 module := &KotlinPlugin{}
43
44 module.addHostProperties()
45
46 InitJavaModule(module, android.HostSupported)
47
48 return module
49}
50
Sam Delmericoc06ea032022-01-28 21:11:03 +000051// Plugin describes a java_plugin module, a host java library that will be used by javac as an annotation processor.
Colin Crossbe9cdb82019-01-21 21:37:16 -080052type Plugin struct {
53 Library
54
55 pluginProperties PluginProperties
56}
57
58type 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 Stefani50098f72024-10-12 17:55:31 +020067
68// Plugin describes a kotlin_plugin module, a host java/kotlin library that will be used by kotlinc as a compiler plugin.
69type KotlinPlugin struct {
70 Library
71}