diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..9b722f2d --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +NAME=ign-validator + +all: build + +.PHONY: package +package: deb rpm + +.PHONY: deb +deb: build + bash build-deb.sh + +.PHONY: rpm +rpm: build + bash build-rpm.sh + +.PHONY: test +test: + mvn clean package + +.PHONY: build +build: + mvn clean package -Dmaven.test.skip=true + + diff --git a/build-deb.sh b/build-deb.sh new file mode 100644 index 00000000..018e0547 --- /dev/null +++ b/build-deb.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +hash fpm 2>/dev/null || { echo >&2 "ERROR : fpm is required to build deb package (see https://fpm.readthedocs.io/en/latest/installing.html)"; exit 1; } + +cd validator-cli/target + +VERSION=$(java -jar validator-cli.jar version) +echo "VERSION=$VERSION" + +rm -rf *.deb +fpm -s dir -t deb -n ign-validator -v $VERSION \ + --license "Cecill-B" \ + --description "IGNF/validator - validate and load data according to models" \ + --prefix /opt/ign-validator validator-cli.jar diff --git a/build-rpm.sh b/build-rpm.sh new file mode 100644 index 00000000..2e781b93 --- /dev/null +++ b/build-rpm.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +hash fpm 2>/dev/null || { echo >&2 "ERROR : fpm is required to build rpm package (see https://fpm.readthedocs.io/en/latest/installing.html)"; exit 1; } + +cd validator-cli/target + +VERSION=$(java -jar validator-cli.jar version) +echo "VERSION=$VERSION" + +rm -rf *.rpm +fpm -s dir -t rpm -n ign-validator -v $VERSION \ + --license "Cecill-B" \ + --description "IGNF/validator - validate and load data according to models" \ + --prefix /opt/ign-validator validator-cli.jar diff --git a/validator-core/src/main/java/fr/ign/validator/command/VersionCommand.java b/validator-core/src/main/java/fr/ign/validator/command/VersionCommand.java new file mode 100644 index 00000000..a212e092 --- /dev/null +++ b/validator-core/src/main/java/fr/ign/validator/command/VersionCommand.java @@ -0,0 +1,39 @@ +package fr.ign.validator.command; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.ParseException; + +import fr.ign.validator.Version; + +/** + * + * Display validator version + * + * @author MBorne + */ +public class VersionCommand extends AbstractCommand { + + public static final String NAME = "version"; + + @Override + public String getName() { + return NAME; + } + + @Override + public void execute() throws Exception { + System.out.println(Version.VERSION); + } + + @Override + protected void buildCustomOptions(Options options) { + + } + + @Override + protected void parseCustomOptions(CommandLine commandLine) throws ParseException { + + } + +} diff --git a/validator-core/src/main/resources/META-INF/services/fr.ign.validator.command.Command b/validator-core/src/main/resources/META-INF/services/fr.ign.validator.command.Command index 71865e96..ca3d02ea 100644 --- a/validator-core/src/main/resources/META-INF/services/fr.ign.validator.command.Command +++ b/validator-core/src/main/resources/META-INF/services/fr.ign.validator.command.Command @@ -3,4 +3,5 @@ fr.ign.validator.command.MetadataToJsonCommand fr.ign.validator.command.UnicodeTableCommand fr.ign.validator.command.ProjectionListCommand fr.ign.validator.command.ReadUrlCommand +fr.ign.validator.command.VersionCommand