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

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

Closed
autonomousapps opened this issue Apr 1, 2022 · 0 comments · Fixed by #824

Comments

@autonomousapps
Copy link

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

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.

1 participant