|
9 | 9 | import javax.annotation.Nullable;
|
10 | 10 | import java.io.File;
|
11 | 11 | import java.io.IOException;
|
| 12 | +import java.text.SimpleDateFormat; |
12 | 13 | import java.util.*;
|
13 | 14 | import java.util.function.Supplier;
|
14 | 15 |
|
15 | 16 | public class Externalize {
|
16 | 17 | 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 | + */ |
17 | 22 | Supplier<String> supplyProjectVersion();
|
18 | 23 |
|
| 24 | + /** |
| 25 | + * @return Logging Interface |
| 26 | + */ |
19 | 27 | @Nonnull
|
20 | 28 | LoggerBridge getLoggerBridge();
|
21 | 29 |
|
| 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 | + */ |
22 | 34 | @Nonnull
|
23 | 35 | String getDateFormat();
|
24 | 36 |
|
| 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 | + */ |
25 | 44 | @Nonnull
|
26 | 45 | String getDateFormatTimeZone();
|
27 | 46 |
|
| 47 | + /** |
| 48 | + * The prefix to expose the properties on. For example {@code 'git'} would allow you to access {@code ${git.branch}}. |
| 49 | + */ |
28 | 50 | @Nonnull
|
29 | 51 | String getPrefixDot();
|
30 | 52 |
|
| 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 | + */ |
31 | 63 | List<String> getExcludeProperties();
|
32 | 64 |
|
| 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 | + */ |
33 | 74 | List<String> getIncludeOnlyProperties();
|
34 | 75 |
|
| 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 | + */ |
35 | 83 | @Nullable
|
36 | 84 | Date getReproducibleBuildOutputTimestamp() throws GitCommitIdExecutionException;
|
37 | 85 |
|
| 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 | + */ |
38 | 91 | boolean useNativeGit();
|
39 | 92 |
|
| 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 | + */ |
40 | 97 | long getNativeGitTimeoutInMs();
|
41 | 98 |
|
| 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 | + */ |
42 | 111 | int getAbbrevLength();
|
43 | 112 |
|
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 | + */ |
45 | 117 | GitDescribeConfig getGitDescribe();
|
46 | 118 |
|
| 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 | + */ |
47 | 138 | CommitIdGenerationMode getCommitIdGenerationMode();
|
48 | 139 |
|
| 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 | + */ |
49 | 146 | boolean getUseBranchNameFromBuildEnvironment();
|
50 | 147 |
|
| 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 | + */ |
51 | 155 | boolean isOffline();
|
52 | 156 |
|
| 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 | + */ |
53 | 169 | String getEvaluateOnCommit();
|
54 | 170 |
|
| 171 | + /** |
| 172 | + * The root directory of the repository we want to check. |
| 173 | + */ |
55 | 174 | File getDotGitDirectory();
|
56 | 175 |
|
| 176 | + /** |
| 177 | + * The project root directory. |
| 178 | + */ |
| 179 | + @Deprecated |
57 | 180 | File getProjectBaseDir() throws IOException;
|
58 | 181 | }
|
59 | 182 |
|
|
0 commit comments