Skip to content

Commit 89ccd08

Browse files
author
TheSnoozer
committed
add basic docs
1 parent ab224f8 commit 89ccd08

File tree

1 file changed

+124
-1
lines changed

1 file changed

+124
-1
lines changed

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

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,174 @@
99
import javax.annotation.Nullable;
1010
import java.io.File;
1111
import java.io.IOException;
12+
import java.text.SimpleDateFormat;
1213
import java.util.*;
1314
import java.util.function.Supplier;
1415

1516
public class Externalize {
1617
protected interface Callback {
18+
/**
19+
* @return Supplier that provides the version of the project that is currently evaluated.
20+
* Used to determine {@link GitCommitPropertyConstant#BUILD_VERSION}.
21+
*/
1722
Supplier<String> supplyProjectVersion();
1823

24+
/**
25+
* @return Logging Interface
26+
*/
1927
@Nonnull
2028
LoggerBridge getLoggerBridge();
2129

30+
/**
31+
* @return The date format to be used for any dates exported by this plugin.
32+
* It should be a valid {@link SimpleDateFormat} string.
33+
*/
2234
@Nonnull
2335
String getDateFormat();
2436

37+
/**
38+
* <p>The timezone used in the date format of dates exported by this plugin.
39+
* It should be a valid Timezone string such as {@code 'America/Los_Angeles'}, {@code 'GMT+10'} or {@code 'PST'}.</p>
40+
*
41+
* <p>Try to avoid three-letter time zone IDs because the same abbreviation is often used for multiple time zones.
42+
* 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>
43+
*/
2544
@Nonnull
2645
String getDateFormatTimeZone();
2746

47+
/**
48+
* The prefix to expose the properties on. For example {@code 'git'} would allow you to access {@code ${git.branch}}.
49+
*/
2850
@Nonnull
2951
String getPrefixDot();
3052

53+
/**
54+
* <p>List of properties to exclude from the resulting file.
55+
* May be useful when you want to hide {@code 'git.remote.origin.url'} (maybe because it contains your repo password?)
56+
* or the email of the committer.</p>
57+
*
58+
* <p>Supports wildcards: you can write {@code 'git.commit.user.*'} to exclude both the {@code 'name'}
59+
* as well as {@code 'email'} properties from being emitted into the resulting files.</p>
60+
*
61+
* <p><b>Note:</b> The strings here are Java regular expressions: {@code '.*'} is a wildcard, not plain {@code '*'}.</p>
62+
*/
3163
List<String> getExcludeProperties();
3264

65+
/**
66+
* <p>List of properties to include into the resulting file. Only properties specified here will be included.
67+
* This list will be overruled by the {@code 'excludeProperties'}.</p>
68+
*
69+
* <p>Supports wildcards: you can write {@code 'git.commit.user.*'} to include both the {@code 'name'}
70+
* as well as {@code 'email'} properties into the resulting files.</p>
71+
*
72+
* <p><b>Note:</b> The strings here are Java regular expressions: {@code '.*'} is a wildcard, not plain {@code '*'}.</p>
73+
*/
3374
List<String> getIncludeOnlyProperties();
3475

76+
/**
77+
* Timestamp for reproducible output archive entries
78+
* (https://maven.apache.org/guides/mini/guide-reproducible-builds.html).
79+
* The value from <code>${project.build.outputTimestamp}</code> is either formatted as ISO 8601
80+
* <code>yyyy-MM-dd'T'HH:mm:ssXXX</code> or as an int representing seconds since the epoch (like
81+
* <a href="https://reproducible-builds.org/docs/source-date-epoch/">SOURCE_DATE_EPOCH</a>.
82+
*/
3583
@Nullable
3684
Date getReproducibleBuildOutputTimestamp() throws GitCommitIdExecutionException;
3785

86+
/**
87+
* Set this to {@code 'true'} to use native Git executable to fetch information about the repository.
88+
* It is in most cases faster but requires a git executable to be installed in system.
89+
* By default the plugin will use jGit implementation as a source of information about the repository.
90+
*/
3891
boolean useNativeGit();
3992

93+
/**
94+
* Allow to specify a timeout (in milliseconds) for fetching information with the native Git executable.
95+
* Note that {@code useNativeGit} needs to be set to {@code 'true'} to use native Git executable.
96+
*/
4097
long getNativeGitTimeoutInMs();
4198

99+
/**
100+
* <p>Minimum length of {@code 'git.commit.id.abbrev'} property.
101+
* Value must be from 2 to 40 (inclusive), other values will result in an exception.</p>
102+
*
103+
* <p>An abbreviated commit is a shorter version of commit id. However, it is guaranteed to be unique.
104+
* To keep this contract, the plugin may decide to print an abbreviated version
105+
* that is longer than the value specified here.</p>
106+
*
107+
* <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
108+
* getting a 4 or 7 char long abbrev version of the commit id. If your repository, on the other hand,
109+
* has just 4 commits, you'll probably get a 2 char long abbreviation.</p>
110+
*/
42111
int getAbbrevLength();
43112

44-
// TODO: this can't be externalized!
113+
/**
114+
* Configuration for the {@code 'git-describe'} command.
115+
* You can modify the dirty marker, abbrev length and other options here.
116+
*/
45117
GitDescribeConfig getGitDescribe();
46118

119+
/**
120+
* <p>The mode of {@code 'git.commit.id'} property generation.</p>
121+
*
122+
* <p>{@code 'git.commit.id'} property name is incompatible with json export
123+
* (see <a href="https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/122">issue #122</a>).
124+
* This property allows one either to preserve backward compatibility or to enable fully valid json export:
125+
*
126+
* <ol>
127+
* <li>{@code 'flat'} (default) generates the property {@code 'git.commit.id'}, preserving backwards compatibility.</li>
128+
* <li>{@code 'full'} generates the property {@code 'git.commit.id.full'}, enabling fully valid json object export.</li>
129+
* </ol>
130+
* </p>
131+
*
132+
* <p><b>Note:</b> Depending on your plugin configuration you obviously can choose the `prefix` of your properties
133+
* by setting it accordingly in the plugin's configuration. As a result this is therefore only an illustration
134+
* what the switch means when the 'prefix' is set to it's default value.</p>
135+
* <p><b>Note:</b> If you set the value to something that's not equal to {@code 'flat'} or {@code 'full'} (ignoring the case)
136+
* the plugin will output a warning and will fallback to the default {@code 'flat'} mode.</p>
137+
*/
47138
CommitIdGenerationMode getCommitIdGenerationMode();
48139

140+
/**
141+
* Use branch name from build environment. Set to {@code 'false'} to use JGit/GIT to get current branch name.
142+
* Useful when using the JGitflow maven plugin.
143+
* Note: If not using "Check out to specific local branch' and setting this to false may result in getting
144+
* detached head state and therefore a commit id as branch name.
145+
*/
49146
boolean getUseBranchNameFromBuildEnvironment();
50147

148+
/**
149+
* Controls whether the git plugin tries to access remote repos to fetch latest information
150+
* or only use local information.
151+
*
152+
* :warning: Before version 5.X.X the default was set to {@code false} causing the plugin to operate
153+
* in online-mode by default.
154+
*/
51155
boolean isOffline();
52156

157+
/**
158+
* Allow to tell the plugin what commit should be used as reference to generate the properties from.
159+
* By default this property is simply set to <p>HEAD</p> which should reference to the latest commit in your repository.
160+
*
161+
* In general this property can be set to something generic like <p>HEAD^1</p> or point to a branch or tag-name.
162+
* To support any kind or use-case this configuration can also be set to an entire commit-hash or it's abbreviated version.
163+
*
164+
* A use-case for this feature can be found in https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/338.
165+
*
166+
* Please note that for security purposes not all references might be allowed as configuration.
167+
* If you have a specific use-case that is currently not white listed feel free to file an issue.
168+
*/
53169
String getEvaluateOnCommit();
54170

171+
/**
172+
* The root directory of the repository we want to check.
173+
*/
55174
File getDotGitDirectory();
56175

176+
/**
177+
* The project root directory.
178+
*/
179+
@Deprecated
57180
File getProjectBaseDir() throws IOException;
58181
}
59182

0 commit comments

Comments
 (0)