melix
04/18/2025, 9:12 AMpublic interface CreateLayerOptions extends LayerOptions {
@Input
@Optional
ListProperty<String> getPackages();
@Classpath
@Optional
ConfigurableFileCollection getJars();
@Input
ListProperty<String> getModules();
}
there is, in my code, a single call to `getJars()`:
var classpath = create.getJars();
boolean hasJars = !classpath.getFiles().isEmpty();
The interface is implemented and added to a domain object set using:
@Override
public void createLayer(Action<? super CreateLayerOptions> spec) {
var layer = objects.newInstance(CreateLayerOptions.class);
var binaryName = getName();
if (!binaryName.startsWith("lib")) {
throw new IllegalArgumentException("Binary name for a layer must start with 'lib'");
}
layer.getLayerName().convention(binaryName);
spec.execute(layer);
layers(options -> options.add(layer));
}
and the user code to configure it currently has (this is all a spike, so hopefully I can make this nicer):
createLayer {
val externalJars = configurations.nativeImageClasspath.get()
.incoming
.artifactView {
lenient(false)
componentFilter { this is ModuleComponentIdentifier }
}
.artifacts
modules = listOf("java.base", "jdk.unsupported", "java.sql")
jars.from(externalJars.resolvedArtifacts
.map { artifacts -> artifacts.map { it.file } }
)
...
When I debug, I can see that after spec.execute(layer)
is called, layer.getFrom()
contains one element as expected. However, when my code to get this list of jars is called, the list is empty oO. I have verified and it's the same instance. Only "something" make the contents go away. The suspect is input evaluation, but I'm 🤨melix
04/18/2025, 12:20 PMthis is ModuleComponentIdentifier
instead of it is ModuleComponentIdentifier
. Still, I don't understand why my collection is mutated and disappears