kopia lustrzana https://github.com/onthegomap/planetiler
Cli add version argument (#376)
rodzic
7a3db3dcf8
commit
6a893a4787
|
@ -141,6 +141,12 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
|
|
|
@ -25,10 +25,13 @@ import com.onthegomap.planetiler.util.ResourceUsage;
|
|||
import com.onthegomap.planetiler.util.Translations;
|
||||
import com.onthegomap.planetiler.util.Wikidata;
|
||||
import com.onthegomap.planetiler.worker.RunnableThatThrows;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -439,6 +442,11 @@ public class Planetiler {
|
|||
* @throws Exception if an error occurs while processing
|
||||
*/
|
||||
public void run() throws Exception {
|
||||
var showVersion = arguments.getBoolean("version", "show version then exit", false);
|
||||
printVersionInfoFromManifest();
|
||||
if (showVersion) {
|
||||
System.exit(0);
|
||||
}
|
||||
if (profile() == null) {
|
||||
throw new IllegalArgumentException("No profile specified");
|
||||
}
|
||||
|
@ -543,6 +551,22 @@ public class Planetiler {
|
|||
stats.close();
|
||||
}
|
||||
|
||||
public static void printVersionInfoFromManifest() {
|
||||
try (var properties = Planetiler.class.getResourceAsStream("/buildinfo.properties")) {
|
||||
var parsed = new Properties();
|
||||
parsed.load(properties);
|
||||
LOGGER.info("Planetiler build git hash: {}", parsed.getProperty("githash"));
|
||||
LOGGER.info("Planetiler build version: {}", parsed.getProperty("version"));
|
||||
var epochMs = parsed.getProperty("timestamp");
|
||||
if (epochMs != null && !epochMs.isBlank() && epochMs.matches("^\\d+$")) {
|
||||
var time = Instant.ofEpochMilli(Long.parseLong(epochMs));
|
||||
LOGGER.info("Planetiler build timestamp: {}", time);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Error getting build properties");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDiskSpace() {
|
||||
ResourceUsage readPhase = new ResourceUsage("read phase disk");
|
||||
ResourceUsage writePhase = new ResourceUsage("write phase disk");
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
githash=${buildNumber}
|
||||
timestamp=${timestamp}
|
||||
version=${revision}
|
14
pom.xml
14
pom.xml
|
@ -28,6 +28,7 @@
|
|||
<sonar.moduleKey>${project.artifactId}</sonar.moduleKey>
|
||||
<sonar.exclusions>planetiler-benchmarks/**/*, planetiler-openmaptiles/**/*</sonar.exclusions>
|
||||
<revision>0.6-SNAPSHOT</revision>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
|
@ -160,6 +161,19 @@
|
|||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>create</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
|
|
Ładowanie…
Reference in New Issue