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

'ConfigureShadowRelocation' task does not support Gradle configuration cache #687

Closed
Tapchicoma opened this issue Jul 3, 2021 · 2 comments · Fixed by #824
Closed

'ConfigureShadowRelocation' task does not support Gradle configuration cache #687

Tapchicoma opened this issue Jul 3, 2021 · 2 comments · Fixed by #824

Comments

@Tapchicoma
Copy link

com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation Gradle tasks does not support configuration cache:

- Task `:relocateShadowJar` of type `com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation`: cannot serialize object of type 'com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.1.1/userguide/configuration_cache.html#config_cache:requirements:task_access

Seems this part in current task implementation:

    @Input
    ShadowJar target

    @InputFiles @Optional
    List<Configuration> getConfigurations() {
        return target.configurations
    }

should be reworked into something like this:

    public setTarget(task: ShadowJar) {
        targetConfigurations = task.configurations
    }

    private List<Configurations> targetConfigurations = null

    @InputFiles @Optional
    List<Configuration> getConfigurations() {
        return targetConfigurations
    }

Shadow Version: 7.0.0
Gradle Version: 7.1.1

@eskatos
Copy link
Contributor

eskatos commented Nov 17, 2021

There is a bit more to this. List<Configuration> should be turned into a List<FileCollection> as it is not supported with CC to hold Configuration fields in tasks. The reference to the other task needs to be removed as it is not supported to hold references to tasks. In other words, "tasks that configure other tasks at execution time" is not supported. That means that the fix here is not trivial.

One way to do it would be to turn ShadowJar.relocators into a ListProperty<Relocator> and add to it mapping from the configurations starting with FileCollection.elements, thus getting rid of the ConfigureShadowRelocation task. Automatic relocation being optional it would need to be behind a flag somehow, maybe on ShadowJar directly. I'm not sure I'll have the time to dive deeper and actually try to implement this in the coming weeks.

@Goooler
Copy link
Member

Goooler commented Feb 25, 2023

Thanks for your suggestions! Addressing the fix to #824.

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

Successfully merging a pull request may close this issue.

3 participants