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, )
| 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 |
| 351 | func (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 | |
| 372 | func (m *JavaSdk) mvnContainer(ctx context.Context) (*dagger.Container, error) { |
| 373 | return disableSVEOnArm64(ctx, m.MavenImage()) |
no test coverage detected