codegenBase takes the user module code, add the generated SDK dependencies if the user module code is empty, creates a default module content based on the template from the SDK The generated container will *not* contain the SDK source code, but only the packages built from the SDK
( ctx context.Context, modSource *dagger.ModuleSource, introspectionJSON *dagger.File, )
| 103 | // if the user module code is empty, creates a default module content based on the template from the SDK |
| 104 | // The generated container will *not* contain the SDK source code, but only the packages built from the SDK |
| 105 | func (m *JavaSdk) codegenBase( |
| 106 | ctx context.Context, |
| 107 | modSource *dagger.ModuleSource, |
| 108 | introspectionJSON *dagger.File, |
| 109 | ) (*dagger.Container, error) { |
| 110 | ctr, err := m.buildJavaDependencies(ctx, introspectionJSON) |
| 111 | if err != nil { |
| 112 | return nil, err |
| 113 | } |
| 114 | ctr = ctr. |
| 115 | // Copy the user module directory under /src |
| 116 | WithDirectory(ModSourceDirPath, modSource.ContextDirectory()). |
| 117 | // Set the working directory to the one containing the sources to build, not just the module root |
| 118 | WithWorkdir(m.moduleConfig.modulePath()) |
| 119 | // Add a default template if there's no existing user code |
| 120 | ctr, err = m.addTemplate(ctx, ctr) |
| 121 | if err != nil { |
| 122 | return nil, err |
| 123 | } |
| 124 | // Ensure the version in the pom.xml is the same as the introspection file |
| 125 | // This is updating the pom.xml whatever it's coming from the template or the user module |
| 126 | version, err := m.getDaggerVersionForModule(ctx, introspectionJSON) |
| 127 | if err != nil { |
| 128 | return nil, err |
| 129 | } |
| 130 | ctr = ctr. |
| 131 | // set the version of the Dagger dependencies to the version of the introspection file |
| 132 | WithExec(m.mavenCommand( |
| 133 | "mvn", |
| 134 | "versions:set-property", |
| 135 | "-DgenerateBackupPoms=false", |
| 136 | "-Dproperty=dagger.module.deps", |
| 137 | fmt.Sprintf("-DnewVersion=%s", version), |
| 138 | )) |
| 139 | return ctr, nil |
| 140 | } |
| 141 | |
| 142 | // buildJavaDependencies builds and install the needed dependencies |
| 143 | // used to build, package and run the user module. |
no test coverage detected