Skip to content

Commit 7314e20

Browse files
committed
Added the function parameter to the deploy-functions mojo and removed add-server-function and add-client-function mojos.
1 parent 0e29496 commit 7314e20

25 files changed

+121
-600
lines changed

README.md

Lines changed: 22 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Java Client Library (beta)
22

3-
### Latest snapshot version v0.5.0-SNAPSHOT
4-
### Latest released version v0.4.2
3+
### Latest snapshot version v0.6.0-SNAPSHOT
4+
### Latest released version v0.5.0
55

66
## Introduction
77
Welcome my friends! This is the Poly API Java client GitHub page. If you are here, then it means you're familiar with what we do at Poly. If you aren't, you can always check [here](https://github.com/polyapi/poly-alpha).
@@ -55,7 +55,7 @@ Nice to have some customers looking around here! So, you'll need to run the foll
5555
2. **Update the project.** Add the following to your project's `pom.xml`:
5656
```xml
5757
<properties>
58-
<poly.version>0.3.3</poly.version>
58+
<poly.version>0.5.0</poly.version>
5959
</properties>
6060
<dependencies>
6161
<dependency>
@@ -76,16 +76,16 @@ Nice to have some customers looking around here! So, you'll need to run the foll
7676
<artifactId>polyapi-maven-plugin</artifactId>
7777
<version>${poly.version}</version>
7878
<executions>
79-
<configuration>
80-
<host>https://develop-k8s.polyapi.io</host>
81-
<port>443</port>
82-
<apiKey>{API_KEY}</apiKey>
83-
</configuration>
8479
<execution>
8580
<phase>generate-sources</phase>
8681
<goals>
8782
<goal>generate-sources</goal>
8883
</goals>
84+
<configuration>
85+
<host>https://develop-k8s.polyapi.io</host>
86+
<port>443</port>
87+
<apiKey>{API_KEY}</apiKey>
88+
</configuration>
8989
</execution>
9090
</executions>
9191
</plugin>
@@ -184,32 +184,6 @@ One of the key classes in this library is the proxy factory. As most of the gene
184184
### Maven plugin
185185
This maven plugin provides the following MOJOs:
186186

187-
#### add-server-function
188-
This MOJO adds a server function to the Poly Server. Poly Server functions are functions that are run in the Poly server.
189-
190-
##### Parameters
191-
Here's the list of parameters:
192-
- **host (required):** The host where the Poly API instance is hosted.
193-
- **port:** The port that the Poly API instance is listening to. Default value is 443.
194-
- **apiKey (required):** The API key required to authenticate to Poly.
195-
- **file (required):** The relative path to the file that contains the function to be uploaded.
196-
- **functionName (required):** The name of the method to be converted into the function to be uploaded.
197-
- **context:** The context where the function will be hosted. When generating the function interface, this will influence the package name.
198-
- **description:** The description of the function.
199-
200-
#### add-client-function
201-
This MOJO adds a client function to the Poly Server. Poly Client functions are functions that, although are stored in the Server, are ultimately executed in the client.
202-
203-
##### Parameters
204-
Here's the list of parameters:
205-
- **host (required):** The host where the Poly API instance is hosted.
206-
- **port:** The port that the Poly API instance is listening to. Default value is 443.
207-
- **apiKey (required):** The API key required to authenticate to Poly.
208-
- **file (required):** The relative path to the file that contains the function to be uploaded.
209-
- **functionName (required):** The name of the method to be converted into the function to be uploaded.
210-
- **context:** The context where the function will be hosted. When generating the function interface, this will influence the package name.
211-
- **description:** The description of the function.
212-
213187
#### generate-sources
214188
This MOJO generates all the sources for a determined API key into the `target/generated-sources` folder.
215189

@@ -250,6 +224,7 @@ Here's the list of parameters:
250224
- **host (required):** The host where the Poly API instance is hosted.
251225
- **port:** The port that the Poly API instance is listening to. Default value is 443.
252226
- **apiKey (required):** The API key required to authenticate to Poly.
227+
- **functions:** Comma separated value containing the names of the functions to deploy. The functions must be annotated with the `@PolyFunction` annotation as it is described. This parameter triggers a filter by function name and/or context + function name in the `[context].[functionName]` format. Each comma separated value will be taken independently and deployed.
253228

254229
<a name="project-usage"></a>
255230
## Usage
@@ -305,63 +280,33 @@ Vari.auth.clientId.onUpdate((event) -> {
305280
});
306281
```
307282

308-
### Custom functions
309-
It is possible to create custom functions that can be used in Poly. To do so, you need to create a class with desired function. For example:
283+
### Poly server functions
284+
It is possible to deploy server functions that can be used in Poly. To do so, you need to create a class with desired function. For example:
310285
```java
311286
public class CustomFunction {
312287
public String sayHello(String name) {
313288
return "Hello " + name;
314289
}
315290
}
316291
```
317-
318-
Then there are 2 approaches:
319-
320-
#### Manual approach
321-
In this approach, you will use the `add-client-function` goals of the PolyAPI maven plugin.
322-
323-
Just run:
324-
```bash
325-
mvn polyapi:add-client-function -Dname=sayHello -Dfile="src/main/java/custom/CustomFunction.java" -Dcontext="test.client" -Dclient -Ddescription="This says hello to you"
326-
```
327-
This will add the function with specified name and context to Poly, so it can be used in code:
328-
329-
```java
330-
var result = Poly.test.client.sayHello("John");
331-
System.out.println(result);
332-
```
333-
334-
#### Annotation approach
335-
This approach requires that you have a setup project. In this project, you need to have the PolyAPI commons library installed as a dependency.
292+
Then, it is required that you have a setup project. In this project, you need to have the PolyAPI commons library installed as a dependency.
336293
```xml
337294
<dependency>
338295
<groupId>io.polyapi</groupId>
339296
<artifactId>commons</artifactId>
340297
<version>${poly.version}</version>
341298
</dependency>
342299
```
343-
Then annotate the function you want to upload with `@PolyFunction`. Have in mind that to mark this as a custom function (or client function) you need to set the property `polyType` in the annotation to `CLIENT`, leaving the annotation something like:
344-
```java
345-
@PolyFunction(polyType = FunctionType.CLIENT)
346-
```
347-
Then, just run:
300+
Then, annotate the function you want to upload with `@PolyFunction`.
301+
And finally, just run:
348302
```bash
349303
mvn polyapi:deploy-functions
350304
```
351-
### Server Functions
352-
Similar to Custom Functions, you can create Server Functions. To do so, you need to create a class with desired function same as with Custom Functions.
353-
Then to add it to Poly, there are the same 2 approaches:
354-
355-
#### Manual approach
356-
In here instead of using the `add-client-function` goal, you use the `add-server-function` one:
357-
```bash
358-
mvn polyapi:add-server-function -Dname=sayHello -Dfile="src/main/java/custom/CustomFunction.java" -Dcontext="test.server" -Ddescription="This says hello to you from server"
305+
### Poly client functions
306+
To create a Poly client Function you need to follow the same steps as with a server function, but when adding the `@PolyFunction` annotation, you need to set the property `polyType` in the annotation to `CLIENT`, leaving the annotation something like:
307+
```java
308+
@PolyFunction(polyType = FunctionType.CLIENT)
359309
```
360-
Otherwise it's the same as in the client functions.
361-
362-
#### Annotation approach
363-
This is the same as the client functions, but you don't need to set the `polyType` property in the annotation. By default it will assume its a server function.
364-
365310
## Limitations
366311
Comparing to its Typescript counterpart, the Java library is still missing the following features:
367312
- Error handlers
@@ -370,6 +315,10 @@ Comparing to its Typescript counterpart, the Java library is still missing the f
370315
These features will be added in the future releases.
371316

372317
## Changelog
318+
### v0.6.0
319+
- Removed add-server-function MOJO. Now only deploy-functions is allowed.
320+
- Removed add-client-function MOJO. Now only deploy-functions is allowed.
321+
- Added functions parameter to deploy-functions.
373322
### v0.5.0
374323
- Changed packages of generated classes to avoid classes with the same name and package but different attributes to override each other.
375324
- Changed names of schema generated classes to use the schema title.

commons/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.polyapi</groupId>
66
<artifactId>parent-pom</artifactId>
7-
<version>0.5.1-SNAPSHOT</version>
7+
<version>0.6.0-SNAPSHOT</version>
88
<relativePath>../parent-pom</relativePath>
99
</parent>
1010

library/pom.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.polyapi</groupId>
66
<artifactId>parent-pom</artifactId>
7-
<version>0.5.1-SNAPSHOT</version>
7+
<version>0.6.0-SNAPSHOT</version>
88
<relativePath>../parent-pom</relativePath>
99
</parent>
1010
<artifactId>library</artifactId>
@@ -63,11 +63,6 @@
6363
<version>1.18.30</version>
6464
<scope>provided</scope>
6565
</dependency>
66-
<dependency>
67-
<groupId>com.github.javaparser</groupId>
68-
<artifactId>javaparser-symbol-solver-core</artifactId>
69-
<version>3.25.6</version>
70-
</dependency>
7166
<dependency>
7267
<groupId>com.google.code.gson</groupId>
7368
<artifactId>gson</artifactId>

parent-pom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>io.polyapi</groupId>
55
<artifactId>parent-pom</artifactId>
6-
<version>0.5.1-SNAPSHOT</version>
6+
<version>0.6.0-SNAPSHOT</version>
77
<packaging>pom</packaging>
88
<name>Poly API Java parent POM</name>
99
<url>https://polyapi.io</url>

polyapi-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.polyapi</groupId>
66
<artifactId>parent-pom</artifactId>
7-
<version>0.5.1-SNAPSHOT</version>
7+
<version>0.6.0-SNAPSHOT</version>
88
<relativePath>../parent-pom</relativePath>
99
</parent>
1010
<artifactId>polyapi-maven-plugin</artifactId>

polyapi-maven-plugin/src/main/java/io/polyapi/plugin/model/TypeData.java

Lines changed: 0 additions & 4 deletions
This file was deleted.

polyapi-maven-plugin/src/main/java/io/polyapi/plugin/model/function/PolyFunctionMetadata.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

polyapi-maven-plugin/src/main/java/io/polyapi/plugin/mojo/AddClientFunctionMojo.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

polyapi-maven-plugin/src/main/java/io/polyapi/plugin/mojo/AddFunctionMojo.java

Lines changed: 0 additions & 83 deletions
This file was deleted.

polyapi-maven-plugin/src/main/java/io/polyapi/plugin/mojo/AddServerFunctionMojo.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)