apache / apache/maven-build-cache-extension

[MBUILDCACHE-70] Failed to restore project error if goal not specified via command line

Open
#320 0 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
163
Forks
77
Avg merge
1d 2h
Merged PRs (30d)
4

Description

**[Adrian Herscu](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=adrian.herscu@gmail.com)** opened **[MBUILDCACHE-70](https://issues.apache.org/jira/browse/MBUILDCACHE-70?redirect=false)** and commented

If Maven is launched without a goal, thus relying on the default goal defined in pom.xml, then the cache fails with:

18:29:50 [ERROR] Failed to restore project
java.util.NoSuchElementException
    at org.apache.maven.buildcache.CacheUtils.getLast (CacheUtils.java:138)
    at org.apache.maven.buildcache.xml.Build.getHighestCompletedGoal (Build.java:138)
    at org.apache.maven.buildcache.LifecyclePhasesHelper.isLaterPhaseThanBuild (LifecyclePhasesHelper.java:119)
    at org.apache.maven.buildcache.LifecyclePhasesHelper.getCachedSegment (LifecyclePhasesHelper.java:191)
    at org.apache.maven.buildcache.CacheControllerImpl.analyzeResult (CacheControllerImpl.java:248)
    at org.apache.maven.buildcache.CacheControllerImpl.findLocalBuild (CacheControllerImpl.java:222)
    at org.apache.maven.buildcache.CacheControllerImpl.findCachedBuild (CacheControllerImpl.java:187)
    at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute (BuildCacheMojosExecutionStrategy.java:117)
    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 sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    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)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)

 

Happens with Maven 3.9.4

---
No further details from [MBUILDCACHE-70](https://issues.apache.org/jira/browse/MBUILDCACHE-70?redirect=false)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the failure with Maven 3.9.4, no command-line goal, and a POM that defines a default goal. Read CacheUtils.getLast in CacheUtils.java and Build.getHighestCompletedGoal in Build.java, then follow the callers in LifecyclePhasesHelper. Done means restoring the project no longer fails in this invocation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.