Skip to content

Instantly share code, notes, and snippets.

@robinhowlett
Created May 15, 2019 20:58
Show Gist options
  • Save robinhowlett/1d1f6a98cbf611cdc4dc0ccdd542c354 to your computer and use it in GitHub Desktop.
Save robinhowlett/1d1f6a98cbf611cdc4dc0ccdd542c354 to your computer and use it in GitHub Desktop.
/**
* When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready
* to be deployed
*/
private static final AtomicInteger readyProjectsCounter = new AtomicInteger();
...
public void execute()
throws MojoExecutionException, MojoFailureException {
boolean addedDeployRequest = false;
if (skip) {
getLog().info("Skipping artifact deployment");
} else {
failIfOffline();
DeployRequest currentExecutionDeployRequest =
new DeployRequest().setProject(project).setUpdateReleaseInfo(isUpdateReleaseInfo()).setRetryFailedDeploymentCount(getRetryFailedDeploymentCount()).setAltReleaseDeploymentRepository(altReleaseDeploymentRepository).setAltSnapshotDeploymentRepository(altSnapshotDeploymentRepository).setAltDeploymentRepository(altDeploymentRepository);
if (!deployAtEnd) {
deployProject(currentExecutionDeployRequest);
} else {
deployRequests.add(currentExecutionDeployRequest);
addedDeployRequest = true;
}
}
boolean projectsReady = readyProjectsCounter.incrementAndGet() == reactorProjects.size();
if (projectsReady) {
synchronized (deployRequests) {
while (!deployRequests.isEmpty()) {
deployProject(deployRequests.remove(0));
}
}
} else if (addedDeployRequest) {
getLog().info("Deploying " + project.getGroupId() + ":" + project.getArtifactId() + ":"
+ project.getVersion() + " at end");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment