Add ability to provide additional build-info in Che (#12919)
parent
86436a88e6
commit
e4763e1dac
|
|
@ -208,6 +208,25 @@
|
|||
WEB-INF/lib/jsr305*.jar</packagingExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- adding "build info" for Che WS Agent API -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>buildinfo</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<echo append="false" file="${project.build.outputDirectory}/che/buildinfo.properties">che.product.build_info = ${build.info}</echo>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -536,6 +536,25 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- adding "build info" for Che Server API -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>buildinfo</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<echo append="false" file="${project.build.outputDirectory}/che/buildinfo.properties">che.product.build_info = ${build.info}</echo>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -15,10 +15,9 @@ import java.io.InputStream;
|
|||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.ws.rs.core.Context;
|
||||
import org.eclipse.che.api.core.rest.shared.dto.ApiInfo;
|
||||
import org.eclipse.che.dto.server.DtoFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -37,8 +36,8 @@ public class ApiInfoProvider implements Provider<ApiInfo> {
|
|||
private ApiInfo apiInfo;
|
||||
|
||||
@Inject
|
||||
public ApiInfoProvider(@Context ServletContext context) {
|
||||
this.apiInfo = readApiInfo(context);
|
||||
public ApiInfoProvider(@Named("che.product.build_info") String buildInfo) {
|
||||
this.apiInfo = readApiInfo(buildInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -46,10 +45,12 @@ public class ApiInfoProvider implements Provider<ApiInfo> {
|
|||
return apiInfo;
|
||||
}
|
||||
|
||||
private ApiInfo readApiInfo(ServletContext context) {
|
||||
private ApiInfo readApiInfo(String buildInfo) {
|
||||
try {
|
||||
try (InputStream inputStream = context.getResourceAsStream("/META-INF/MANIFEST.MF")) {
|
||||
final Manifest manifest = new Manifest(inputStream);
|
||||
try (InputStream manifestInputStream =
|
||||
ApiInfoProvider.class.getResourceAsStream("/META-INF/MANIFEST.MF")) {
|
||||
|
||||
final Manifest manifest = new Manifest(manifestInputStream);
|
||||
final Attributes mainAttributes = manifest.getMainAttributes();
|
||||
final DtoFactory dtoFactory = DtoFactory.getInstance();
|
||||
return dtoFactory
|
||||
|
|
@ -59,8 +60,10 @@ public class ApiInfoProvider implements Provider<ApiInfo> {
|
|||
.withSpecificationTitle("Che REST API")
|
||||
.withSpecificationVersion(mainAttributes.getValue("Specification-Version"))
|
||||
.withImplementationVersion(mainAttributes.getValue("Implementation-Version"))
|
||||
.withScmRevision(mainAttributes.getValue("SCM-Revision"));
|
||||
.withScmRevision(mainAttributes.getValue("SCM-Revision"))
|
||||
.withBuildInfo(buildInfo);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Unable to read API info. Error: " + e.getMessage(), e);
|
||||
throw new RuntimeException("Unable to read API information", e);
|
||||
|
|
|
|||
|
|
@ -57,4 +57,10 @@ public interface ApiInfo {
|
|||
ApiInfo withIdeVersion(String ideVersion);
|
||||
|
||||
void setIdeVersion(String ideVersion);
|
||||
|
||||
String getBuildInfo();
|
||||
|
||||
ApiInfo withBuildInfo(String buildInfo);
|
||||
|
||||
void setBuildInfo(String buildInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ export class CheBranding {
|
|||
updateVersion(): void {
|
||||
this.cheService.fetchServicesInfo().then(() => {
|
||||
let info = this.cheService.getServicesInfo();
|
||||
this.$rootScope.productVersion = (info && info.implementationVersion) ? info.implementationVersion : '';
|
||||
this.$rootScope.productVersion = (info && info.buildInfo) ? info.buildInfo : '';
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@
|
|||
<tasks>
|
||||
<echo append="false" file="${project.build.directory}/classes/org/eclipse/che/ide/ext/help/client/BuildInfo.properties">revision = ${revision}
|
||||
buildTime = ${timestamp}
|
||||
version = ${project.version}</echo>
|
||||
version = ${build.info}</echo>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
|||
1
pom.xml
1
pom.xml
|
|
@ -48,6 +48,7 @@
|
|||
<url>https://github.com/eclipse/che</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<build.info>${project.version}</build.info>
|
||||
<che.dashboard.version>7.0.0-beta-3.0-SNAPSHOT</che.dashboard.version>
|
||||
<che.docs.version>7.0.0-beta-3.0-SNAPSHOT</che.docs.version>
|
||||
<che.lib.version>7.0.0-beta-3.0-SNAPSHOT</che.lib.version>
|
||||
|
|
|
|||
Loading…
Reference in New Issue