|
9 | 9 | import org.slf4j.Logger; |
10 | 10 | import org.slf4j.LoggerFactory; |
11 | 11 |
|
| 12 | +import java.io.FileInputStream; |
12 | 13 | import java.nio.file.Files; |
13 | 14 | import java.nio.file.Path; |
14 | 15 | import java.nio.file.Paths; |
| 16 | +import java.text.SimpleDateFormat; |
| 17 | +import java.time.Instant; |
| 18 | +import java.util.Date; |
15 | 19 | import java.util.Objects; |
| 20 | +import java.util.Properties; |
16 | 21 | import java.util.function.Consumer; |
17 | 22 |
|
18 | 23 | import static de.donnerbart.split.util.FormatUtil.formatTime; |
@@ -46,6 +51,12 @@ public static void main(final @Nullable String @NotNull [] args) throws Exceptio |
46 | 51 | if (!validateArguments(arguments, workingDirectory)) { |
47 | 52 | exitConsumer.accept(1); |
48 | 53 | } |
| 54 | + final var properties = readProperties(); |
| 55 | + LOG.info("split-tests-java {} (commit: {} on branch: {}) built on {}", |
| 56 | + properties.getProperty("version", "unknown"), |
| 57 | + properties.getProperty("git.commit.id.abbrev", "unknown"), |
| 58 | + properties.getProperty("git.branch", "unknown"), |
| 59 | + getBuiltTime(properties.getProperty("git.commit.time", "unknown"))); |
49 | 60 | LOG.info("Split index {} (total: {})", arguments.splitIndex, arguments.splitTotal); |
50 | 61 | LOG.info("Working directory: {}", workingDirectory); |
51 | 62 | LOG.info("Glob: {}", arguments.glob); |
@@ -140,4 +151,22 @@ static int calculateOptimalTotalSplit(final @NotNull Arguments arguments, final |
140 | 151 | lastSlowestSplit = slowestSplit; |
141 | 152 | } |
142 | 153 | } |
| 154 | + |
| 155 | + private static @NotNull Properties readProperties() throws Exception { |
| 156 | + final var resource = Thread.currentThread().getContextClassLoader().getResource("split-tests-java.properties"); |
| 157 | + if (resource == null) { |
| 158 | + throw new IllegalStateException("Cannot find split-tests-java.properties in classpath"); |
| 159 | + } |
| 160 | + final var properties = new Properties(); |
| 161 | + properties.load(new FileInputStream(resource.getPath())); |
| 162 | + return properties; |
| 163 | + } |
| 164 | + |
| 165 | + private static @NotNull Date getBuiltTime(final @NotNull String dateString) { |
| 166 | + try { |
| 167 | + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse(dateString); |
| 168 | + } catch (final Exception e) { |
| 169 | + return Date.from(Instant.EPOCH); |
| 170 | + } |
| 171 | + } |
143 | 172 | } |
0 commit comments