Uploaded image for project: 'Maven Build Cache Extension'
  1. Maven Build Cache Extension
  2. MBUILDCACHE-67

Any error in restoring from the cache should resume the non cache build

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.1
    • 1.1.0
    • None

    Description

      If any error arise during the restoration of artefacts from the cache, the build should continue as it would usually do without the cache. In fact, it's even what the extension says "Cannot restore cache, continuing with normal build."

      But it's a lie, the build goes straight to the phase where it saves the generated artefact in cache.

      [DEBUG] Hash calculated, item: dependency, hash: 14eab0591a006938
      [INFO] Project inputs calculated in 97 ms. XX checksum [a0d7876d9bceb494] calculated in 50 ms.
      [INFO] Attempting to restore project io.github.kbuntrock.sample:openapi-plugin-sample-backend from build cache
      [DEBUG] Checking local build info: C:\Users\kbuntrock\.m2\build-cache\v1\io.github.kbuntrock.sample\openapi-plugin-sample-backend\a0d7876d9bceb494\local\buildinfo.xml
      [INFO] Local build found by checksum a0d7876d9bceb494
      [INFO] Found cached build, restoring io.github.kbuntrock.sample:openapi-plugin-sample-backend from cache by checksum a0d7876d9bceb494
      [DEBUG] Cached build details: Build{dto=org.apache.maven.buildcache.xml.build.Build@63cf9de0}
      [DEBUG] Cannot restore cache, continuing with normal build.
      java.lang.RuntimeException: Made-up error : restoring artefact is impossible.
          at org.apache.maven.buildcache.CacheControllerImpl.restoreProjectArtifacts (CacheControllerImpl.java:312)
          at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.restoreProject (BuildCacheMojosExecutionStrategy.java:171)
          at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute (BuildCacheMojosExecutionStrategy.java:124)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
          at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
          at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
          at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
          at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
          at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
          at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke (Method.java:568)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
      [INFO] Cannot restore project artifacts, continuing with non cached build
      [INFO] Saved Build to local file: C:\Users\kbuntrock\.m2\build-cache\v1\io.github.kbuntrock.sample\openapi-plugin-sample-backend\a0d7876d9bceb494\local\buildinfo.xml
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time:  0.629 s
      [INFO] Finished at: 2023-08-02T23:21:36+02:00
      [INFO] ------------------------------------------------------------------------
      [DEBUG] Save cache-report to local file: C:\Users\kbuntrock\Developpement\sample\target\maven-incremental\cache-report.662d75e1-1a0e-407a-85aa-21da4d207498.xml 

      While trying to reproduce the error with a more convenient use case, it seems that erasing the artefact from the repository (local in my case) does not throw any restoration error (the build is set by default to "lazyRestore = false").

      Here is a screenshot of a normal execution where the artefact is correctly loaded :

      [INFO] Found cached build, restoring io.github.kbuntrock.sample:openapi-plugin-sample-backend from cache by checksum a0d7876d9bceb494
      [DEBUG] Cached build details: Build{dto=org.apache.maven.buildcache.xml.build.Build@5befbac1}
      [DEBUG] Downloading artifact openapi-plugin-sample-backend
      [DEBUG] Downloaded artifact openapi-plugin-sample-backend to: C:\Users\kbuntrock\.m2\build-cache\v1\io.github.kbuntrock.sample\openapi-plugin-sample-backend\a0d7876d9bceb494\local\openapi-plugin-sample-backend.jar
      [INFO] Skipping plugin execution (cached): resources:resources
      [INFO] Skipping plugin execution (cached): compiler:compile 

      And the log of an execution where the file is missing on the filesystem. We can see a missing line but no further effect on the cached build.

      [INFO] Found cached build, restoring io.github.kbuntrock.sample:openapi-plugin-sample-backend from cache by checksum a0d7876d9bceb494
      [DEBUG] Cached build details: Build{dto=org.apache.maven.buildcache.xml.build.Build@5befbac1}
      [DEBUG] Downloading artifact openapi-plugin-sample-backend
      [INFO] Skipping plugin execution (cached): resources:resources
      [INFO] Skipping plugin execution (cached): compiler:compile

      If the artefact is used in a dependant module build, the expected error arise : " Error retrieving artifact file: Missing file for cached build, cannot restore.". But since we are not in lazy restore, we exept it earlier.

       

      I would suggest to correct / test the two bugs in the MR since it will be far easier to do so (it is why I created only one issue).

       

      NB : The bugfix MR will follow.

      Attachments

        Issue Links

          Activity

            People

              olamy Olivier Lamy
              Kevin Buntrock Kevin Buntrock
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: