1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.maven.bugzilla;
17
18 import static de.smartics.maven.issue.util.VersionHelper.CURRENT;
19 import static de.smartics.maven.issue.util.VersionHelper.MAJOR;
20 import static de.smartics.maven.issue.util.VersionHelper.MICRO;
21 import static de.smartics.maven.issue.util.VersionHelper.MINOR;
22 import static de.smartics.maven.issue.util.VersionHelper.SNAPSHOT;
23 import static de.smartics.maven.issue.util.VersionHelper.getVersionStrippedFromSnapshotSuffix;
24
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.plugin.MojoFailureException;
27 import org.apache.maven.project.MavenProject;
28
29 import de.smartics.maven.issue.util.VersionHelper;
30
31
32
33
34 final class MojoHelperSync extends AbstractMojoHelper
35 {
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 protected MojoHelperSync(final MavenProject project,
58 final MavenCommandFactory commandFactory, final Console console)
59 {
60 super(project, commandFactory, console);
61 }
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 void execute(final String releasedVersion) throws MojoExecutionException,
77 MojoFailureException
78 {
79 final String product = project.getArtifactId();
80
81 final String normalizedVersion = normalize(releasedVersion);
82 final MojoHelperVersion versionHelper =
83 new MojoHelperVersion(project, commandFactory, console);
84 versionHelper.run(product, normalizedVersion);
85
86 final VersionHelper helper = new VersionHelper(normalizedVersion);
87 final MojoHelperMilestone milestoneHelper =
88 new MojoHelperMilestone(project, commandFactory, console);
89
90 final String micro =
91 !SNAPSHOT.equals(releasedVersion) ? helper.calculateNextVersion(MICRO)
92 : getVersionStrippedFromSnapshotSuffix(project.getVersion());
93 milestoneHelper.run(product, micro, null);
94 final String minor = helper.calculateNextVersion(MINOR);
95 milestoneHelper.run(product, minor, null);
96 final String major = helper.calculateNextVersion(MAJOR);
97 milestoneHelper.run(product, major, null);
98 }
99
100 private String normalize(final String releasedVersion)
101 {
102 final String normalized;
103
104 if (SNAPSHOT.equals(releasedVersion))
105 {
106 normalized = project.getVersion();
107 }
108 else if (CURRENT.equals(releasedVersion))
109 {
110 normalized = getVersionStrippedFromSnapshotSuffix(project.getVersion());
111 }
112 else
113 {
114 normalized = releasedVersion;
115 }
116
117 return normalized;
118 }
119
120
121
122 }