MCPcopy Index your code
hub / github.com/dagger/dagger / finalJar

Method finalJar

sdk/java/runtime/main.go:351–370  ·  view source on GitHub ↗

finalJar will return the jar corresponding to the user module built In order to have the final container as minimal as possible, we just want to be able to run a jar. To make it easy, we will rename the jar as module.jar But that's not easy, as we don't know the name of the built jar, so we will ask

(
	ctx context.Context,
	ctr *dagger.Container,
)

Source from the content-addressed store, hash-verified

349// But that's not easy, as we don't know the name of the built jar, so we will ask maven to give us the
350// artifactId and the version so we can get the jar name
351func (m *JavaSdk) finalJar(
352 ctx context.Context,
353 ctr *dagger.Container,
354) (*dagger.File, error) {
355 artifactID, err := ctr.
356 WithExec(m.mavenCommand("mvn", "org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate", "-Dexpression=project.artifactId", "-q", "-DforceStdout")).
357 Stdout(ctx)
358 if err != nil {
359 return nil, err
360 }
361 version, err := ctr.
362 WithExec(m.mavenCommand("mvn", "org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate", "-Dexpression=project.version", "-q", "-DforceStdout")).
363 Stdout(ctx)
364 if err != nil {
365 return nil, err
366 }
367 jarFileName := fmt.Sprintf("%s-%s.jar", artifactID, version)
368
369 return ctr.File(filepath.Join(m.moduleConfig.modulePath(), "target", jarFileName)), nil
370}
371
372func (m *JavaSdk) mvnContainer(ctx context.Context) (*dagger.Container, error) {
373 return disableSVEOnArm64(ctx, m.MavenImage())

Callers 1

buildJarMethod · 0.95

Calls 5

mavenCommandMethod · 0.95
FileMethod · 0.65
StdoutMethod · 0.45
WithExecMethod · 0.45
modulePathMethod · 0.45

Tested by

no test coverage detected