Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display server version on startup #139

Merged
merged 1 commit into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
//Use consistent indentation
"editor.detectIndentation": false,
"editor.tabSize": 4,
"editor.insertSpaces": false
"editor.insertSpaces": false,
"java.configuration.updateBuildConfiguration": "interactive"
}
50 changes: 33 additions & 17 deletions org.eclipse.lsp4xml/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse</groupId>
Expand All @@ -10,17 +8,48 @@
<artifactId>org.eclipse.lsp4xml</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format>
<dev.build.timestamp>${maven.build.timestamp}</dev.build.timestamp>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources/</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
Expand Down Expand Up @@ -93,17 +122,4 @@
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>lsp4j-snapshot</id>
<layout>default</layout>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.eclipse.lsp4xml;

import static org.eclipse.lsp4j.jsonrpc.CompletableFutures.computeAsync;
import static org.eclipse.lsp4xml.utils.VersionHelper.getVersion;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -67,7 +68,7 @@ public XMLLanguageServer() {

@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
LOGGER.info("Initializing LSP4XML server");
LOGGER.info("Initializing LSP4XML server " + getVersion());
this.parentProcessId = params.getProcessId();

capabilityManager.setClientCapabilities(params.getCapabilities());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void initializeRootLogger(LanguageClient newLanguageClient, LogsSe

Logger logger = Logger.getLogger("");
unregisterAllHandlers(logger.getHandlers());
logger.setLevel(Level.SEVERE);
logger.setLevel(Level.INFO);
logger.setUseParentHandlers(false);// Stops output to console

// Configure logging LSP client handler
Expand Down Expand Up @@ -68,11 +68,11 @@ public static void initializeRootLogger(LanguageClient newLanguageClient, LogsSe

private static void createDirectoryPath(String path) {
Path parentPath = Paths.get(path).normalize().getParent();
if(parentPath != null) {
if (parentPath != null) {
try {
Files.createDirectories(parentPath);
} catch (IOException e) {

}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Fred Bricon <fbricon@gmail.com>, Red Hat Inc. - initial API and implementation
*/
package org.eclipse.lsp4xml.utils;

import java.util.ResourceBundle;

/**
* Helper object to retrieve the current version of the server.
*/
public class VersionHelper {

private VersionHelper() {
// No instantiation
}

/**
* Returns the version of the server with the format
* <code>major.minor.incremental-timestamp</code>.
*
* @return the server version
*/
public static String getVersion() {
// No need to make it a static field as it'll be used only once
ResourceBundle bundle = ResourceBundle.getBundle("version");
String version = bundle.getString("version");
return version;
}
}
1 change: 1 addition & 0 deletions org.eclipse.lsp4xml/src/main/resources/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-${dev.build.timestamp}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Fred Bricon <fbricon@gmail.com>, Red Hat Inc. - initial API and implementation
*/
package org.eclipse.lsp4xml.utils;

import static org.junit.Assert.assertTrue;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.Test;

public class VersionHelperTest {

@Test
public void testGetVersion() {
String version = VersionHelper.getVersion();
Pattern pattern = Pattern.compile("^(\\d+\\.\\d+\\.\\d+)(-.*)$");
Matcher matcher = pattern.matcher(version);
assertTrue("Unexpected format for :" + version, matcher.matches());
}
}