Skip to content

Commit e064f64

Browse files
authored
docs: write documentation for shipping plugin (#179)
1 parent de48ff1 commit e064f64

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

docs/en/latest/writing-filters.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919

2020
# Overview
2121

22-
This document explains how to develop Java plugins using apisix-java-plugin-runner's official Maven release.
22+
This document explains how to develop and ship Java plugins using apisix-java-plugin-runner's official Maven release.
2323

2424
A Demo Project can be found at: https://github.com/tzssangglass/java-plugin-runner-demo-1
2525

2626
___
2727

28+
### Write Java plugin
29+
2830
Create a new Maven Spring Boot Project.
2931

3032
Add the GAV of `apisix-java-plugin-runner` in `pom.xml`.
@@ -152,6 +154,23 @@ socket.file = /tmp/runner.sock
152154
```
153155
This allows our java-plugin-runner to communicate with the main APISIX process.
154156

155-
Finally, build your Java plugin! Be sure to label each filter class as a Spring *@Component* while following the guide at:
157+
Build your Java plugin! Be sure to label each filter class as a Spring *@Component* while following the guide at:
156158
https://github.com/apache/apisix-java-plugin-runner/blob/main/docs/en/latest/development.md
157159

160+
### Ship plugin
161+
162+
In your plugin's *pom.xml*, add
163+
```
164+
<configuration>
165+
<classifier>exec</classifier>
166+
</configuration>
167+
```
168+
169+
The standard Spring Boot executable JAR places all of your application classes inside *BOOT-INF/classes*, making it impossible to inject into another project. This config builds an additional non-executable JAR that can be used for dependency injection.
170+
171+
Deploy the JARs to Maven Central.
172+
173+
### Using a deployed plugin
174+
175+
To use someone else's plugin, add their plugin's non-executable JAR as a dependency in your project. Add the package name of their filters (usually the same as the Group ID) in *scanBasePackages* in your main SpringBootApplication class to allow Spring to find the plugin *@Component*.
176+

0 commit comments

Comments
 (0)