Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mjulianotq opened this issue May 24, 2021 · 0 comments
Closed

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

mjulianotq opened this issue May 24, 2021 · 0 comments
Milestone

Comments

@mjulianotq
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants