Skip to content
Snippets Groups Projects
Verified Commit 4b2a7408 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: pipeline

parent fd3141b6
Branches
Tags
2 merge requests!44Release 0.6,!43Merge f-GRPC-main to dev
Pipeline #8521 passed
......@@ -57,7 +57,7 @@ formatting:
# Compile into a standalone jar file
jar: print-version easy-units
mvn package -DskipTests
mvn -e package -DskipTests
@pushd target ; \
ln -s caosdb-server-$(CAOSDB_SERVER_VERSION)-jar-with-dependencies.jar caosdb-server.jar; \
popd
......
......@@ -28,6 +28,9 @@
<version>0.4.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>CaosDB Server</name>
<scm>
<connection>scm:git:https://gitlab.indiscale.com/caosdb/src/caosdb-server.git</connection>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.testSourceDirectory>src/test/java</project.build.testSourceDirectory>
......@@ -214,6 +217,12 @@
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/</directory>
<includes><include>**/*.properties</include></includes>
</resource>
</resources>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<scriptSourceDirectory>${basedir}/src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
......@@ -298,6 +307,28 @@
<forkCount>0.5C</forkCount>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>create-metadata</goal>
</goals>
</execution>
</executions>
<configuration>
<addOutputDirectoryToResources>true</addOutputDirectoryToResources>
<applicationPropertyName>project.name</applicationPropertyName>
<revisionPropertyName>project.revision</revisionPropertyName>
<versionPropertyName>project.version</versionPropertyName>
<timestampPropertyName>build.timestamp</timestampPropertyName>
<outputDirectory>${basedir}/target/classes/org/caosdb/server/</outputDirectory>
<outputName>build.properties</outputName>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
......
......@@ -4,8 +4,8 @@
*
* Copyright (C) 2018 Research Group Biomedical Physics,
* Max-Planck-Institute for Dynamics and Self-Organization Göttingen
* Copyright (C) 2019 IndiScale GmbH
* Copyright (C) 2019 Timm Fitschen (t.fitschen@indiscale.com)
* Copyright (C) 2019-2021 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2019-2021 Timm Fitschen <t.fitschen@indiscale.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
......@@ -28,6 +28,7 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
......@@ -134,6 +135,11 @@ public class ServerProperties extends Properties {
"WEBUI_HTTP_HEADER_CACHE_MAX_AGE";
public static final String KEY_AUTHTOKEN_CONFIG = "AUTHTOKEN_CONFIG";
public static final String KEY_PROJECT_VERSION = "project.version";
public static final String KEY_PROJECT_NAME = "project.name";
public static final String KEY_PROJECT_REVISTION = "project.revision";
public static final String KEY_BUILD_TIMESTAMP = "build.timestamp";
/**
* Read the config files and initialize the server properties.
*
......@@ -143,6 +149,9 @@ public class ServerProperties extends Properties {
final Properties serverProperties = new Properties();
final String basepath = System.getProperty("user.dir");
final URL url = CaosDBServer.class.getResource("/build.properties");
serverProperties.load(url.openStream());
// load standard config
loadConfigFile(serverProperties, new File(basepath + "/conf/core/server.conf"));
......@@ -150,11 +159,11 @@ public class ServerProperties extends Properties {
loadConfigFile(serverProperties, new File(basepath + "/conf/ext/server.conf"));
// load ext/server.conf.d/ (ordering is determined by system collation)
File confDir = new File(basepath + "/conf/ext/server.conf.d");
final File confDir = new File(basepath + "/conf/ext/server.conf.d");
if (confDir.exists() && confDir.isDirectory()) {
String[] confFiles = confDir.list();
final String[] confFiles = confDir.list();
Arrays.sort(confFiles, Comparator.naturalOrder());
for (String confFile : confFiles) {
for (final String confFile : confFiles) {
// prevent backup files from being read
if (confFile.endsWith(".conf")) {
loadConfigFile(serverProperties, new File(confDir, confFile));
......@@ -163,7 +172,7 @@ public class ServerProperties extends Properties {
}
// load env vars
for (java.util.Map.Entry<String, String> envvar : System.getenv().entrySet()) {
for (final java.util.Map.Entry<String, String> envvar : System.getenv().entrySet()) {
if (envvar.getKey().startsWith("CAOSDB_CONFIG_") && envvar.getKey().length() > 14) {
serverProperties.setProperty(envvar.getKey().substring(14), envvar.getValue());
}
......@@ -171,11 +180,11 @@ public class ServerProperties extends Properties {
// log configuration alphabetically
if (logger.isInfoEnabled()) {
ArrayList<String> names = new ArrayList<>(serverProperties.stringPropertyNames());
final ArrayList<String> names = new ArrayList<>(serverProperties.stringPropertyNames());
Collections.sort(names);
for (String name : names) {
String val =
(name.contains("PASSW") || name.contains("SECRET"))
for (final String name : names) {
final String val =
name.contains("PASSW") || name.contains("SECRET")
? "****"
: serverProperties.getProperty(name);
logger.info(name + "=" + val);
......@@ -184,7 +193,7 @@ public class ServerProperties extends Properties {
return serverProperties;
}
private static void loadConfigFile(Properties serverProperties, File confFile)
private static void loadConfigFile(final Properties serverProperties, final File confFile)
throws IOException {
if (confFile.exists() && confFile.isFile()) {
logger.info("Reading configuration from " + confFile.getAbsolutePath());
......
......@@ -5,6 +5,8 @@ import org.caosdb.api.info.v1alpha1.GeneralInfoServiceGrpc.GeneralInfoServiceImp
import org.caosdb.api.info.v1alpha1.GetVersionInfoRequest;
import org.caosdb.api.info.v1alpha1.GetVersionInfoResponse;
import org.caosdb.api.info.v1alpha1.VersionInfo;
import org.caosdb.server.CaosDBServer;
import org.caosdb.server.ServerProperties;
public class EntityTransactionImpl extends GeneralInfoServiceImplBase {
......@@ -13,8 +15,22 @@ public class EntityTransactionImpl extends GeneralInfoServiceImplBase {
final GetVersionInfoRequest request,
final StreamObserver<GetVersionInfoResponse> responseObserver) {
final String version[] =
CaosDBServer.getServerProperty(ServerProperties.KEY_PROJECT_VERSION).split("[\\.-]", 4);
final Integer major = Integer.parseInt(version[0]);
final Integer minor = Integer.parseInt(version[1]);
final Integer patch = Integer.parseInt(version[2]);
final String pre_release = version.length > 3 ? version[3] : null;
final String build = CaosDBServer.getServerProperty(ServerProperties.KEY_PROJECT_REVISTION);
final VersionInfo versionInfo =
VersionInfo.newBuilder().setMajor(0).setMinor(0).setPatch(1).build();
VersionInfo.newBuilder()
.setMajor(major)
.setMinor(minor)
.setPatch(patch)
.setPreRelease(pre_release)
.setBuild(build)
.build();
final GetVersionInfoResponse response =
GetVersionInfoResponse.newBuilder().setVersionInfo(versionInfo).build();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment