Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-5760] Add --resume / -r switch #342

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
07b60e4
[MNG-5760] When a build fails, write file with properties to resume t…
MartinKanters May 4, 2020
fe48f1b
[MNG-5760] Refactored the getResumeFromSelector logic to be compliant…
MartinKanters May 22, 2020
883d806
[MNG-5760] Added JavaDoc to the method which determines whether a res…
MartinKanters May 22, 2020
c467598
[MNG-5760] Added license to BuildResumptionManagerTest
MartinKanters May 22, 2020
0dc3c0b
[MNG-5760] When -r is given, load resume.properties and apply it to t…
MartinKanters May 22, 2020
a65ecc3
[MNG-5760] Created unit tests for the resumeFromSelector method.
MartinKanters May 22, 2020
79df2e5
[MNG-5760] Removed dead code, as the `getResumeFrom` method has been …
MartinKanters May 22, 2020
8d7f51c
[MNG-5760] Fix bug where the build resume hint log could be logged in…
MartinKanters May 22, 2020
fe92235
[MNG-5760] Fixed a bug where a failed project would be excluded in th…
MartinKanters May 23, 2020
368b60b
[MNG-5760] Refactored to call the resumption manager from the Default…
MartinKanters May 23, 2020
712932d
[MNG-5760] Removing the resumption data when a build succeeded.
MartinKanters May 23, 2020
2763ee0
[MNG-5760] Extract public interface
mthmulders May 23, 2020
7bc1e06
[MNG-5760] Store information about resumption storage in execution re…
mthmulders May 23, 2020
c7fee3f
[MNG-5760] Replace Stream#filter#count with Stream#anyMatch
mthmulders May 25, 2020
b93dbfd
[MNG-5760] Avoid stringly-typed method signatures
mthmulders May 25, 2020
8bcaa9f
[MNG-5760] Rename resumptionDataStored to canResume
mthmulders May 25, 2020
77e5d53
[MNG-5760] Replace Plexus logger with SLF4J
mthmulders May 25, 2020
d33702d
[MNG-5760] Replace String#format with String concatenation
mthmulders May 25, 2020
40ab881
Merge remote-tracking branch 'origin/master' into mng-5760-resume-fea…
MartinKanters Jun 3, 2020
5a130ea
[MNG-5760] Renamed BuildResumptionManager to BuildResumer
MartinKanters Jun 5, 2020
7801922
[MNG-5760] Removed an unused mock for the plexus Logger, which is a l…
MartinKanters Jun 5, 2020
5a4a946
[MNG-5760] Resolving review comment; clearing up persistResumptionDat…
MartinKanters Jun 5, 2020
557ec1c
[MNG-5760] Review comment: Removed Guava's @VisibleForTesting
MartinKanters Jun 5, 2020
08e3a61
[MNG-5760] When something fails while persisting resumption data, thr…
MartinKanters Jun 5, 2020
c86da3b
[MNG-5760] Add a boolean to the setCanResume method, which denotes wh…
MartinKanters Jun 5, 2020
2d5c380
[MNG-5760] Fixed checkstyle findings
MartinKanters Jun 5, 2020
41faa43
[MNG-5760] Moved the -rf helper method, including the tests, back to …
MartinKanters Jun 6, 2020
d87dcbf
[MNG-5760] Rename interface and implementation
mthmulders Jun 17, 2020
4e35d21
[MNG-5760] Refactored `#determineProjectsToSkip` to return a list ins…
MartinKanters Jun 17, 2020
9a43e1a
[MNG-5760] Split off BuildResumptionAnalyzer from BuildResumptionData…
mthmulders Jun 17, 2020
adf8c6f
[MNG-5760] Persist method either succeeds or throws Exception, so ret…
mthmulders Jun 18, 2020
058fa9e
[MNG-5760] Removed unused import
MartinKanters Jun 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions maven-core/src/main/java/org/apache/maven/DefaultMaven.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,21 @@ private void afterSessionEnd( Collection<MavenProject> projects, MavenSession se

private void saveResumptionDataWhenApplicable( MavenExecutionResult result, MavenSession session )
mthmulders marked this conversation as resolved.
Show resolved Hide resolved
{
List<LifecycleExecutionException> lifecycleExecutionExceptions = result.getExceptions().stream()
long lifecycleExecutionExceptionCount = result.getExceptions().stream()
.filter( LifecycleExecutionException.class::isInstance )
.map( LifecycleExecutionException.class::cast )
.collect( Collectors.toList() );
.count();
mthmulders marked this conversation as resolved.
Show resolved Hide resolved

if ( !lifecycleExecutionExceptions.isEmpty() )
if ( lifecycleExecutionExceptionCount > 0 )
{
session.getAllProjects().stream()
.filter( MavenProject::isExecutionRoot )
.findFirst()
.ifPresent( rootProject ->
{
boolean persisted = buildResumptionManager.persistResumptionData( result, rootProject );
lifecycleExecutionExceptions.forEach( e -> e.setBuildResumptionDataSaved( persisted ) );
if ( buildResumptionManager.persistResumptionData( result, rootProject ) )
{
result.setResumptionDataStored();
}
} );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class DefaultMavenExecutionResult
private final Map<MavenProject, BuildSummary> buildSummaries =
Collections.synchronizedMap( new IdentityHashMap<>() );

private boolean resumptionDataStored = false;

public MavenExecutionResult setProject( MavenProject project )
{
this.project = project;
Expand Down Expand Up @@ -108,4 +110,16 @@ public void addBuildSummary( BuildSummary summary )
{
buildSummaries.put( summary.getProject(), summary );
}

@Override
public boolean isResumptionDataStored()
{
return resumptionDataStored;
}

@Override
public void setResumptionDataStored()
{
this.resumptionDataStored = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,18 @@ public interface MavenExecutionResult
* @param summary The build summary to add, must not be {@code null}.
*/
void addBuildSummary( BuildSummary summary );

/**
* Indicates whether or not resumption data has been stored.
* @see org.apache.maven.execution.BuildResumptionManager
* @return <code>true</code> when it is possible to resume the build, <code>false</code> otherwise.
*/
boolean isResumptionDataStored();

/**
* Indicate that resumption data has been stored.
* @see org.apache.maven.execution.BuildResumptionManager
* @see #isResumptionDataStored()
*/
void setResumptionDataStored();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public class LifecycleExecutionException
{
private MavenProject project;

private boolean buildResumptionDataSaved = false;

public LifecycleExecutionException( String message )
{
super( message );
Expand Down Expand Up @@ -78,16 +76,6 @@ public MavenProject getProject()
return project;
}

public boolean isBuildResumptionDataSaved()
{
return buildResumptionDataSaved;
}

public void setBuildResumptionDataSaved( boolean isBuildResumptionDataSaved )
{
this.buildResumptionDataSaved = isBuildResumptionDataSaved;
}

private static String createMessage( MojoExecution execution, MavenProject project, Throwable cause )
{
MessageBuilder buffer = buffer( 256 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,6 @@ private int execute( CliRequest cliRequest )
Map<String, String> references = new LinkedHashMap<>();

MavenProject project = null;
boolean isResumptionDataSaved = false;

for ( Throwable exception : result.getExceptions() )
{
Expand All @@ -1004,7 +1003,6 @@ private int execute( CliRequest cliRequest )
{
LifecycleExecutionException lifecycleExecutionException = (LifecycleExecutionException) exception;
project = lifecycleExecutionException.getProject();
isResumptionDataSaved = lifecycleExecutionException.isBuildResumptionDataSaved();
}
}

Expand Down Expand Up @@ -1034,7 +1032,7 @@ private int execute( CliRequest cliRequest )
}

List<MavenProject> sortedProjects = result.getTopologicallySortedProjects();
if ( isResumptionDataSaved )
if ( result.isResumptionDataStored() )
{
logBuildResumeHint( "mvn <args> -r " );
}
Expand Down