Skip to content

Commit f63c67f

Browse files
committed
improved formatting for command line help display
1 parent 7dd2e85 commit f63c67f

File tree

2 files changed

+52
-124
lines changed

2 files changed

+52
-124
lines changed

pom.xml

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,12 @@
1111
<artifactId>git-commit-id-plugin</artifactId>
1212
<packaging>maven-plugin</packaging>
1313
<version>2.2.1-SNAPSHOT</version>
14-
<name>Git Commit Id Plugin Maven Mojo</name>
14+
<name>Git Commit Id Maven Plugin</name>
1515
<description>
1616
This plugin makes basic repository information available through maven resources. This can be used to display
17-
"what version is this?" or "who has deployed this and when, from which branch?" information at runtime - making
17+
"what version is this?" or "who has deployed this and when, from which branch?" information at runtime, making
1818
it easy to find things like "oh, that isn't deployed yet, I'll test it tomorrow" and making both testers and
19-
developers life easier.
20-
21-
git-commit-id-plugin is quite similar to
22-
https://fisheye.codehaus.org/browse/mojo/tags/buildnumber-maven-plugin-1.0-beta-4 for example but as buildnumber at
23-
the time when I started this plugin only supported CVS and SVN, something had to be done.
24-
25-
The data currently exported is like this (that's the end effect from the GitRepositoryState Bean):
26-
{
27-
"branch" : "testing-maven-git-plugin",
28-
"commitTime" : "06.01.1970 @ 16:16:26 CET",
29-
"commitId" : "787e39f61f99110e74deed68ab9093088d64b969",
30-
"commitUserName" : "Konrad Malawski",
31-
"commitUserEmail" : "konrad.malawski@java.pl",
32-
"commitMessageFull" : "releasing my fun plugin :-) + fixed some typos + cleaned up directory structure + added
33-
license etc",
34-
"commitMessageShort" : "releasing my fun plugin :-)",
35-
"buildTime" : "06.01.1970 @ 16:17:53 CET",
36-
"buildUserName" : "Konrad Malawski",
37-
"buildUserEmail" : "konrad.malawski@java.pl"
38-
}
39-
40-
Note that the data is exported via maven resource filtering and is really easy to use with Spring -
41-
which I've explained in detail in this readme https://github.com/ktoso/maven-git-commit-id-plugin
19+
developers life easier. See https://github.com/ktoso/maven-git-commit-id-plugin
4220
</description>
4321
<url>http://www.blog.project13.pl</url>
4422

src/main/java/pl/project13/maven/git/GitCommitIdMojo.java

Lines changed: 49 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import java.util.TimeZone;
5555

5656
/**
57-
* Goal which puts git build-time information into property files or maven's properties.
57+
* Puts git build-time information into property files or maven's properties.
5858
*
5959
* @since 1.0
6060
*/
@@ -105,80 +105,66 @@ public class GitCommitIdMojo extends AbstractMojo {
105105
private MavenSession session;
106106

107107
/**
108-
* <p>Set this to {@code true} to inject git properties into all reactor projects, not just the current one.</p>
108+
* <p>Set this to {@code 'true'} to inject git properties into all reactor projects, not just the current one.</p>
109109
*
110110
* <p>Injecting into all projects may slow down the build and you don't always need this feature.
111-
* For details about why you might want to skip this: <a href="https://github.com/ktoso/maven-git-commit-id-plugin/pull/65">https://github.com/ktoso/maven-git-commit-id-plugin/pull/65</a>.
111+
* See <a href="https://github.com/ktoso/maven-git-commit-id-plugin/pull/65">pull #65</a> for details about why you might want to skip this.
112112
* </p>
113-
*
114-
* <p>Defaults to {@code false}.</p>
115113
*/
116114
@Parameter(defaultValue = "false")
117115
private boolean injectAllReactorProjects;
118116

119117
/**
120-
* <p>Set this to {@code true} to print more info while scanning for paths.
121-
* It will make git-commit-id "eat it's own dog food" :-)</p>
122-
*
123-
* <p>Defaults to {@code false}.</p>
118+
* Set this to {@code 'true'} to print more info while scanning for paths.
119+
* It will make git-commit-id "eat its own dog food" :-)
124120
*/
125121
@Parameter(defaultValue = "false")
126122
private boolean verbose;
127123

128124
/**
129-
* <p>Set this to {@code false} to execute plugin in 'pom' packaged projects.</p>
130-
*
131-
* <p>Defaults to {@code true}.</p>
125+
* Set this to {@code 'false'} to execute plugin in 'pom' packaged projects.
132126
*/
133127
@Parameter(defaultValue = "true")
134128
private boolean skipPoms;
135129

136130
/**
137-
* <p>Set this to {@code true} to generate {@code git.properties} file.
138-
* By default plugin only adds properties to maven project properties.</p>
139-
*
140-
* <p>Defaults to {@code false}.</p>
131+
* Set this to {@code 'true'} to generate {@code 'git.properties'} file.
132+
* By default plugin only adds properties to maven project properties.
141133
*/
142134
@Parameter(defaultValue = "false")
143135
private boolean generateGitPropertiesFile;
144136

145137
/**
146-
* <p>The location of {@code git.properties} file. Set {@code generateGitPropertiesFile} to {@code true}
138+
* <p>The location of {@code 'git.properties'} file. Set {@code 'generateGitPropertiesFile'} to {@code 'true'}
147139
* to generate this file.</p>
148140
*
149-
* <p>The path here is relative to your projects src directory.</p>
150-
*
151-
* <p>Defaults to {@code ${project.build.outputDirectory}/git.properties}.</p>
141+
* <p>The path here is relative to your project src directory.</p>
152142
*/
153143
@Parameter(defaultValue = "${project.build.outputDirectory}/git.properties")
154144
private String generateGitPropertiesFilename;
155145

156146
/**
157-
* <p>The root directory of the repository we want to check.</p>
158-
*
159-
* <p>Defaults to {@code ${project.basedir}/.git}.</p>
147+
* The root directory of the repository we want to check.
160148
*/
161149
@Parameter(defaultValue = "${project.basedir}/.git")
162150
private File dotGitDirectory;
163151

164152
/**
165-
* Configuration for the {@code git-describe} command.
153+
* Configuration for the {@code 'git-describe'} command.
166154
* You can modify the dirty marker, abbrev length and other options here.
167155
*/
168156
@Parameter
169157
private GitDescribeConfig gitDescribe;
170158

171159
/**
172-
* <p>Minimum length of {@code git.commit.id.abbrev} property.
160+
* <p>Minimum length of {@code 'git.commit.id.abbrev'} property.
173161
* Value must be from 2 to 40 (inclusive), other values will result in an exception.</p>
174162
*
175163
* <p>An abbreviated commit is a shorter version of commit id. However, it is guaranteed to be unique.
176-
* To keep this contract, the plugin may decide to print an abbreviated version that is longer than the value specified here.</p>
177-
*
178-
* <p>Defaults to {@code 7}.</p>
164+
* To keep this contract, the plugin may decide to print an abbreviated version
165+
* that is longer than the value specified here.</p>
179166
*
180-
* <b>Example:</b>
181-
* <p>You have a very big repository, yet you set this value to 2. It's very probable that you'll end up
167+
* <p><b>Example:</b> You have a very big repository, yet you set this value to 2. It's very probable that you'll end up
182168
* getting a 4 or 7 char long abbrev version of the commit id. If your repository, on the other hand,
183169
* has just 4 commits, you'll probably get a 2 char long abbreviation.</p>
184170
*
@@ -187,162 +173,126 @@ public class GitCommitIdMojo extends AbstractMojo {
187173
private int abbrevLength;
188174

189175
/**
190-
* <p>The format to save properties in: {@code properties} or {@code json}.</p>
191-
*
192-
* <p>Defaults to {@code properties}.</p>
176+
* The format to save properties in: {@code 'properties'} or {@code 'json'}.
193177
*/
194178
@Parameter(defaultValue = "properties")
195179
private String format;
196180

197181
/**
198-
* <p>The prefix to expose the properties on.
199-
* For example {@code git} would allow you to access {@code ${git.branch}}.</p>
200-
*
201-
* <p>Defaults to {@code git}.</p>
182+
* The prefix to expose the properties on. For example {@code 'git'} would allow you to access {@code ${git.branch}}.
202183
*/
203184
@Parameter(defaultValue = "git")
204185
private String prefix;
205186
// prefix with dot appended if needed
206187
private String prefixDot = "";
207188

208189
/**
209-
* <p>The date format to be used for any dates exported by this plugin.
210-
* It should be a valid SimpleDateFormat string.</p>
211-
*
212-
* <p>Defaults to {@code dd.MM.yyyy '@' HH:mm:ss z}.</p>
190+
* The date format to be used for any dates exported by this plugin. It should be a valid {@link SimpleDateFormat} string.
213191
*/
214192
@Parameter(defaultValue = "dd.MM.yyyy '@' HH:mm:ss z")
215193
private String dateFormat;
216194

217195
/**
218196
* <p>The timezone used in the date format of dates exported by this plugin.
219-
* It should be a valid Timezone string (e.g. 'America/Los_Angeles', 'GMT+10', 'PST').</p>
197+
* It should be a valid Timezone string such as {@code 'America/Los_Angeles'}, {@code 'GMT+10'} or {@code 'PST'}.</p>
220198
*
221199
* <p>Try to avoid three-letter time zone IDs because the same abbreviation is often used for multiple time zones.
222200
* Please review <a href="https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html">https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html</a> for more information on this issue.</p>
223-
*
224-
* <p>Defaults to {@code java.util.TimeZone.getDefault().getID()}.</p>
225201
*/
226202
@Parameter
227203
private String dateFormatTimeZone;
228204

229205
/**
230-
* Set this to {@code false} to avoid failing the build on missing {@code .git} directory.
231-
*
232-
* <p>Defaults to {@code true}.</p>
206+
* Set this to {@code 'false'} to continue the build on missing {@code '.git'} directory.
233207
*/
234208
@Parameter(defaultValue = "true")
235209
private boolean failOnNoGitDirectory;
236210

237211
/**
238-
* <p>Set this to {@code false} to continue the build even if unable to get enough data for a complete run.
212+
* <p>Set this to {@code 'false'} to continue the build even if unable to get enough data for a complete run.
239213
* This may be useful during CI builds if the CI server does weird things to the repository.</p>
240214
*
241-
* <p>Setting this value to {@code false} causes the plugin to gracefully tell you "I did my best"
242-
* and abort it's execution if unable to obtain git meta data - yet the build will continue to run without failing.</p>
215+
* <p>Setting this value to {@code 'false'} causes the plugin to gracefully tell you "I did my best"
216+
* and abort its execution if unable to obtain git meta data - yet the build will continue to run without failing.</p>
243217
*
244-
* <p>See <a href="https://github.com/ktoso/maven-git-commit-id-plugin/issues/63">https://github.com/ktoso/maven-git-commit-id-plugin/issues/63</a>
218+
* <p>See <a href="https://github.com/ktoso/maven-git-commit-id-plugin/issues/63">issue #63</a>
245219
* for a rationale behind this flag.</p>
246-
*
247-
* <p>Defaults to {@code true}.</p>
248220
*/
249221
@Parameter(defaultValue = "true")
250222
private boolean failOnUnableToExtractRepoInfo;
251223

252224
/**
253-
* Set this to {@code true} to use native GIT executable to fetch information about the repository.
225+
* Set this to {@code 'true'} to use native Git executable to fetch information about the repository.
254226
* It is in most cases faster but requires a git executable to be installed in system.
255227
* By default the plugin will use jGit implementation as a source of information about the repository.
256-
*
257-
* <p>Defaults to {@code false}.</p>
258228
* @since 2.1.9
259229
*/
260230
@Parameter(defaultValue = "false")
261231
private boolean useNativeGit;
262232

263233
/**
264-
* <p>Set this to {@code true} to skip plugin execution.</p>
265-
*
266-
* <p>Defaults to {@code false}.</p>
234+
* Set this to {@code 'true'} to skip plugin execution.
267235
* @since 2.1.8
268236
*/
269237
@Parameter(defaultValue = "false")
270238
private boolean skip;
271239

272240
/**
273-
* <p>Set this to {@code true} to only run once in a multi-module build. This probably won't "do the right thing"
274-
* if your project has more than one git repository. If you use this with {@code generateGitPropertiesFile},
241+
* <p>Set this to {@code 'true'} to only run once in a multi-module build. This probably won't "do the right thing"
242+
* if your project has more than one git repository. If you use this with {@code 'generateGitPropertiesFile'},
275243
* it will only generate (or update) the file in the directory where you started your build.</p>
276244
*
277245
* <p>The git.* maven properties are available in all modules.</p>
278-
*
279-
* <p>Defaults to {@code false}.</p>
280246
* @since 2.1.12
281247
*/
282248
@Parameter(defaultValue = "false")
283249
private boolean runOnlyOnce;
284250

285251
/**
286252
* <p>List of properties to exclude from the resulting file.
287-
* May be useful when you want to hide {@code git.remote.origin.url} (maybe because it contains your repo password?),
288-
* or the email of the committer etc.</p>
289-
*
290-
* <p>Supports wildcards: you can write {@code git.commit.user.*} to exclude both the {@code name},
291-
* as well as {@code email} properties from being emitted into the resulting files.</p>
253+
* May be useful when you want to hide {@code 'git.remote.origin.url'} (maybe because it contains your repo password?)
254+
* or the email of the committer.</p>
292255
*
293-
* <p>Please note that the strings here are Java regular expressions ({@code .*} is a wildcard, not plain {@code *}).</p>
256+
* <p>Supports wildcards: you can write {@code 'git.commit.user.*'} to exclude both the {@code 'name'}
257+
* as well as {@code 'email'} properties from being emitted into the resulting files.</p>
294258
*
295-
* <p>Defaults to empty list.</p>
259+
* <p><b>Note:</b> The strings here are Java regular expressions: {@code '.*'} is a wildcard, not plain {@code '*'}.</p>
296260
* @since 2.1.9
297261
*/
298262
@Parameter
299263
private List<String> excludeProperties;
300264

301265
/**
302266
* <p>List of properties to include into the resulting file. Only properties specified here will be included.
303-
* This list will be overruled by the {@code excludeProperties}.</p>
267+
* This list will be overruled by the {@code 'excludeProperties'}.</p>
304268
*
305-
* <p>Supports wildcards: you can write {@code git.commit.user.*} to exclude both the {@code name},
306-
* as well as {@code email} properties from being emitted into the resulting files.</p>
269+
* <p>Supports wildcards: you can write {@code 'git.commit.user.*'} to include both the {@code 'name'}
270+
* as well as {@code 'email'} properties into the resulting files.</p>
307271
*
308-
* <p>Please note that the strings here are Java regular expressions ({@code .*} is a wildcard, not plain {@code *}).</p>
309-
*
310-
* <p>Defaults to empty list.</p>
272+
* <p><b>Note:</b> The strings here are Java regular expressions: {@code '.*'} is a wildcard, not plain {@code '*'}.</p>
311273
* @since 2.1.14
312274
*/
313275
@Parameter
314276
private List<String> includeOnlyProperties;
315277

316278
/**
317-
* <p>The mode of {@code git.commit.id} property generation.</p>
279+
* <p>The mode of {@code 'git.commit.id'} property generation.</p>
318280
*
319-
* <p>Due to naming issues in json export
320-
* (see <a href="https://github.com/ktoso/maven-git-commit-id-plugin/issues/122">https://github.com/ktoso/maven-git-commit-id-plugin/issues/122</a>)
321-
* we need to make it possible to export all properties as a valid json-object.
322-
* Due to the fact that this is one of the major properties the plugin is exporting we just don't want to change
323-
* the exporting mechanism and somehow throw the backwards compatibility away.
324-
* We rather provide a convenient switch where you can choose if you would like the properties as they always had been,
325-
* or if you rather need to support full json-object compatibility.
326-
* In the case you need to fully support json-object we unfortunately need to change the {@code git.commit.id} property
327-
* from {@code git.commit.id} to {@code git.commit.id.full} in the exporting mechanism to allow the generation
328-
* of a fully valid json object.</p>
281+
* <p>{@code 'git.commit.id'} property name is incompatible with json export
282+
* (see <a href="https://github.com/ktoso/maven-git-commit-id-plugin/issues/122">issue #122</a>).
283+
* This property allows one either to preserve backward compatibility or to enable fully valid json export:
329284
*
330-
* <p>Currently the switch allows two different options:<ol>
331-
* <li>By default this property is set to {@code flat} and will generate the formerly known property {@code git.commit.id}
332-
* as it was in the previous versions of the plugin. Keeping it to {@code flat} by default preserves backwards compatibility
333-
* and does not require further adjustments by the end user.</li>
334-
* <li>If you set this switch to {@code full} the plugin will export the formerly known property {@code git.commit.id}
335-
* as {@code git.commit.id.full} and therefore will generate a fully valid json object in the exporting mechanism.</li>
285+
* <ol>
286+
* <li>{@code 'flat'} (default) generates the property {@code 'git.commit.id'}, preserving backwards compatibility.</li>
287+
* <li>{@code 'full'} generates the property {@code 'git.commit.id.full'}, enabling fully valid json object export.</li>
336288
* </ol>
337289
* </p>
338290
*
339-
* <b>Note</b>: Depending on your plugin configuration you obviously can choose the 'prefix' of your properties
291+
* <p><b>Note:</b> Depending on your plugin configuration you obviously can choose the `prefix` of your properties
340292
* by setting it accordingly in the plugin's configuration. As a result this is therefore only an illustration
341-
* what the switch means when the 'prefix' is set to it's default value.
342-
* <b>Note</b>: If you set the value to something that's not equal to {@code flat} or {@code full} (ignoring the case)
343-
* the plugin will output a warning and will fallback to the default {@code flat} mode.
344-
*
345-
* <p>Defaults to {@code flat}.</p>
293+
* what the switch means when the 'prefix' is set to it's default value.</p>
294+
* <p><b>Note:</b> If you set the value to something that's not equal to {@code 'flat'} or {@code 'full'} (ignoring the case)
295+
* the plugin will output a warning and will fallback to the default {@code 'flat'} mode.</p>
346296
* @since 2.2.0
347297
*/
348298
@Parameter(defaultValue = "flat")

0 commit comments

Comments
 (0)