ReactiveCircus / app-versioning

A Gradle Plugin for lazily generating Android app's versionCode & versionName from Git tags.
Apache License 2.0
205 stars 3 forks source link

File not found. #26

Closed xiazunyang closed 1 year ago

xiazunyang commented 2 years ago

FAILURE: Build failed with an exception.

BUILD FAILED in 30s 5 actionable tasks: 5 up-to-date

Wrywulf commented 2 years ago

I ran into the same issue on my new M1 machine running Zulu-jdk 11.0.15:

> ./gradlew test
…
Execution failed for task ':app:generateStagingDebugBuildConfig'
> Error while evaluating property 'versionCode' of task ':app:generateStagingDebugBuildConfig'
   > java.io.FileNotFoundException: /.../app/build/outputs/app_versioning/stagingDebug/version_code.txt (No such file or directory)

Even though the file does exist.

If I run the task explicitly, that succeeds:

> ./gradlew :app:generateStagingDebugBuildConfig
…
BUILD SUCCESSFUL in 5s
16 actionable tasks: 1 executed, 15 up-to-date

And after this the original test task can build successfully as well. EDIT: it does not complete successfully.

Here is the error root stack trace:

Caused by: java.io.FileNotFoundException: /../app/build/outputs/app_versioning/stagingDebug/version_code.txt (No such file or directory)
        at kotlin.io.FilesKt__FileReadWriteKt.readText(FileReadWrite.kt:125)
        at kotlin.io.FilesKt__FileReadWriteKt.readText$default(FileReadWrite.kt:125)
        at io.github.reactivecircus.appversioning.AppVersioningPlugin$apply$3$1$generatedVersionCode$1.transform(AppVersioningPlugin.kt:51)
        at io.github.reactivecircus.appversioning.AppVersioningPlugin$apply$3$1$generatedVersionCode$1.transform(AppVersioningPlugin.kt:23)
        at org.gradle.api.internal.provider.TransformBackedProvider.mapValue(TransformBackedProvider.java:73)
        at org.gradle.api.internal.provider.TransformBackedProvider.calculateExecutionTimeValue(TransformBackedProvider.java:57)
        at org.gradle.api.internal.provider.MappingProvider.calculateExecutionTimeValue(MappingProvider.java:64)
        at org.gradle.api.internal.provider.DefaultProperty.calculateOwnExecutionTimeValue(DefaultProperty.java:123)
        at org.gradle.api.internal.provider.DefaultProperty.calculateOwnExecutionTimeValue(DefaultProperty.java:26)
        at org.gradle.api.internal.provider.AbstractProperty.calculateExecutionTimeValue(AbstractProperty.java:147)
        at org.gradle.configurationcache.serialization.codecs.FixedValueReplacingProviderCodec.encodeProvider(ProviderCodecs.kt:72)
        at org.gradle.configurationcache.serialization.codecs.PropertyCodec.encode(ProviderCodecs.kt:243)
        at org.gradle.configurationcache.serialization.codecs.PropertyCodec.encode(ProviderCodecs.kt:235)
        at org.gradle.configurationcache.serialization.codecs.BindingsBackedCodec.encode(BindingsBackedCodec.kt:52)
        at org.gradle.configurationcache.serialization.DefaultWriteContext.write(Contexts.kt:80)
        at org.gradle.configurationcache.serialization.beans.BeanPropertyWriterKt.writeNextProperty(BeanPropertyWriter.kt:100)

Could it be related to the the asFile() extension applied in the plugin?

 val generatedVersionCode = generateAppVersionInfo.map { it.versionCodeFile.asFile.get().readText().trim().toInt() }

I have both incremental, local Gradle cache and remote Gradle cache enabled. It smells somewhat like a caching key issue.

It’s weird that it didn’t happen before on my intel Mac using adopt open jdk 11.

I googled this old(er) gradle issue, but it doesn’t seem 1:1 https://github.com/gradle/gradle/issues/19249

ychescale9 commented 2 years ago

Is this issue 100% reproducible or intermittent? Have you tried with a newer version of JDK?

Wrywulf commented 2 years ago

I updated my comment with more info - sorry I thought I could make it before you read it.

I have not tried with a newer version than JDK 11.0.15

The problem is pretty consistent for me. Although I have been able to build some targets. But I think that was with an empty cache. I'll try to find a more reproducible path

Wrywulf commented 2 years ago

The problem seems to be related to gradle configuration cache (for me).

I had it permanently enabled in my gradle.properties. After disabling it, I see no problems (so far). Since it is an incubating feature still, I suppose this issue is more like a heads up then.

It just seems a bit weird that it is happening only on my new machine - I did not see it at all on my intel-based mac, as mentioned.

For posterity here's some context for the issue:

ychescale9 commented 2 years ago

Thanks, I'll do some testing myself

joharei commented 1 year ago

I'm having the same issue. I have configuration cache enabled, and this issue happens after running e.g., gradle clean, and then trying to build or run the generateAppVersionInfoForX. Locally, I can work around this by adding --no-configuration-cache for one build, and the subsequent ones will work fine. My main issue is running this on a CI where I'm using cache.

ychescale9 commented 1 year ago

Hi @joharei can you please share the following?