Skip to content
Permalink
Browse files

[JENKINS-46148] - Avoid using deprecated APIs

  • Loading branch information...
oleg-nenashev committed Aug 11, 2017
1 parent 4826ae7 commit a7b4824df1f16b5ea44bb58e4b5ef11424a4695e
Showing with 29 additions and 3 deletions.
  1. +29 −3 src/main/java/hudson/maven/MavenBuild.java
@@ -96,6 +96,9 @@

import jenkins.model.ArtifactManager;
import jenkins.mvn.SettingsProvider;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.ProjectSorter;
import org.codehaus.plexus.util.dag.CycleDetectedException;

/**
* {@link Run} for {@link MavenModule}.
@@ -347,18 +350,41 @@ public void executeAsync(final BuildCallable<?,?> program) throws IOException {

private static final long serialVersionUID = 1L;
}


/**
* @deprecated Used APIs are deprecated and probably unstable according to
* {@link ProjectSorter#getTopLevelProject()} comments.
*/
@Deprecated
@CheckForNull
private static MavenProject getTopLevelProject(ReactorManager rm) throws BuildFailureException {
List<MavenProject> sortedProjects = rm.getSortedProjects();
if (sortedProjects.isEmpty()) {
return null;
}

final ProjectSorter sorter;
try {
sorter = new ProjectSorter(sortedProjects);
} catch(CycleDetectedException ex) {
throw new BuildFailureException("Cannot retrieve the top-level project due to the cycle", ex);
} catch(DuplicateProjectException ex) {
throw new BuildFailureException("Cannot retrieve the duplicate in the project list", ex);
}
return sorter.getTopLevelProject();
}

@Override
void preBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException, IOException, InterruptedException {
for (MavenReporter r : reporters.get(moduleName))
r.preBuild(buildProxy,rm.getTopLevelProject(),listener);
r.preBuild(buildProxy,getTopLevelProject(rm),listener);
}

@Override
void postBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException, IOException, InterruptedException {
buildProxy.setExecutedMojos(executedMojos);
for (MavenReporter r : reporters.get(moduleName))
r.postBuild(buildProxy,rm.getTopLevelProject(),listener);
r.postBuild(buildProxy,getTopLevelProject(rm),listener);
}

@Override

0 comments on commit a7b4824

Please sign in to comment.
You can’t perform that action at this time.