-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #413 from gnodet/i351
Support -r / --resume option, fixes #351
- Loading branch information
Showing
7 changed files
with
522 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
daemon/src/main/java/org/mvndaemon/mvnd/execution/BuildResumptionAnalyzer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mvndaemon.mvnd.execution; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import java.util.Optional; | ||
import org.apache.maven.execution.MavenExecutionResult; | ||
|
||
/** | ||
* Instances of this class are responsible for determining whether it makes sense to "resume" a build (i.e., using | ||
* the {@code --resume} flag. | ||
*/ | ||
public interface BuildResumptionAnalyzer { | ||
/** | ||
* Construct an instance of {@link BuildResumptionData} based on the outcome of the current Maven build. | ||
* | ||
* @param result Outcome of the current Maven build. | ||
* @return A {@link BuildResumptionData} instance or {@link Optional#empty()} if resuming the build is not | ||
* possible. | ||
*/ | ||
Optional<BuildResumptionData> determineBuildResumptionData(final MavenExecutionResult result); | ||
} |
60 changes: 60 additions & 0 deletions
60
daemon/src/main/java/org/mvndaemon/mvnd/execution/BuildResumptionData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mvndaemon.mvnd.execution; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import java.util.List; | ||
|
||
/** | ||
* This class holds the information required to enable resuming a Maven build with {@code --resume}. | ||
*/ | ||
public class BuildResumptionData { | ||
/** | ||
* The list of projects that remain to be built. | ||
*/ | ||
private final List<String> remainingProjects; | ||
|
||
public BuildResumptionData(final List<String> remainingProjects) { | ||
this.remainingProjects = remainingProjects; | ||
} | ||
|
||
/** | ||
* Returns the projects that still need to be built when resuming. | ||
* | ||
* @return A list containing the group and artifact id of the projects. | ||
*/ | ||
public List<String> getRemainingProjects() { | ||
return this.remainingProjects; | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
daemon/src/main/java/org/mvndaemon/mvnd/execution/BuildResumptionDataRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mvndaemon.mvnd.execution; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import org.apache.maven.execution.MavenExecutionRequest; | ||
import org.apache.maven.project.MavenProject; | ||
|
||
/** | ||
* Instances of this interface retrieve and store data for the --resume / -r feature. This data is used to ensure newer | ||
* builds of the same project, that have the -r command-line flag, skip successfully built projects during earlier | ||
* invocations of Maven. | ||
*/ | ||
public interface BuildResumptionDataRepository { | ||
/** | ||
* Persists any data needed to resume the build at a later point in time, using a new Maven invocation. This method | ||
* may also decide it is not needed or meaningful to persist such data, and return <code>false</code> to indicate | ||
* so. | ||
* | ||
* @param rootProject The root project that is being built. | ||
* @param buildResumptionData Information needed to resume the build. | ||
* @throws BuildResumptionPersistenceException When an error occurs while persisting data. | ||
*/ | ||
void persistResumptionData(final MavenProject rootProject, final BuildResumptionData buildResumptionData) | ||
throws BuildResumptionPersistenceException; | ||
|
||
/** | ||
* Uses previously stored resumption data to enrich an existing execution request. | ||
* | ||
* @param request The execution request that will be enriched. | ||
* @param rootProject The root project that is being built. | ||
*/ | ||
void applyResumptionData(final MavenExecutionRequest request, final MavenProject rootProject); | ||
|
||
/** | ||
* Removes previously stored resumption data. | ||
* | ||
* @param rootProject The root project that is being built. | ||
*/ | ||
void removeResumptionData(final MavenProject rootProject); | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
daemon/src/main/java/org/mvndaemon/mvnd/execution/BuildResumptionPersistenceException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mvndaemon.mvnd.execution; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/** | ||
* This exception will be thrown when something fails while persisting build resumption data. | ||
* | ||
* @see BuildResumptionDataRepository#persistResumptionData | ||
*/ | ||
public class BuildResumptionPersistenceException extends Exception { | ||
public BuildResumptionPersistenceException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
Oops, something went wrong.