• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

git-commit-id / git-commit-id-maven-plugin / #219

04 Dec 2023 07:24PM CUT coverage: 71.134%. Remained the same
#219

push

web-flow
Merge pull request #676 from git-commit-id/dependabot/maven/org.apache.maven.plugins-maven-javadoc-plugin-3.6.3

Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.2 to 3.6.3

276 of 388 relevant lines covered (71.13%)

0.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.56
/src/main/java/pl/project13/maven/git/ReplacementProperty.java
1
/*
2
 * This file is part of git-commit-id-maven-plugin by Konrad 'ktoso' Malawski <konrad.malawski@java.pl>
3
 *
4
 * git-commit-id-maven-plugin is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * git-commit-id-maven-plugin is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with git-commit-id-maven-plugin.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17

18
package pl.project13.maven.git;
19

20
import java.util.ArrayList;
21
import java.util.List;
22

23
import org.apache.maven.plugins.annotations.Parameter;
24

25
/**
26
 * This class represents a specific property replacement the user wants to perform.
27
 * For a use-case refer to https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/317.
28
 * @since 2.2.3
29
 */
30
public class ReplacementProperty {
31
  /**
32
   * Defines if a replacement should only be applied to a single property.
33
   * If left empty the replacement will be performed on all generated properties.
34
   */
35
  @Parameter
36
  private String property;
37

38
  /**
39
   * @since 2.2.4
40
   * Defines an additional output property suffix.
41
   * Note: 
42
   * this will only be *appended* to the current property key
43
   * (e.g. when the property is set to 'sample' the property
44
   * 'git.branch' will be transformed to 'git.branch.sample')
45
   * 
46
   * Be advised that you might want to adjust your include
47
   * or exclude filters which be applied after the regex validation.
48
   */
49
  @Parameter
50
  private String propertyOutputSuffix;
51

52
  /**
53
   * Token to replace.
54
   * This may or may not be a regular expression.
55
   */
56
  @Parameter(required = true)
57
  private String token;
58

59
  /**
60
   * Value to replace token with.
61
   * The text to be written over any found tokens. 
62
   * You can also reference grouped regex matches made in the token here by $1, $2, etc.
63
   */
64
  @Parameter(defaultValue = "")
1✔
65
  private String value = "";
66

67
  /**
68
   * Indicates if the token should be located with regular expressions. 
69
   */
70
  @Parameter(defaultValue = "true")
1✔
71
  private boolean regex = true;
72

73
  /**
74
   * Forces the plugin to evaluate the value on *every* project.
75
   * Note that this essentially means that the plugin *must* run for every child-project of a reactor
76
   * build and thus might cause some overhead (the git properties should be cached).
77
   *
78
   * For a use-case refer to https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/457.
79
   */
80
  @Parameter(defaultValue = "false")
1✔
81
  private boolean forceValueEvaluation = false;
82

83
  /**
84
   * @since 2.2.4
85
   * Provides the ability to perform certain string transformations before regex evaluation or after.
86
   */
87
  @Parameter
1✔
88
  private List<TransformationRule> transformationRules = new ArrayList<>();
89

90
  /**
91
   * Empty constructor
92
   */
93
  public ReplacementProperty() {
×
94
  }
×
95

96
  /**
97
   * Constructs a specific property replacement the user wants to perform.
98
   * @param property The source (input) property on which the replacements should be performed (e.g. {@code git.branch})
99
   * @param propertyOutputSuffix The property output suffix where the replacement result should be stored in (e.g. {@code git.branch-no-slashes})
100
   * @param token The replacement token acts as {@code needle} that will be searched in the input property (e.g. {@code ^([^\/]*)\/([^\/]*)$})
101
   * @param value The value acts as the text to be written over any found tokens ("replacement").
102
   * @param regex If {@code true} the replacement will be performed with regular expressions or,
103
   *             if {@code false} performs a replacement with java's string.replace-function.
104
   * @param forceValueEvaluation If {@code true} forces the plugin to evaluate the given value on *every* project.
105
   *                             This might come handy if *every* project needs a unique value and a user wants to
106
   *                             project specific variables like {@code project.artifactId}.
107
   * @param transformationRules The list of transformation-rules that should be applied during replacement.
108
   */
109
  public ReplacementProperty(String property, String propertyOutputSuffix, String token, String value, boolean regex, boolean forceValueEvaluation, List<TransformationRule> transformationRules) {
1✔
110
    this.property = property;
1✔
111
    this.propertyOutputSuffix = propertyOutputSuffix;
1✔
112
    this.token = token;
1✔
113
    this.value = value;
1✔
114
    this.regex = regex;
1✔
115
    this.forceValueEvaluation = forceValueEvaluation;
1✔
116
    this.transformationRules = transformationRules;
1✔
117
  }
1✔
118

119
  /**
120
   * @return The source (input) property on which the replacements should be performed (e.g. {@code git.branch})
121
   */
122
  public String getProperty() {
123
    return property;
1✔
124
  }
125

126
  /**
127
   * Set the source (input) property on which the replacements should be performed (e.g. {@code git.branch})
128
   * @param property The source (input) property
129
   */
130
  public void setProperty(String property) {
131
    this.property = property;
×
132
  }
×
133

134
  /**
135
   * @return The property output suffix where the replacement result should be stored in (e.g. {@code git.branch-no-slashes})
136
   */
137
  public String getPropertyOutputSuffix() {
138
    return propertyOutputSuffix;
1✔
139
  }
140

141
  /**
142
   * Set the property output suffix where the replacement result should be stored in (e.g. {@code git.branch-no-slashes})
143
   * @param propertyOutputSuffix The property output suffix
144
   */
145
  public void setPropertyOutputSuffix(String propertyOutputSuffix) {
146
    this.propertyOutputSuffix = propertyOutputSuffix;
×
147
  }
×
148

149
  /**
150
   * @return The replacement token acts as {@code needle} that will be searched in the input property (e.g. {@code ^([^\/]*)\/([^\/]*)$})
151
   */
152
  public String getToken() {
153
    return token;
1✔
154
  }
155

156
  /**
157
   * Set the replacement token
158
   * @param token The replacement token
159
   */
160
  public void setToken(String token) {
161
    this.token = token;
×
162
  }
×
163

164
  /**
165
   * @return The value that acts as the text to be written over any found tokens ("replacement").
166
   */
167
  public String getValue() {
168
    return value;
1✔
169
  }
170

171
  /**
172
   * Sets the value that acts as the text to be written over any found tokens ("replacement").
173
   * @param value The replacment value
174
   */
175
  public void setValue(String value) {
176
    this.value = value;
×
177
  }
×
178

179
  /**
180
   * @return Indicator if the replacement will be performed with regular expressions ({@code true}) or,
181
   * if a replacement with java's string.replace-function is performed ({@code false}).
182
   */
183
  public boolean isRegex() {
184
    return regex;
1✔
185
  }
186

187
  /**
188
   * Sets Indicator if the replacement will be performed with regular expressions ({@code true}) or,
189
   * if a replacement with java's string.replace-function is performed ({@code false}).
190
   * @param regex Indicator
191
   */
192
  public void setRegex(boolean regex) {
193
    this.regex = regex;
×
194
  }
×
195

196
  /**
197
   * @return Indicator if the plugin forces to evaluate the given value on *every* project ({@code true}).
198
   */
199
  public boolean isForceValueEvaluation() {
200
    return forceValueEvaluation;
1✔
201
  }
202

203
  /**
204
   * Sets Indicator if the plugin forces to evaluate the given value on *every* project ({@code true}).
205
   * @param forceValueEvaluation Indicator if the plugin forces to evaluate the given value on *every* project ({@code true}).
206
   */
207
  public void setForceValueEvaluation(boolean forceValueEvaluation) {
208
    this.forceValueEvaluation = forceValueEvaluation;
×
209
  }
×
210

211
  /**
212
   * @return The list of transformation-rules that should be applied during replacement.
213
   */
214
  public List<TransformationRule> getTransformationRules() {
215
    return transformationRules;
1✔
216
  }
217

218
  /**
219
   * Sets the list of transformation-rules that should be applied during replacement.
220
   * @param transformationRules The list of transformation-rules
221
   */
222
  public void setTransformationRules(List<TransformationRule> transformationRules) {
223
    this.transformationRules = transformationRules;
×
224
  }
×
225
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc