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

Bugfix - Limit 'mvn deploy' to work with only install/deploy phases #626

Merged
merged 2 commits into from
Mar 16, 2022
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void sessionStarted(ExecutionEvent event) {
logger.info("Initializing Artifactory Build-Info Recording");
buildInfoBuilder = buildInfoModelPropertyResolver.resolveProperties(event, conf);
deployableArtifactBuilderMap = new ConcurrentHashMap<>();
skipDefaultDeploy(event.getSession());
setDeploymentPolicy(event);

if (wrappedListener != null) {
wrappedListener.sessionStarted(event);
Expand Down Expand Up @@ -729,9 +729,20 @@ private void cleanUpModule() {
}

/**
* Skip the default maven deploy behaviour.
* Only Maven deploy / install goals are supposed to upload artifacts to artifactory.
* Other than that, we don't upload artifacts.
*/
private void skipDefaultDeploy(MavenSession session) {
session.getUserProperties().put("maven.deploy.skip", Boolean.TRUE.toString());
private void setDeploymentPolicy(ExecutionEvent event) {
List<String> goals = event.getSession().getRequest().getGoals();
// Override the default Maven deploy behavior with Artifactory.
if (goals.contains("deploy")) {
event.getSession().getUserProperties().put("maven.deploy.skip", Boolean.TRUE.toString());
return;
}
// Skip the artifact deployment behavior if the goals do not contain install phases.
if (!goals.contains("install")) {
conf.publisher.setPublishArtifacts(false);
conf.publisher.setPublishBuildInfo(false);
}
}
}