#Let me know if you want I have a look,

1 messages · Page 1 of 1 (latest)

warm fossil
#

I created a small module

{
  "name": "test-optional",
  "engineVersion": "v0.16.1",
  "sdk": {
    "source": "java"
  }
}
#
package io.dagger.modules.testoptional;

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

/** TestOptional main object */
@Object
public class TestOptional extends AbstractModule {
  /** Returns a container that echoes whatever string argument is provided */
  @Function
  public Container containerEcho(Optional<String> stringArg) {
    String str = stringArg.orElse("Hello Dagger");
    return dag.container().from("alpine:latest").withExec(List.of("echo", str));
  }
}
#

And I have these errors

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.870 s
[INFO] Finished at: 2025-03-12T08:07:43Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project test-optional: C
ailure: Compilation failure:
[ERROR] /src/target/generated-sources/annotations/io/dagger/gen/entrypoint/Entrypoint.java:[26,26] ';' expected
[ERROR] /src/target/generated-sources/annotations/io/dagger/gen/entrypoint/Entrypoint.java:[95,33] illegal start of expression
[ERROR] /src/target/generated-sources/annotations/io/dagger/gen/entrypoint/Entrypoint.java:[95,34] ';' expected
[ERROR] /src/target/generated-sources/annotations/io/dagger/gen/entrypoint/Entrypoint.java:[95,98] illegal start of expression
[ERROR] /src/target/generated-sources/annotations/io/dagger/gen/entrypoint/Entrypoint.java:[95,99] <identifier> expected
[ERROR] /src/target/generated-sources/annotations/io/dagger/gen/entrypoint/Entrypoint.java:[95,104] ';' expected
[ERROR] /src/target/generated-sources/annotations/io/dagger/gen/entrypoint/Entrypoint.java:[98,63] illegal start of expression
[ERROR] /src/target/generated-sources/annotations/io/dagger/gen/entrypoint/Entrypoint.java:[98,64] <identifier> expected
[ERROR] /src/target/generated-sources/annotations/io/dagger/gen/entrypoint/Entrypoint.java:[98,69] ';' expected
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
#

it seems that the generated code is invalid

#

the problem seems to come from the Optional<?> argument

gloomy dagger
#

Yes, Optional is in v0.16.2 if I'm right.
So either you should use a v0.16.2 engine or to pin the java sdk version to v0.16.1 and do not use Optional
That's my guess, I haven't tried it, but I'm using frequently Optional

warm fossil
#

I was sure I tried earlier

#

but maybe I was using my local dagger repo clone

#

ok, it's working in 0.16.2