yanzhenjie / AndServer

:cherries: Web server and web framework of Android platform.
https://yanzhenjie.com/AndServer
Apache License 2.0
3.71k stars 746 forks source link

Gradle plugin does not support configuration cache, which causes build failure #440

Open ISNing opened 2 years ago

ISNing commented 2 years ago

build.gradle of the library:

buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.yanzhenjie.andserver:plugin:2.1.10'
    }
}

plugins {
    id 'com.android.library'
}
apply plugin: 'com.yanzhenjie.andserver'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        minSdk rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion

        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility rootProject.ext.sourceCompatibility
        targetCompatibility rootProject.ext.targetCompatibility
    }
}

dependencies {

    implementation "androidx.appcompat:appcompat:$rootProject.ext.appCompatVersion"
    implementation "com.google.android.material:material:$rootProject.ext.materialComponentsVersion"
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'com.yanzhenjie.andserver:api:2.1.10'
    annotationProcessor 'com.yanzhenjie.andserver:processor:2.1.10'
    implementation 'com.google.code.gson:gson:2.8.6'

    implementation project(path: ':app:shared')
}

Everything looks well.

But build failed. Log:

Executing tasks: [:app:assembleDebug, :app:web:assembleDebug] in project /home/isning/StudioProjects/Share

Configuration cache is an incubating feature.
Calculating task graph as no configuration cache is available for tasks: :app:assembleDebug :app:web:assembleDebug

67 problems were found storing the configuration cache, 40 of which seem unique.
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.lint.AndroidLintAnalysisTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.lint.AndroidLintTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.lint.LintModelWriterTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.res.GenerateApiPublicTxtTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.res.GenerateLibraryRFileTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.res.ParseLibraryResourcesTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.tasks.AarMetadataTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.tasks.BundleLibraryClassesDir', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.tasks.BundleLibraryClassesJar', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.tasks.BundleLibraryJavaRes', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.tasks.CheckManifest', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.tasks.ExportConsumerProguardFilesTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.tasks.LibraryAarJarsTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.tasks.LibraryJniLibsTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
- Task `:app:web:packageDebugAssets` of type `com.android.build.gradle.tasks.MergeSourceSetFolders`: cannot serialize object of type 'com.android.build.gradle.internal.tasks.LintModelMetadataTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:task_access
plus 25 more problems. Please see the report for details.

See the complete report at file:///home/isning/StudioProjects/Share/build/reports/configuration-cache/4v667v7h6bo23uocgnb78cy67/1tej4ebbi4aapcha7ipd6ci6c/configuration-cache-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache state could not be cached: field 'actions' from type 'com.android.build.gradle.tasks.MergeSourceSetFolders': error writing value of type 'java.util.ArrayList'
> Configuration cache state could not be cached: field 'action' from type 'org.gradle.api.internal.AbstractTask$TaskActionWrapper': error writing value of type 'com.yanzhenjie.andserver.plugin.AndServerPlugin$$Lambda$3216/0x0000000101bda840'
   > Configuration cache state could not be cached: field 'capturedArgs' from type 'java.lang.invoke.SerializedLambda': error writing value of type '[Ljava.lang.Object;'
      > Configuration cache state could not be cached: field 'testVariant' from type 'com.android.build.gradle.internal.api.LibraryVariantImpl': error writing value of type 'com.android.build.gradle.internal.api.TestVariantImpl'
         > Configuration cache state could not be cached: field 'variantData' from type 'com.android.build.gradle.internal.api.TestVariantImpl': error writing value of type 'com.android.build.gradle.internal.variant.TestVariantData'
            > Configuration cache state could not be cached: field 'testedVariantData' from type 'com.android.build.gradle.internal.variant.TestVariantData': error writing value of type 'com.android.build.gradle.internal.variant.LibraryVariantData'
               > Configuration cache state could not be cached: field 'globalScope' from type 'com.android.build.gradle.internal.variant.LibraryVariantData': error writing value of type 'com.android.build.gradle.internal.scope.GlobalScope'
                  > Configuration cache state could not be cached: field 'dslServices' from type 'com.android.build.gradle.internal.scope.GlobalScope': error writing value of type 'com.android.build.gradle.internal.services.DslServicesImpl'
                     > Configuration cache state could not be cached: field 'projectServices' from type 'com.android.build.gradle.internal.services.DslServicesImpl': error writing value of type 'com.android.build.gradle.internal.services.ProjectServices'
                        > Configuration cache state could not be cached: field 'deprecationReporter' from type 'com.android.build.gradle.internal.services.ProjectServices': error writing value of type 'com.android.build.gradle.internal.errors.DeprecationReporterImpl'
                           > Configuration cache state could not be cached: field 'issueReporter' from type 'com.android.build.gradle.internal.errors.DeprecationReporterImpl': error writing value of type 'com.android.build.gradle.internal.errors.SyncIssueReporterImpl'
                              > Configuration cache state could not be cached: field 'messageReceiverImpl' from type 'com.android.build.gradle.internal.errors.SyncIssueReporterImpl': error writing value of type 'com.android.build.gradle.internal.errors.MessageReceiverImpl'
                                 > Configuration cache state could not be cached: field 'mGson' from type 'com.android.build.gradle.internal.errors.MessageReceiverImpl': error writing value of type 'com.google.gson.Gson'
                                    > Configuration cache state could not be cached: field 'constructorConstructor' from type 'com.google.gson.Gson': error writing value of type 'com.google.gson.internal.ConstructorConstructor'
                                       > Configuration cache state could not be cached: field 'accessor' from type 'com.google.gson.internal.ConstructorConstructor': error writing value of type 'com.google.gson.internal.reflect.UnsafeReflectionAccessor'
                                          > Configuration cache state could not be cached: field 'overrideField' from type 'com.google.gson.internal.reflect.UnsafeReflectionAccessor': error writing value of type 'java.lang.reflect.Field'
                                             > Configuration cache state could not be cached: field 'overrideFieldAccessor' from type 'java.lang.reflect.Field': error writing value of type 'jdk.internal.reflect.UnsafeBooleanFieldAccessorImpl'
                                                > Unable to make field protected final java.lang.reflect.Field jdk.internal.reflect.UnsafeFieldAccessorImpl.field accessible: module java.base does not "opens jdk.internal.reflect" to unnamed module @4da649f6

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 21s

The build scan was not published due to a configuration problem.

The Gradle Terms of Service have not been agreed to.

For more information, please see https://gradle.com/help/plugin-terms-of-service.

Alternatively, if you are using Gradle Enterprise, specify the server location.
For more information, please see https://gradle.com/help/plugin-enterprise-config.

Configuration cache entry discarded with 67 problems.

After I removed gradle plugin, everything works well

ISNing commented 2 years ago

To make it reappear, you should enable gradle configuration by adding "org.gradle.unsafe.configuration-cache=true" to gradle.properties And you can also turn this error to a wrning by adding "org.gradle.unsafe.configuration-cache-problems=warn"

Maybe this issue should be considered as a feature request?

Edit: This issue can only be overcame by disabling configuration caching

ZYRzyr commented 1 year ago

In the file gradle.properties there is a line of code org.gradle.unsafe.configuration-cache=true Delete it and rebuild the project, it will solve the problem.

This occurred due to the configuration cache of Gradle. This libraries are not cacheable so it gives the error .