jib icon indicating copy to clipboard operation
jib copied to clipboard

jibBuildTar is wrongly UP-TO-DATE

Open AcidSepp opened this issue 3 years ago • 4 comments

Environment:

  • Jib version: 3.2.1
  • Build tool: Gradle
  • OS: MacOS, M1

Description of the issue: The jibBuildTar is UP-TO-DATE although the compileJava task is not.

Expected behavior:

  • Changes to the code will cause the jibBuildTar to not be UP-TO-DATE

Steps to reproduce:

  1. Change code
  2. ./gradlew jibBuildTar
  3. Change code again
  4. ./gradlew jibBuildTar => UP-TO-DATE

build.gradle.kts

plugins {
    java
    id("com.google.cloud.tools.jib")
}

jib {
    from {
        image = "openjdk:11-jre-slim"
    }
}

settings.gradle.kts

rootProject.name = "jib-reproducer"

pluginManagement {
    plugins {
        id("com.google.cloud.tools.jib") version "3.2.1"
    }
}

Log output:

Run 1:

> Task :compileJava
Caching disabled for task ':compileJava' because:
  Build cache is disabled
Task ':compileJava' is not up-to-date because:
  Output property 'destinationDirectory' file /Users/yannick/IdeaProjects/jib-r?producer/build/classes/java/main has been removed.
  Output property 'destinationDirectory' file /Users/yannick/IdeaProjects/jib-r?producer/build/classes/java/main/org has been removed.
  Output property 'destinationDirectory' file /Users/yannick/IdeaProjects/jib-r?producer/build/classes/java/main/org/test has been removed.
The input changes require a full rebuild for incremental task ':compileJava'.
Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
Compiling with toolchain '/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home'.
Compiling with JDK Java compiler API.
Class dependency analysis for incremental compilation took 0.0 secs.
Created classpath snapshot for incremental compilation in 0.0 secs.
:compileJava (Thread[Execution worker for ':',5,main]) completed. Took 0.036 secs.
:processResources (Thread[Execution worker for ':',5,main]) started.

> Task :processResources NO-SOURCE
Skipping task ':processResources' as it has no source files and no previous output files.
:processResources (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs.
:classes (Thread[Execution worker for ':',5,main]) started.

> Task :classes
Skipping task ':classes' as it has no actions.
:classes (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs.
:jibBuildTar (Thread[Execution worker for ':',5,main]) started.

> Task :jibBuildTar
Caching disabled for task ':jibBuildTar' because:
  Build cache is disabled
Task ':jibBuildTar' is not up-to-date because:
  Implementation of input property 'jib.from.platforms.$0' has changed for task ':jibBuildTar'
  Value of input property 'jib.from.platforms.$0.architecture' has changed for task ':jibBuildTar'
Tagging image with generated image reference jib-reproducer:latest. If you'd like to specify a different tag, you can set the jib.to.image parameter in your build.gradle, or use the --image=<MY IMAGE> commandline flag.
Searching for main class... Add a 'mainClass' configuration to 'jib' to improve build speed.
Could not find a valid main class from 'jar' task; looking into all class files to infer main class.

Run 2:

> Task :compileJava
Caching disabled for task ':compileJava' because:
  Build cache is disabled
Task ':compileJava' is not up-to-date because:
  Input property 'stableSources' file /Users/yannick/IdeaProjects/jib-r?producer/src/main/java/org/test/Main.java has changed.
Created classpath snapshot for incremental compilation in 0.0 secs.
Compiling with toolchain '/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home'.
Compiling with JDK Java compiler API.
Incremental compilation of 1 classes completed in 0.009 secs.
Class dependency analysis for incremental compilation took 0.0 secs.
:compileJava (Thread[Execution worker for ':',5,main]) completed. Took 0.015 secs.
:processResources (Thread[Execution worker for ':',5,main]) started.

> Task :processResources NO-SOURCE
Skipping task ':processResources' as it has no source files and no previous output files.
:processResources (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs.
:classes (Thread[Execution worker for ':',5,main]) started.

> Task :classes
Skipping task ':classes' as it has no actions.
:classes (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs.
:jibBuildTar (Thread[Execution worker for ':',5,main]) started.

> Task :jibBuildTar UP-TO-DATE
Caching disabled for task ':jibBuildTar' because:
  Build cache is disabled
Skipping task ':jibBuildTar' as it is up-to-date.
:jibBuildTar (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs.

AcidSepp avatar May 13 '22 07:05 AcidSepp

Even though :compileJava is executed, the :classes task that depends on :compileJava was skipped.

> Task :classes
Skipping task ':classes' as it has no actions.

Did you really make a meaningful change to the code?

chanseokoh avatar May 13 '22 18:05 chanseokoh

classes is a lifecycle task (https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:lifecycle_tasks) and never executes, it only "combines" tasks (in this case compileJava and processResources).

Did you really make a meaningful change to the code?

Yes, see this line:

Task ':compileJava' is not up-to-date because:
  Input property 'stableSources' file /Users/yannick/IdeaProjects/jib-r?producer/src/main/java/org/test/Main.java has changed.

SgtSilvio avatar May 16 '22 11:05 SgtSilvio

Yeah, looks like this is an easily reproducible bug.

chanseokoh avatar May 16 '22 14:05 chanseokoh

We'd be happy to accept a fix PR for this issue.

elefeint avatar May 16 '22 15:05 elefeint

Reproduced and opening #3793 to address this issue, which seems to be happening due to input files for this task no longer including class and resource outputs for the main SourceSet as it previously did.

In the meanwhile, please use the --rerun-tasks flag in gradle to force run the task as a workaround. Thanks again for reporting this!

emmileaf avatar Sep 23 '22 17:09 emmileaf

jib-gradle-plugin 3.3.1 has been released with this fix.

emmileaf avatar Oct 28 '22 20:10 emmileaf