Skip to content

AppendingTransformer blocks use of configuration cache (field data cannot be serialized) #763

@autonomousapps

Description

@autonomousapps

Shadow Version

7.1.2

Gradle Version

7.4

Expected Behavior

The configuration cache is supported. Sample invocation that fails:

./gradlew foo:shadowJar -m --configuration-cache

Actual Behavior

Attempting to use the configuration cache fails with the following:

// console output
$ ./gradlew bundle-aar:shadowJar -m --configuration-cache
3 problems were found storing the configuration cache, 1 of which seems unique.
- Task `:bundle-aar:shadowJar` of type `com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar`: cannot serialize object of type 'java.io.ByteArrayOutputStream', a subtype of 'java.io.OutputStream', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.4/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

// and the configuration cache error report:
cannot serialize object of type java.io.ByteArrayOutputStream a subtype of java.io.OutputStream, as these are not supported with the configuration cache (https://docs.gradle.org/7.4/userguide/configuration_cache.html#config_cache:requirements:disallowed_types)
  field data of com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer
    bean of type com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer
      fieldtransformers of com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
        task:bundle-aar:shadowJar of type com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

Note that this is only a dry run. It fails in the configuration phase, before it gets to the task action.

Gradle Build Script(s)

configurations {
  androidTools {
    // sdklib brings in a lot of unused code paths that can cause trouble with classpath conflicts.
    // Excluding for sanity.
    exclude group: 'com.android.tools', module: 'repository'
    exclude group: 'com.android.tools.analytics-library'
  }
}

// bundle and shade androidTools to avoid conflicting with AGP versions.
shadowJar {
  configurations = [project.configurations.androidTools]
  relocate 'com.android', 'bundle.aar.com.android'
  append 'META-INF/LICENSE.txt'
  append 'META-INF/LICENSE.md'
  append 'META-INF/NOTICE.md'
  mergeServiceFiles()
  minimize()
  dependencies {
    // don't fat jar kotlin
    exclude(dependency('org.jetbrains.kotlin:.*'))
  }
}

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions