package org.utplsql.cli;

import org.utplsql.api.JavaApiVersionInfo;

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;

/** This class is getting updated automatically by the build process.
 * Please do not update its constants manually cause they will be overwritten.
 *
 * @author pesse
 */
public class CliVersionInfo {

    private static final String MAVEN_PROJECT_NAME = "utPLSL-cli";
    private static String MAVEN_PROJECT_VERSION = "unknown";

    static {
        try {
            MAVEN_PROJECT_VERSION = Files.readAllLines(
                    Paths.get(CliVersionInfo.class.getClassLoader().getResource("utplsql-cli.version").toURI())
                    , Charset.defaultCharset())
                    .get(0);
        }
        catch ( IOException | URISyntaxException e ) {
            System.out.println("WARNING: Could not get Version information!");
        }
    }

    public static String getVersion() { return MAVEN_PROJECT_VERSION; }
    public static String getInfo() { return MAVEN_PROJECT_NAME + " " + getVersion(); }


}

@@ -78,27 +78,30 @@
 java.io.
-IOException
+BufferedReader
 ;%0Aimport
@@ -110,21 +110,13 @@
 ava.
-net.URISyntax
+io.IO
 Exce
@@ -138,27 +138,22 @@
 ava.
-n
 io.
-charset.Charset
+InputStream
 ;%0Aim
@@ -166,50 +166,64 @@
 ava.
-n
 io.
-file.Files;%0Aimport java.nio.file.Paths
+InputStreamReader;%0Aimport java.net.URISyntaxException
 ;%0A%0A/
@@ -597,84 +597,37 @@
     
-MAVEN_PROJECT_VERSION = Files.readAllLines(%0A                    Paths.get(Cl
+try ( InputStream in = JavaAp
 iVer
@@ -669,16 +669,24 @@
 Resource
+AsStream
 (%22utplsq
@@ -704,17 +704,11 @@
 on%22)
-.toURI())
+) %7B
 %0A   
@@ -724,39 +724,78 @@
     
-    , Charset.defaultCharset(
+BufferedReader reader = new BufferedReader(new InputStreamReader(in
 ))
+;
 %0A   
@@ -811,20 +811,97 @@
     
-    .get(0);
+MAVEN_PROJECT_VERSION = reader.readLine();%0A%0A                reader.close();%0A            %7D
 %0A   
@@ -939,29 +939,8 @@
 ion 
-%7C URISyntaxException 
 e ) 

Read the info from stream instead of NIO