Skip to content

Cannot change dependencies of dependency configuration 'implementation' after it has been included in dependency resolution #855

@blaghed

Description

@blaghed

Describe the bug

Starting with v0.11.4, I get the following error:

* What went wrong:
A problem occurred evaluating project ':foo-bar'.
> Cannot change dependencies of dependency configuration ':foo-bar:implementation' after it has been included in dependency resolution.

This happens on v0.11.5 as well. v0.11.3 is fine, though.

After a glance, I believe the culprit is likely the GenerateDynamicAccessMetadata class, which tries to resolve the dependency graph during the task's registration, instead of waiting to do so only on the task execution:

~https://github.com/graalvm/native-build-tools/blob/0.11.4/native-gradle-plugin/src/main/java/org/graalvm/buildtools/gradle/tasks/GenerateDynamicAccessMetadata.java#L84

    public void setClasspath(Configuration classpath) {
        getRuntimeClasspathGraph().set(classpath.getIncoming().getResolutionResult().getRootComponent());

        // Build coordinates -> path map
        Map<String, String> map = new HashMap<>();
        for (ResolvedArtifactResult artifact : classpath.getIncoming().getArtifacts().getResolvedArtifacts().get()) {
            if (artifact.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier mci) {
                String coordinates = mci.getGroup() + ":" + mci.getModule();
                map.put(coordinates, artifact.getFile().getAbsolutePath());
            }
        }
        getCoordinatesToPath().set(map);
    }

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions