8000 docs(sdk/java) cookbook by eunomie · Pull Request #9848 · dagger/dagger · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

docs(sdk/java) cookbook #9848

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "my-module",
"engineVersion": "v0.18.6",
"sdk": {
"source": "java"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.dagger.modules.daggermodule</groupId>
<artifactId>my-module</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-module</name>

<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dagger.module.deps>0.18.6-my-module-module</dagger.module.deps>
</properties>

<dependencies>
<dependency>
<groupId>io.dagger</groupId>
<artifactId>dagger-java-sdk</artifactId>
<version>${dagger.module.deps}</version>
</dependency>
<dependency>
<groupId>io.dagger</groupId>
<artifactId>dagger-java-annotation-processor</artifactId>
<version>${dagger.module.deps}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>runtime</scope>
<version>2.0.16</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>3.0.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.118.Final</version>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.5.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<!--
This plugin configuration is required by Dagger to generate the module.
Please do not remove or modify it.
-->
<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>${dagger.module.deps}</version>
</path>
</annotationProcessorPaths>
<annotationProcessors>
<annotationProcessor>io.dagger.annotation.processor.DaggerModuleAnnotationProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.6.1</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<!--
This plugin configuration helps VS Code editor (and others) to find
the generated code created by `dagger init` and `dagger develop` and
helps for code completion.
-->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>add-generated-sources</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/dagger-io</source>
<source>${project.build.directory}/generated-sources/dagger-module</source>
<source>${project.build.directory}/generated-sources/entrypoint</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--
This plugin configuration is required by Dagger to generate the module.
Please do not remove or modify it.
-->
<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.gen.entrypoint.Entrypoint</mainClass>
</transformer>
</transformers>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.dagger.modules.mymodule;

import static io.dagger.client.Dagger.dag;

import io.dagger.client.Container;
import io.dagger.client.Service;
import io.dagger.module.annotation.Function;
import io.dagger.module.annotation.Object;
import java.util.List;

@Object
public class MyModule {
@Function
public Service httpService() {
return dag().container()
.from("python")
.withWorkdir("/srv")
.withNewFile("index.html", "Hello, world!")
.withExposedPort(8080)
.asService(new Container.AsServiceArguments().withArgs(List.of("python", "-m", "http.server", "8080")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@Object
public class MyModule {
private Container.WithExecArguments execOpts =
private final Container.WithExecArguments execOpts =
new Container.WithExecArguments().withUseEntrypoint(true);

/** Create Redis service and client */
Expand Down
Loading
Loading
0