/
AttachDeployedArtifactsMojo.java
52 lines (50 loc) · 2.24 KB
/
AttachDeployedArtifactsMojo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.e_gineering.maven.gitflowhelper;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
/**
* When executed, attaches artifacts from a previously deployed (to a repository) build of this
* project to the current build execution.
*/
@Mojo(name = "attach-deployed", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true)
@Execute(phase = LifecyclePhase.CLEAN)
public class AttachDeployedArtifactsMojo extends AbstractGitflowBasedRepositoryMojo {
@Override
protected void execute(final GitBranchInfo gitBranchInfo) throws MojoExecutionException, MojoFailureException {
switch (gitBranchInfo.getType()) {
case MASTER:
case SUPPORT:
{
getLog().info("Attaching artifacts from release repository...");
attachExistingArtifacts(releaseDeploymentRepository, true);
break;
}
case RELEASE:
case HOTFIX: {
getLog().info("Attaching artifacts from stage repository...");
attachExistingArtifacts(stageDeploymentRepository, true);
break;
}
case DEVELOPMENT: {
getLog().info("Attaching artifacts from snapshot repository...");
attachExistingArtifacts(snapshotDeploymentRepository, true);
break;
}
case OTHER: {
String otherBranchesToDeploy = resolveExpression(otherDeployBranchPattern);
if (!"".equals(otherBranchesToDeploy) && gitBranchInfo.getName().matches(otherBranchesToDeploy)) {
getLog().info("Attaching branch artifacts from snapshot repository...");
attachExistingArtifacts(snapshotDeploymentRepository, true);
break;
}
}
default: {
getLog().info("Attaching Artifacts from local repository...");
// Use the 'local' repository to do this.
attachExistingArtifacts(null, false);
}
}
}
}