diff --git a/.gitignore b/.gitignore index c583d0bd3803..492dd61b87b6 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,7 @@ OALLexer.tokens .checkstyle .externalToolBuilders oap-server/oal-grammar/**/gen/ + +# This serves as a template but will ONLY be updated when building a source release tar, +# so we don't track future updates of this file. +oap-server/server-starter/src/main/resources/version.properties diff --git a/.licenserc.yaml b/.licenserc.yaml index f94085ea8a57..7b1bc66c65c7 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -61,5 +61,6 @@ header: - '**/src/main/proto/protoc-gen-swagger/**' - '**/src/main/proto/validate/validate.proto' - '**/src/main/proto/opencensus/**' + - 'oap-server/server-starter/src/main/resources/version.properties' comment: on-failure diff --git a/apm-dist/src/main/assembly/binary.xml b/apm-dist/src/main/assembly/binary.xml index 65de5ad0790c..cc83c22f4034 100644 --- a/apm-dist/src/main/assembly/binary.xml +++ b/apm-dist/src/main/assembly/binary.xml @@ -69,6 +69,7 @@ ui-initialized-templates/* lal/* log-mal-rules/* + version.properties config diff --git a/apm-protocol/apm-network/src/main/proto b/apm-protocol/apm-network/src/main/proto index e6742be21130..21492e496b79 160000 --- a/apm-protocol/apm-network/src/main/proto +++ b/apm-protocol/apm-network/src/main/proto @@ -1 +1 @@ -Subproject commit e6742be211302cf7eb93db83bdf1da2a8e600d17 +Subproject commit 21492e496b797567d0e127f4510509baf73e10fd diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/Version.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/Version.java new file mode 100644 index 000000000000..03ab473e06ea --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/Version.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.core; + +import java.io.IOException; +import java.util.Properties; +import lombok.Getter; +import org.apache.logging.log4j.util.Strings; + +@Getter +public enum Version { + CURRENT; + + private final String buildVersion; + private final String buildTime; + private final String commitId; + + private final Properties properties = new Properties(); + + Version() { + try { + properties.load(Version.class.getClassLoader() + .getResourceAsStream("version.properties")); + buildVersion = properties.getProperty("git.build.version"); + buildTime = properties.getProperty("git.build.time"); + commitId = properties.getProperty("git.commit.id"); + } catch (IOException e) { + throw new ExceptionInInitializerError(e); + } + } + + @Override + public String toString() { + return String.format( + "%s-%s (%s)", + buildVersion, + Strings.left(commitId, 7), + buildTime + ); + } +} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/Query.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/Query.java index 947e30316d9d..b04b522475a6 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/Query.java +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/Query.java @@ -19,10 +19,12 @@ package org.apache.skywalking.oap.query.graphql.resolver; import com.coxautodev.graphql.tools.GraphQLQueryResolver; +import org.apache.skywalking.oap.server.core.Version; /** * Root Query Resolver. */ public class Query implements GraphQLQueryResolver { - private String version = "8.0"; + @SuppressWarnings("unused") // Used in GraphQL query + private final String version = Version.CURRENT.toString(); } diff --git a/oap-server/server-starter/pom.xml b/oap-server/server-starter/pom.xml index 00300a8a3276..d347bb5e637a 100644 --- a/oap-server/server-starter/pom.xml +++ b/oap-server/server-starter/pom.xml @@ -17,7 +17,8 @@ ~ --> - + oap-server org.apache.skywalking @@ -27,6 +28,10 @@ server-starter + + ${project.build.outputDirectory}/version.properties + + org.apache.skywalking @@ -260,6 +265,22 @@ skywalking-oap + + + src/main/resources + true + + version.properties + + + + src/main/resources + false + + version.properties + + + maven-compiler-plugin @@ -299,6 +320,7 @@ zabbix-rules/ lal/ log-mal-rules/ + version.properties @@ -320,6 +342,33 @@ + + pl.project13.maven + git-commit-id-plugin + 4.9.10 + + + get-the-git-information + + revision + + initialize + + + + false + true + ${generateGitPropertiesFilename} + UTC + yyyyMMddHHmmss + false + + ^git.build.version$ + ^git.commit.id$ + ^git.build.time$ + + + diff --git a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java index 3e893e4c7af3..bcf3e0846ebb 100644 --- a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java +++ b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerBootstrap.java @@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.oap.server.core.RunningMode; +import org.apache.skywalking.oap.server.core.Version; import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration; import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader; @@ -49,6 +50,8 @@ public static void start() { // Set uptime to second .setValue(System.currentTimeMillis() / 1000d); + log.info("Version of OAP: {}", Version.CURRENT); + if (RunningMode.isInitMode()) { log.info("OAP starts up in init mode successfully, exit now..."); System.exit(0); diff --git a/tools/releasing/create_source_release.sh b/tools/releasing/create_source_release.sh index 16d1bb3b9518..734d4dece3c0 100755 --- a/tools/releasing/create_source_release.sh +++ b/tools/releasing/create_source_release.sh @@ -43,7 +43,8 @@ PRODUCT_NAME=${PRODUCT_NAME}-${RELEASE_VERSION} rm -rf ${PRODUCT_NAME} mkdir ${PRODUCT_NAME} -git clone https://github.com/apache/skywalking.git ./${PRODUCT_NAME} +# TODO +git clone https://github.com/kezhenxu94/skywalking.git ./${PRODUCT_NAME} cd ${PRODUCT_NAME} TAG_EXIST=`git tag -l ${TAG_NAME} | wc -l` @@ -58,6 +59,9 @@ git checkout ${TAG_NAME} git submodule init git submodule update +./mvnw -q -pl oap-server/server-starter initialize \ + -DgenerateGitPropertiesFilename="$(pwd)/oap-server/server-starter/src/main/resources/version.properties" + cd .. tar czf ${PRODUCT_NAME}-src.tgz \