-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First step to manage timeout in Maven goals based on the output #351
- Loading branch information
Showing
15 changed files
with
192 additions
and
59 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
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
56 changes: 56 additions & 0 deletions
56
...peline/src/main/java/fr/inria/spirals/repairnator/process/maven/RunnableMavenInvoker.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,56 @@ | ||
package fr.inria.spirals.repairnator.process.maven; | ||
|
||
import org.apache.maven.shared.invoker.DefaultInvocationRequest; | ||
import org.apache.maven.shared.invoker.DefaultInvoker; | ||
import org.apache.maven.shared.invoker.InvocationRequest; | ||
import org.apache.maven.shared.invoker.InvocationResult; | ||
import org.apache.maven.shared.invoker.Invoker; | ||
import org.apache.maven.shared.invoker.MavenInvocationException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
|
||
public class RunnableMavenInvoker implements Runnable { | ||
private final Logger logger = LoggerFactory.getLogger(RunnableMavenInvoker.class); | ||
|
||
private MavenHelper mavenHelper; | ||
private int exitCode; | ||
|
||
public RunnableMavenInvoker(MavenHelper mavenHelper) { | ||
this.mavenHelper = mavenHelper; | ||
this.exitCode = -1; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
InvocationRequest request = new DefaultInvocationRequest(); | ||
request.setPomFile(new File(this.mavenHelper.getPomFile())); | ||
request.setGoals(Arrays.asList(this.mavenHelper.getGoal())); | ||
|
||
request.setProperties(this.mavenHelper.getProperties()); | ||
|
||
Invoker invoker = new DefaultInvoker(); | ||
|
||
if (this.mavenHelper.getErrorHandler() != null) { | ||
invoker.setErrorHandler(this.mavenHelper.getErrorHandler()); | ||
} | ||
invoker.setOutputHandler(this.mavenHelper.getOutputHandler()); | ||
|
||
try { | ||
InvocationResult result = invoker.execute(request); | ||
this.exitCode = result.getExitCode(); | ||
} catch (MavenInvocationException e) { | ||
this.logger.error("Error while executing goal :" + this.mavenHelper.getGoal() + " on the following pom file: " + this.mavenHelper.getPomFile() | ||
+ ". Properties: " + this.mavenHelper.getProperties()); | ||
this.logger.debug(e.getMessage()); | ||
this.mavenHelper.getInspector().getJobStatus().addStepError(this.mavenHelper.getName(), e.getMessage()); | ||
this.exitCode = MavenHelper.MAVEN_ERROR; | ||
} | ||
} | ||
|
||
public int getExitCode() { | ||
return exitCode; | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
...ne/src/main/java/fr/inria/spirals/repairnator/process/maven/output/MavenErrorHandler.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
7 changes: 4 additions & 3 deletions
7
...main/java/fr/inria/spirals/repairnator/process/maven/output/MavenFilterOutputHandler.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
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
7 changes: 4 additions & 3 deletions
7
...c/main/java/fr/inria/spirals/repairnator/process/maven/output/MavenMuteOutputHandler.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
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
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
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
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
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
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
Oops, something went wrong.