-
Notifications
You must be signed in to change notification settings - Fork 646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create modules in Java #9422
Create modules in Java #9422
Conversation
...-processor/src/main/java/io/dagger/annotation/processor/DaggerModuleAnnotationProcessor.java
Outdated
Show resolved
Hide resolved
...-processor/src/main/java/io/dagger/annotation/processor/DaggerModuleAnnotationProcessor.java
Outdated
Show resolved
Hide resolved
...-processor/src/main/java/io/dagger/annotation/processor/DaggerModuleAnnotationProcessor.java
Outdated
Show resolved
Hide resolved
sdk/java/dagger-java-sdk/src/main/java/io/dagger/module/Base.java
Outdated
Show resolved
Hide resolved
07a1fdd
to
2e13194
Compare
...-processor/src/main/java/io/dagger/annotation/processor/DaggerModuleAnnotationProcessor.java
Outdated
Show resolved
Hide resolved
sdk/java/dagger-java-sdk/src/main/java/io/dagger/client/Convert.java
Outdated
Show resolved
Hide resolved
sdk/java/dagger-java-sdk/src/main/java/io/dagger/client/Convert.java
Outdated
Show resolved
Hide resolved
2e13194
to
79a1793
Compare
I improved the primitive types support, they are both working for returning types and arguments. |
19eaedb
to
b996ee1
Compare
...-processor/src/main/java/io/dagger/annotation/processor/DaggerModuleAnnotationProcessor.java
Outdated
Show resolved
Hide resolved
ba383c2
to
67c9da9
Compare
...-processor/src/main/java/io/dagger/annotation/processor/DaggerModuleAnnotationProcessor.java
Outdated
Show resolved
Hide resolved
67c9da9
to
bce6fb9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks like a good start to me, just left some general integration points as comments.
Really not qualified to comment on any of the Java code - will trust you and @jcsirot on this 🎉
Would also like @helderco to take a look if possible, since he's more familiar with the process of how we've integrated with the other SDKs 🎉
// - dagger-codegen-maven-plugin: this plugin will be used to generate the SDK code, from the introspection file, | ||
// this means including the ability to call other projects (not part of the main dagger SDK) | ||
// - this plugin is only used to build the SDK, the user module doesn't need it | ||
// - dagger-java-annotation-processor: this will read dagger specific annotations (@Module, @Object, @Function) | ||
// and generate the entrypoint to register the module and invoke the functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this separation - I think this is actually the way we'd like to get all the SDKs to work eventually (see #7707).
...dagger-java-annotation-processor/src/test/resources/io/dagger/gen/entrypoint/entrypoint.java
Outdated
Show resolved
Hide resolved
sdk/java/dagger-codegen-maven-plugin/src/main/resources/schemas/schema-0.15.1.json
Outdated
Show resolved
Hide resolved
...-processor/src/main/java/io/dagger/annotation/processor/DaggerModuleAnnotationProcessor.java
Show resolved
Hide resolved
...-processor/src/main/java/io/dagger/annotation/processor/DaggerModuleAnnotationProcessor.java
Outdated
Show resolved
Hide resolved
sdk/java/runtime/template/src/main/java/io/dagger/sample/module/DaggerModule.java
Outdated
Show resolved
Hide resolved
sdk/java/runtime/template/src/main/java/io/dagger/sample/module/DaggerModule.java
Outdated
Show resolved
Hide resolved
25e0fe0
to
fd9472a
Compare
f4a5149
to
d75a52f
Compare
Like assert from golangci-lint module Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
so types are correctly handled. Use JsonConverter class to convert types to/from JSON Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
they are not needed for module generation. And we still generate them on the fly when needed to build locally. Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
/src/<user module>/sdk is replaced by /src/dagger-io that's where the sdk, java lib, etc will be built <user module>/target/generated-sources/sdk is replaced by <user module>/target/generated-sources/dagger-io where the sdk/java source code will be put <user module>/target/generated-sources/dagger is replaced by <user module>/target/generated-sources/dagger-module where the generated code from sdk/java and specific to the module will be put Signed-off-by: Yves Brissaud <gh@lgtd.io>
That way we avoid "samples" and there's no conflict with the default package io.dagger.module Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Bumps the sdk-java group with 4 updates in the /sdk/java directory: io.smallrye:smallrye-graphql-client-api, io.smallrye:smallrye-graphql-client-implementation-vertx, [io.netty:netty-common](https://github.com/netty/netty) and [org.assertj:assertj-core](https://github.com/assertj/assertj). Updates `io.smallrye:smallrye-graphql-client-api` from 2.12.0 to 2.12.1 Updates `io.smallrye:smallrye-graphql-client-implementation-vertx` from 2.12.0 to 2.12.1 Updates `io.smallrye:smallrye-graphql-client-implementation-vertx` from 2.12.0 to 2.12.1 Updates `io.netty:netty-common` from 4.1.116.Final to 4.1.117.Final - [Commits](netty/netty@netty-4.1.116.Final...netty-4.1.117.Final) Updates `org.assertj:assertj-core` from 3.27.2 to 3.27.3 - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](assertj/assertj@assertj-build-3.27.2...assertj-build-3.27.3) --- updated-dependencies: - dependency-name: io.smallrye:smallrye-graphql-client-api dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: io.smallrye:smallrye-graphql-client-implementation-vertx dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: io.smallrye:smallrye-graphql-client-implementation-vertx dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: io.netty:netty-common dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch dependency-group: sdk-java ... Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
Java + docker desktop + macos 15.3 is not a nice combo with a lot of java crashes. Those are old (but supported) java version that look like to work as expected. Signed-off-by: Yves Brissaud <gh@lgtd.io>
Signed-off-by: Yves Brissaud <gh@lgtd.io>
136baab
to
f7fef23
Compare
* Add annotations to for module declaration and an annotation processor skeleton This annotation processor will collect type info into a file in order to register objects and functions when the module is called. Signed-off-by: Jean-Christophe Sirot <jcsirot@gmail.com> * reads description from javadoc Only in case `description` field of the annotation is not set. That way it's still possible to override it, specifically for Dagger, but on the other hand it's now possible to only use Java features and not provide fields so there's no duplication. Before: @ModuleFunction(value="echo", description="Returns a contain...") public Container containerEcho(String stringArg) { After: /// Returns a container that echoes... @ModuleFunction public Container echo(String stringArg) { Signed-off-by: Yves Brissaud <gh@lgtd.io> * refactor annotations and entrypoint Rename annotation classes so they are simpler: Module, Object, Function. As close as possible to the Dagger wording. I also moved the info objects (the ones used to generate the json file) to the dagger-java-sdk part so they can also be used to read the json file. Almost created the registry part of the entrypoint: it creates the right dagger module structure, but now it needs to create the right JSON output. This entrypoint can be used as the entrypoint of a module. It's intended to be generic (based on the json file for now, maybe on the annotation in the future). So the module side only needs to declare the mainClass to io.dagger.module.Entrypoint For instance by adding this to the pom.xml: <dependencies> <dependency> <groupId>io.dagger</groupId> <artifactId>dagger-java-sdk</artifactId> <version>1.0.0-SNAPSHOT</version> </dependency> <dependency> <groupId>io.dagger</groupId> <artifactId>dagger-java-annotation-processor</artifactId> <version>1.0.0-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies> <build> <pluginManagement> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.13.0</version> <configuration> <verbose>false</verbose> <annotationProcessorPaths> <path> <groupId>io.dagger</groupId> <artifactId>dagger-java-annotation-processor</artifactId> <version>1.0.0-SNAPSHOT</version> </path> </annotationProcessorPaths> <annotationProcessors> <annotationProcessor>io.dagger.annotation.processor.DaggerModuleAnnotationProcessor</annotationProcessor> </annotationProcessors> </configuration> </plugin> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.5.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>io.dagger.module.Entrypoint</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build> This should be good to create a jar with all the dependencies: ./mvnw clean package This includes the management of the annotations. And then the generated jar declares the right entrypoint, so this should be good to run with: dagger run java -jar dagger-module.jar This will not completely work as the module part is not done, so the dagger engine doesn't know about the module and so the registration can't be done. But that's a different story. The goal here was to be able to: - document with annotations - create a first basic entrypoint - declare as much as possible in the SDK so it's easy to integrate Signed-off-by: Yves Brissaud <gh@lgtd.io> * add a module.Base class This is a very simple one, just provided so that modules don't have define the `dag` field. In some way this is just to enforce some conventions. Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix annotation processor, set type of parameter Signed-off-by: Yves Brissaud <gh@lgtd.io> * correctly reads the dagger module info json file I'm using gson, but I'll have a second look to avoid it and keep dependencies minimal. But for now it solves the issue. Signed-off-by: Yves Brissaud <gh@lgtd.io> * ensure descriptions are not empty Signed-off-by: Yves Brissaud <gh@lgtd.io> * ensure type is not null start dealing with types, but needs more work to ensure everything is compatible Signed-off-by: Yves Brissaud <gh@lgtd.io> * return the module ID when registering make the Scalar.convert method public to be able to convert to JSON. Not sure that's the best way, but at least for now it unblocks it. Signed-off-by: Yves Brissaud <gh@lgtd.io> * wip java module Signed-off-by: Yves Brissaud <gh@lgtd.io> * migrate to palantir/javapoet As of 2020-10-10, Square's JavaPoet project is deprecated Signed-off-by: Yves Brissaud <gh@lgtd.io> * add 0.15.2 schema Signed-off-by: Yves Brissaud <gh@lgtd.io> * generate code for the entrypoint Signed-off-by: Yves Brissaud <gh@lgtd.io> * improve runtime code add comments, clean build and final image Signed-off-by: Yves Brissaud <gh@lgtd.io> * add template for dagger init Signed-off-by: Yves Brissaud <gh@lgtd.io> * generate all java files and support dagger develop Signed-off-by: Yves Brissaud <gh@lgtd.io> * enable -XX:UseSVE=0 flag based on platform Only enable it when architecture is arm64. Enable it at the base of maven and jre container used so it's transparent for all actions based on those containers. Signed-off-by: Yves Brissaud <gh@lgtd.io> * format code using com.spotify.fmt Signed-off-by: Yves Brissaud <gh@lgtd.io> * bump java dependencies Signed-off-by: Yves Brissaud <gh@lgtd.io> * improve type handling in entrypoint handles primitive and class based types, as well as lists and enums for return types and parameters Signed-off-by: Yves Brissaud <gh@lgtd.io> * make module Base class abstract Signed-off-by: Yves Brissaud <gh@lgtd.io> * use fmt-maven-plugin on build Signed-off-by: Yves Brissaud <gh@lgtd.io> * mention modules in sdk/java readme Signed-off-by: Yves Brissaud <gh@lgtd.io> * cover entrypoint generation by a test Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix runtime lint errors Signed-off-by: Yves Brissaud <gh@lgtd.io> * Parse javadoc to get modules, functions and parameters descriptions Co-authored-by: Yves Brissaud <gh@lgtd.io> Signed-off-by: Yves Brissaud <gh@lgtd.io> * make Convert class a final class Signed-off-by: Yves Brissaud <gh@lgtd.io> * handle primitive types in return and args Signed-off-by: Yves Brissaud <gh@lgtd.io> * improve convert code and assignable types Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix fields/method with reserverd java words Like assert from golangci-lint module Signed-off-by: Yves Brissaud <gh@lgtd.io> * allow to check if values of scalars are identical Signed-off-by: Yves Brissaud <gh@lgtd.io> * use dedicated json (de)serializers so types are correctly handled. Use JsonConverter class to convert types to/from JSON Signed-off-by: Yves Brissaud <gh@lgtd.io> * allow to set argument as optional Signed-off-by: Yves Brissaud <gh@lgtd.io> * cover code generation from annotations Signed-off-by: Yves Brissaud <gh@lgtd.io> * allow to set a default value to parameters Signed-off-by: Yves Brissaud <gh@lgtd.io> * remove @module value (module name) Wasn't used and cause some confusion. @module is optional, and only here to expose the module's description. @object and @function are the ones required to create module objects. Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix ignore/generated path Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix initialization of primitive types Signed-off-by: Yves Brissaud <gh@lgtd.io> * replace sed calls Signed-off-by: Yves Brissaud <gh@lgtd.io> * remove Java from built in SDKs Signed-off-by: Yves Brissaud <gh@lgtd.io> * connect java sdk into the CI Signed-off-by: Yves Brissaud <gh@lgtd.io> * remove schema files they are not needed for module generation. And we still generate them on the fly when needed to build locally. Signed-off-by: Yves Brissaud <gh@lgtd.io> * add quotes to default string values if needed Signed-off-by: Yves Brissaud <gh@lgtd.io> * improve type management Signed-off-by: Yves Brissaud <gh@lgtd.io> * add more details about java sdk internal to the README Signed-off-by: Yves Brissaud <gh@lgtd.io> * replace 'sdk' by more meaningful names /src/<user module>/sdk is replaced by /src/dagger-io that's where the sdk, java lib, etc will be built <user module>/target/generated-sources/sdk is replaced by <user module>/target/generated-sources/dagger-io where the sdk/java source code will be put <user module>/target/generated-sources/dagger is replaced by <user module>/target/generated-sources/dagger-module where the generated code from sdk/java and specific to the module will be put Signed-off-by: Yves Brissaud <gh@lgtd.io> * update default java package to io.dagger.modules.<usermodule> That way we avoid "samples" and there's no conflict with the default package io.dagger.module Signed-off-by: Yves Brissaud <gh@lgtd.io> * only import needed files to build Signed-off-by: Yves Brissaud <gh@lgtd.io> * handle generation when referencing non yet existing classes Signed-off-by: Yves Brissaud <gh@lgtd.io> * replace @optional by @nullable + @default That way we can express the full matrix of possibilities between the two aspects. For now, to set a default value implies the value to be nullable (optional in term of Dagger API). Signed-off-by: Yves Brissaud <gh@lgtd.io> * chore(deps): bump the sdk-java group across 1 directory with 4 updates Bumps the sdk-java group with 4 updates in the /sdk/java directory: io.smallrye:smallrye-graphql-client-api, io.smallrye:smallrye-graphql-client-implementation-vertx, [io.netty:netty-common](https://github.com/netty/netty) and [org.assertj:assertj-core](https://github.com/assertj/assertj). Updates `io.smallrye:smallrye-graphql-client-api` from 2.12.0 to 2.12.1 Updates `io.smallrye:smallrye-graphql-client-implementation-vertx` from 2.12.0 to 2.12.1 Updates `io.smallrye:smallrye-graphql-client-implementation-vertx` from 2.12.0 to 2.12.1 Updates `io.netty:netty-common` from 4.1.116.Final to 4.1.117.Final - [Commits](netty/netty@netty-4.1.116.Final...netty-4.1.117.Final) Updates `org.assertj:assertj-core` from 3.27.2 to 3.27.3 - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](assertj/assertj@assertj-build-3.27.2...assertj-build-3.27.3) --- updated-dependencies: - dependency-name: io.smallrye:smallrye-graphql-client-api dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: io.smallrye:smallrye-graphql-client-implementation-vertx dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: io.smallrye:smallrye-graphql-client-implementation-vertx dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: io.netty:netty-common dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch dependency-group: sdk-java ... Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix warnings in pom.xml Signed-off-by: Yves Brissaud <gh@lgtd.io> * rollback images to java 17 to work with latest desktop/mac Java + docker desktop + macos 15.3 is not a nice combo with a lot of java crashes. Those are old (but supported) java version that look like to work as expected. Signed-off-by: Yves Brissaud <gh@lgtd.io> * rename io.dagger.module.Base to io.dagger.module.AbstractModule Signed-off-by: Yves Brissaud <gh@lgtd.io> --------- Signed-off-by: Jean-Christophe Sirot <jcsirot@gmail.com> Signed-off-by: Yves Brissaud <gh@lgtd.io> Co-authored-by: Jean-Christophe Sirot <jcsirot@gmail.com> Co-authored-by: dependabot [bot] <support@github.com>
* Add annotations to for module declaration and an annotation processor skeleton This annotation processor will collect type info into a file in order to register objects and functions when the module is called. Signed-off-by: Jean-Christophe Sirot <jcsirot@gmail.com> * reads description from javadoc Only in case `description` field of the annotation is not set. That way it's still possible to override it, specifically for Dagger, but on the other hand it's now possible to only use Java features and not provide fields so there's no duplication. Before: @ModuleFunction(value="echo", description="Returns a contain...") public Container containerEcho(String stringArg) { After: /// Returns a container that echoes... @ModuleFunction public Container echo(String stringArg) { Signed-off-by: Yves Brissaud <gh@lgtd.io> * refactor annotations and entrypoint Rename annotation classes so they are simpler: Module, Object, Function. As close as possible to the Dagger wording. I also moved the info objects (the ones used to generate the json file) to the dagger-java-sdk part so they can also be used to read the json file. Almost created the registry part of the entrypoint: it creates the right dagger module structure, but now it needs to create the right JSON output. This entrypoint can be used as the entrypoint of a module. It's intended to be generic (based on the json file for now, maybe on the annotation in the future). So the module side only needs to declare the mainClass to io.dagger.module.Entrypoint For instance by adding this to the pom.xml: <dependencies> <dependency> <groupId>io.dagger</groupId> <artifactId>dagger-java-sdk</artifactId> <version>1.0.0-SNAPSHOT</version> </dependency> <dependency> <groupId>io.dagger</groupId> <artifactId>dagger-java-annotation-processor</artifactId> <version>1.0.0-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies> <build> <pluginManagement> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.13.0</version> <configuration> <verbose>false</verbose> <annotationProcessorPaths> <path> <groupId>io.dagger</groupId> <artifactId>dagger-java-annotation-processor</artifactId> <version>1.0.0-SNAPSHOT</version> </path> </annotationProcessorPaths> <annotationProcessors> <annotationProcessor>io.dagger.annotation.processor.DaggerModuleAnnotationProcessor</annotationProcessor> </annotationProcessors> </configuration> </plugin> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.5.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>io.dagger.module.Entrypoint</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build> This should be good to create a jar with all the dependencies: ./mvnw clean package This includes the management of the annotations. And then the generated jar declares the right entrypoint, so this should be good to run with: dagger run java -jar dagger-module.jar This will not completely work as the module part is not done, so the dagger engine doesn't know about the module and so the registration can't be done. But that's a different story. The goal here was to be able to: - document with annotations - create a first basic entrypoint - declare as much as possible in the SDK so it's easy to integrate Signed-off-by: Yves Brissaud <gh@lgtd.io> * add a module.Base class This is a very simple one, just provided so that modules don't have define the `dag` field. In some way this is just to enforce some conventions. Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix annotation processor, set type of parameter Signed-off-by: Yves Brissaud <gh@lgtd.io> * correctly reads the dagger module info json file I'm using gson, but I'll have a second look to avoid it and keep dependencies minimal. But for now it solves the issue. Signed-off-by: Yves Brissaud <gh@lgtd.io> * ensure descriptions are not empty Signed-off-by: Yves Brissaud <gh@lgtd.io> * ensure type is not null start dealing with types, but needs more work to ensure everything is compatible Signed-off-by: Yves Brissaud <gh@lgtd.io> * return the module ID when registering make the Scalar.convert method public to be able to convert to JSON. Not sure that's the best way, but at least for now it unblocks it. Signed-off-by: Yves Brissaud <gh@lgtd.io> * wip java module Signed-off-by: Yves Brissaud <gh@lgtd.io> * migrate to palantir/javapoet As of 2020-10-10, Square's JavaPoet project is deprecated Signed-off-by: Yves Brissaud <gh@lgtd.io> * add 0.15.2 schema Signed-off-by: Yves Brissaud <gh@lgtd.io> * generate code for the entrypoint Signed-off-by: Yves Brissaud <gh@lgtd.io> * improve runtime code add comments, clean build and final image Signed-off-by: Yves Brissaud <gh@lgtd.io> * add template for dagger init Signed-off-by: Yves Brissaud <gh@lgtd.io> * generate all java files and support dagger develop Signed-off-by: Yves Brissaud <gh@lgtd.io> * enable -XX:UseSVE=0 flag based on platform Only enable it when architecture is arm64. Enable it at the base of maven and jre container used so it's transparent for all actions based on those containers. Signed-off-by: Yves Brissaud <gh@lgtd.io> * format code using com.spotify.fmt Signed-off-by: Yves Brissaud <gh@lgtd.io> * bump java dependencies Signed-off-by: Yves Brissaud <gh@lgtd.io> * improve type handling in entrypoint handles primitive and class based types, as well as lists and enums for return types and parameters Signed-off-by: Yves Brissaud <gh@lgtd.io> * make module Base class abstract Signed-off-by: Yves Brissaud <gh@lgtd.io> * use fmt-maven-plugin on build Signed-off-by: Yves Brissaud <gh@lgtd.io> * mention modules in sdk/java readme Signed-off-by: Yves Brissaud <gh@lgtd.io> * cover entrypoint generation by a test Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix runtime lint errors Signed-off-by: Yves Brissaud <gh@lgtd.io> * Parse javadoc to get modules, functions and parameters descriptions Co-authored-by: Yves Brissaud <gh@lgtd.io> Signed-off-by: Yves Brissaud <gh@lgtd.io> * make Convert class a final class Signed-off-by: Yves Brissaud <gh@lgtd.io> * handle primitive types in return and args Signed-off-by: Yves Brissaud <gh@lgtd.io> * improve convert code and assignable types Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix fields/method with reserverd java words Like assert from golangci-lint module Signed-off-by: Yves Brissaud <gh@lgtd.io> * allow to check if values of scalars are identical Signed-off-by: Yves Brissaud <gh@lgtd.io> * use dedicated json (de)serializers so types are correctly handled. Use JsonConverter class to convert types to/from JSON Signed-off-by: Yves Brissaud <gh@lgtd.io> * allow to set argument as optional Signed-off-by: Yves Brissaud <gh@lgtd.io> * cover code generation from annotations Signed-off-by: Yves Brissaud <gh@lgtd.io> * allow to set a default value to parameters Signed-off-by: Yves Brissaud <gh@lgtd.io> * remove @module value (module name) Wasn't used and cause some confusion. @module is optional, and only here to expose the module's description. @object and @function are the ones required to create module objects. Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix ignore/generated path Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix initialization of primitive types Signed-off-by: Yves Brissaud <gh@lgtd.io> * replace sed calls Signed-off-by: Yves Brissaud <gh@lgtd.io> * remove Java from built in SDKs Signed-off-by: Yves Brissaud <gh@lgtd.io> * connect java sdk into the CI Signed-off-by: Yves Brissaud <gh@lgtd.io> * remove schema files they are not needed for module generation. And we still generate them on the fly when needed to build locally. Signed-off-by: Yves Brissaud <gh@lgtd.io> * add quotes to default string values if needed Signed-off-by: Yves Brissaud <gh@lgtd.io> * improve type management Signed-off-by: Yves Brissaud <gh@lgtd.io> * add more details about java sdk internal to the README Signed-off-by: Yves Brissaud <gh@lgtd.io> * replace 'sdk' by more meaningful names /src/<user module>/sdk is replaced by /src/dagger-io that's where the sdk, java lib, etc will be built <user module>/target/generated-sources/sdk is replaced by <user module>/target/generated-sources/dagger-io where the sdk/java source code will be put <user module>/target/generated-sources/dagger is replaced by <user module>/target/generated-sources/dagger-module where the generated code from sdk/java and specific to the module will be put Signed-off-by: Yves Brissaud <gh@lgtd.io> * update default java package to io.dagger.modules.<usermodule> That way we avoid "samples" and there's no conflict with the default package io.dagger.module Signed-off-by: Yves Brissaud <gh@lgtd.io> * only import needed files to build Signed-off-by: Yves Brissaud <gh@lgtd.io> * handle generation when referencing non yet existing classes Signed-off-by: Yves Brissaud <gh@lgtd.io> * replace @optional by @nullable + @default That way we can express the full matrix of possibilities between the two aspects. For now, to set a default value implies the value to be nullable (optional in term of Dagger API). Signed-off-by: Yves Brissaud <gh@lgtd.io> * chore(deps): bump the sdk-java group across 1 directory with 4 updates Bumps the sdk-java group with 4 updates in the /sdk/java directory: io.smallrye:smallrye-graphql-client-api, io.smallrye:smallrye-graphql-client-implementation-vertx, [io.netty:netty-common](https://github.com/netty/netty) and [org.assertj:assertj-core](https://github.com/assertj/assertj). Updates `io.smallrye:smallrye-graphql-client-api` from 2.12.0 to 2.12.1 Updates `io.smallrye:smallrye-graphql-client-implementation-vertx` from 2.12.0 to 2.12.1 Updates `io.smallrye:smallrye-graphql-client-implementation-vertx` from 2.12.0 to 2.12.1 Updates `io.netty:netty-common` from 4.1.116.Final to 4.1.117.Final - [Commits](netty/netty@netty-4.1.116.Final...netty-4.1.117.Final) Updates `org.assertj:assertj-core` from 3.27.2 to 3.27.3 - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](assertj/assertj@assertj-build-3.27.2...assertj-build-3.27.3) --- updated-dependencies: - dependency-name: io.smallrye:smallrye-graphql-client-api dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: io.smallrye:smallrye-graphql-client-implementation-vertx dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: io.smallrye:smallrye-graphql-client-implementation-vertx dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: io.netty:netty-common dependency-type: direct:production update-type: version-update:semver-patch dependency-group: sdk-java - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-patch dependency-group: sdk-java ... Signed-off-by: Yves Brissaud <gh@lgtd.io> * fix warnings in pom.xml Signed-off-by: Yves Brissaud <gh@lgtd.io> * rollback images to java 17 to work with latest desktop/mac Java + docker desktop + macos 15.3 is not a nice combo with a lot of java crashes. Those are old (but supported) java version that look like to work as expected. Signed-off-by: Yves Brissaud <gh@lgtd.io> * rename io.dagger.module.Base to io.dagger.module.AbstractModule Signed-off-by: Yves Brissaud <gh@lgtd.io> --------- Signed-off-by: Jean-Christophe Sirot <jcsirot@gmail.com> Signed-off-by: Yves Brissaud <gh@lgtd.io> Co-authored-by: Jean-Christophe Sirot <jcsirot@gmail.com> Co-authored-by: dependabot [bot] <support@github.com>
This PR allows to create Dagger modules using Java.
This will create the module with a default template. This template module is based on the same than Go and others, with the
container-echo
andgrep-dir
functions.A default
pom.xml
is also generated.Once done, it's possible to list the functions or call them:
The java module code is using annotations to know what to expose and call:
@Module
@Object
@Function
The entrypoint code will be generated at build time. In that way it's close to the Go modules (not a generic endpoint at runtime only).
The default
pom.xml
set the main class to the generated entrypoint one automatically using themaven-shade
plugin.By default only the
src
directory and thepom.xml
are necessary. But to keep a nice Developer Experience and help IDEs to complete code, all the Dagger SDK dependencies (the Dagger java sdk plus all the generated files for the different types and the entrypoint) can be generated and made available under thetarget/generated-sources
directory:dagger
: the generated files based on Dagger introspection JSONentrypoint
: the generated entrypoint based on user's codesdk
: thesdk/java/dagger-java-sdk
source code (this is not really generated sources but a way to make it available easily)generated files
Those files are not intended to be added to git. To re-generate them:
dagger develop