Skip to content

Project#afterEvaluate cannot be executed in the current context #674

@mjulianotq

Description

@mjulianotq

Shadow Version

7.0.0

Gradle Version

7.0.2

Expected Behavior

Gradle evaluates its configuration correctly.

Actual Behavior

Gradle fails to configure a project with this plugin because of the call to Project#afterEvaluate.

* What went wrong:
An exception occurred applying plugin request [id: 'com.github.johnrengelman.shadow', version: '7.0.0']
> Failed to apply plugin 'com.github.johnrengelman.shadow'.
   > Project#afterEvaluate(Closure) on project ':rdf-delta-server' cannot be executed in the current context.

Gradle Build Script(s)

To recreate my issue, clone https://github.com/TopQuadrant-DevOps/rdf-delta and change the contents of ./rdf-delta-dist/build.gradle.kts to the below. Then run any task like ./gradlew clean.

plugins {
    base
    id("com.palantir.docker") version "0.26.0"
}

tasks.register<Tar>("packageDistribution") {
    dependsOn(":rdf-delta-server:shadowJar")
    dependsOn(":rdf-delta-fuseki-server:shadowJar")
    archiveBaseName.set("rdf-delta")
    from("dist")
    from("Files")
    from("README")
    with(copySpec {
        from(tasks.getByPath(":rdf-delta-server:shadowJar"))
        rename({ name -> "delta-server.jar" })
    })
    with(copySpec {
        from(tasks.getByPath(":rdf-delta-fuseki-server:shadowJar"))
        rename({name -> "delta-fuseki.jar" })
    })
    with(copySpec {
        from(project.file("../rdf-delta-examples/Tutorial"))
        into("Tutorial")
    })
    into("rdf-delta-${project.version}")
}

docker {
    name = "topquadrant/rdf-delta"
    files(tasks.getByName("packageDistribution").outputs)
}

Additional Notes

I see that Project#afterEvaluate is called specifically to exclude the Gradle API from being added to Shaded Jars, but perhaps it would be better to use this project's own filtering API. I don't mind doing the work here. I'm opening this ticket to get feedback on my thinking from the project owner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions