Skip to content

Commit 014e59d

Browse files
committed
add a default java module to use in tests
Signed-off-by: Yves Brissaud <yves.brissaud@gmail.com>
1 parent e04b301 commit 014e59d

6 files changed

Lines changed: 217 additions & 0 deletions

File tree

java-module/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/generated-sources/** linguist-generated

java-module/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
/.env

java-module/dagger.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "java-module",
3+
"engineVersion": "v0.19.8",
4+
"sdk": {
5+
"source": "java"
6+
}
7+
}

java-module/pom.xml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>io.dagger.modules.daggermodule</groupId>
8+
<artifactId>java-module</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<name>java-module</name>
11+
12+
<properties>
13+
<maven.compiler.release>17</maven.compiler.release>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<dagger.module.deps>0.19.7-java-module-module</dagger.module.deps>
16+
</properties>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>io.dagger</groupId>
21+
<artifactId>dagger-java-sdk</artifactId>
22+
<version>${dagger.module.deps}</version>
23+
</dependency>
24+
<dependency>
25+
<groupId>io.dagger</groupId>
26+
<artifactId>dagger-java-annotation-processor</artifactId>
27+
<version>${dagger.module.deps}</version>
28+
<scope>provided</scope>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.slf4j</groupId>
32+
<artifactId>slf4j-simple</artifactId>
33+
<scope>runtime</scope>
34+
<version>2.0.16</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.eclipse</groupId>
38+
<artifactId>yasson</artifactId>
39+
<version>3.0.4</version>
40+
<scope>runtime</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>io.netty</groupId>
44+
<artifactId>netty-handler</artifactId>
45+
<version>4.1.125.Final</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>net.minidev</groupId>
49+
<artifactId>json-smart</artifactId>
50+
<version>2.5.2</version>
51+
<scope>runtime</scope>
52+
</dependency>
53+
</dependencies>
54+
55+
<build>
56+
<pluginManagement>
57+
<plugins>
58+
<plugin>
59+
<artifactId>maven-clean-plugin</artifactId>
60+
<version>3.4.0</version>
61+
</plugin>
62+
<plugin>
63+
<artifactId>maven-resources-plugin</artifactId>
64+
<version>3.3.1</version>
65+
</plugin>
66+
<plugin>
67+
<!--
68+
This plugin configuration is required by Dagger to generate the module.
69+
Please do not remove or modify it.
70+
-->
71+
<artifactId>maven-compiler-plugin</artifactId>
72+
<version>3.13.0</version>
73+
<configuration>
74+
<verbose>false</verbose>
75+
<annotationProcessorPaths>
76+
<path>
77+
<groupId>io.dagger</groupId>
78+
<artifactId>dagger-java-annotation-processor</artifactId>
79+
<version>${dagger.module.deps}</version>
80+
</path>
81+
</annotationProcessorPaths>
82+
<annotationProcessors>
83+
<annotationProcessor>io.dagger.annotation.processor.DaggerModuleAnnotationProcessor</annotationProcessor>
84+
</annotationProcessors>
85+
</configuration>
86+
</plugin>
87+
<plugin>
88+
<artifactId>maven-surefire-plugin</artifactId>
89+
<version>3.3.0</version>
90+
</plugin>
91+
<plugin>
92+
<artifactId>maven-jar-plugin</artifactId>
93+
<version>3.4.2</version>
94+
</plugin>
95+
<plugin>
96+
<artifactId>maven-install-plugin</artifactId>
97+
<version>3.1.2</version>
98+
</plugin>
99+
<plugin>
100+
<artifactId>maven-deploy-plugin</artifactId>
101+
<version>3.1.2</version>
102+
</plugin>
103+
<plugin>
104+
<artifactId>maven-site-plugin</artifactId>
105+
<version>3.12.1</version>
106+
</plugin>
107+
<plugin>
108+
<artifactId>maven-project-info-reports-plugin</artifactId>
109+
<version>3.6.1</version>
110+
</plugin>
111+
</plugins>
112+
</pluginManagement>
113+
114+
<plugins>
115+
<plugin>
116+
<!--
117+
This plugin configuration helps VS Code editor (and others) to find
118+
the generated code created by `dagger init` and `dagger develop` and
119+
helps for code completion.
120+
-->
121+
<groupId>org.codehaus.mojo</groupId>
122+
<artifactId>build-helper-maven-plugin</artifactId>
123+
<version>3.3.0</version>
124+
<executions>
125+
<execution>
126+
<id>add-generated-sources</id>
127+
<goals>
128+
<goal>add-source</goal>
129+
</goals>
130+
<configuration>
131+
<sources>
132+
<source>${project.build.directory}/generated-sources/dagger-io</source>
133+
<source>${project.build.directory}/generated-sources/dagger-module</source>
134+
<source>${project.build.directory}/generated-sources/entrypoint</source>
135+
</sources>
136+
</configuration>
137+
</execution>
138+
</executions>
139+
</plugin>
140+
<plugin>
141+
<!--
142+
This plugin configuration is required by Dagger to generate the module.
143+
Please do not remove or modify it.
144+
-->
145+
<groupId>org.apache.maven.plugins</groupId>
146+
<artifactId>maven-shade-plugin</artifactId>
147+
<version>3.5.0</version>
148+
<executions>
149+
<execution>
150+
<phase>package</phase>
151+
<goals>
152+
<goal>shade</goal>
153+
</goals>
154+
<configuration>
155+
<transformers>
156+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
157+
<mainClass>io.dagger.gen.entrypoint.Entrypoint</mainClass>
158+
</transformer>
159+
</transformers>
160+
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
161+
<finalName>${project.artifactId}-${project.version}</finalName>
162+
</configuration>
163+
</execution>
164+
</executions>
165+
</plugin>
166+
</plugins>
167+
</build>
168+
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package io.dagger.modules.javamodule;
2+
3+
import static io.dagger.client.Dagger.dag;
4+
5+
import io.dagger.client.Container;
6+
import io.dagger.client.exception.DaggerQueryException;
7+
import io.dagger.client.Directory;
8+
import io.dagger.module.annotation.Function;
9+
import io.dagger.module.annotation.Object;
10+
import java.util.List;
11+
import java.util.concurrent.ExecutionException;
12+
13+
/** JavaModule main object */
14+
@Object
15+
public class JavaModule {
16+
/** Returns a container that echoes whatever string argument is provided */
17+
@Function
18+
public Container containerEcho(String stringArg) {
19+
return dag().container().from("alpine:latest").withExec(List.of("echo", stringArg));
20+
}
21+
22+
/** Returns lines that match a pattern in the files of the provided Directory */
23+
@Function
24+
public String grepDir(Directory directoryArg, String pattern)
25+
throws InterruptedException, ExecutionException, DaggerQueryException {
26+
return dag()
27+
.container()
28+
.from("alpine:latest")
29+
.withMountedDirectory("/mnt", directoryArg)
30+
.withWorkdir("/mnt")
31+
.withExec(List.of("grep", "-R", pattern, "."))
32+
.stdout();
33+
}
34+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** JavaModule example */
2+
@Module
3+
package io.dagger.modules.javamodule;
4+
5+
import io.dagger.module.annotation.Module;

0 commit comments

Comments
 (0)