xref: /aosp_15_r20/build/soong/java/plugin.go (revision 333d2b3687b3a337dbcca9d65000bca186795e39)
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
15package java
16
17import (
18	"android/soong/android"
19)
20
21func init() {
22	registerJavaPluginBuildComponents(android.InitRegistrationContext)
23}
24
25func registerJavaPluginBuildComponents(ctx android.RegistrationContext) {
26	ctx.RegisterModuleType("java_plugin", PluginFactory)
27	ctx.RegisterModuleType("kotlin_plugin", KotlinPluginFactory)
28}
29
30func PluginFactory() android.Module {
31	module := &Plugin{}
32
33	module.addHostProperties()
34	module.AddProperties(&module.pluginProperties)
35
36	InitJavaModule(module, android.HostSupported)
37
38	return module
39}
40
41func KotlinPluginFactory() android.Module {
42	module := &KotlinPlugin{}
43
44	module.addHostProperties()
45
46	InitJavaModule(module, android.HostSupported)
47
48	return module
49}
50
51// Plugin describes a java_plugin module, a host java library that will be used by javac as an annotation processor.
52type 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}
67
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}
72