So I'm facing something quite strange. The content...
# community-support
m
So I'm facing something quite strange. The content of by file collection seems to vanish between configuration time and execution time oO. I have an interface which like this:
Copy code
public 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()`:
Copy code
var classpath = create.getJars();
boolean hasJars = !classpath.getFiles().isEmpty();
The interface is implemented and added to a domain object set using:
Copy code
@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):
Copy code
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 🤨
Found the problem:
this is ModuleComponentIdentifier
instead of
it is ModuleComponentIdentifier
. Still, I don't understand why my collection is mutated and disappears