You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/10/23 13:14:07 UTC

[GitHub] [netbeans] JaroslavTulach opened a new pull request #2480: Search for JDK in typical location

JaroslavTulach opened a new pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480


   It all started with a bug report: Java Language Server ignores `JAVA_HOME` environment variable. Then it continued with a discussion and the conclusion was made to mimic behavior of the existing VSCode Java extension. E.g. to search locations:
   
   - `netbeans.jdkhome` setting (workspace then user settings)
   - `java.home` setting (workspace then user settings)
   - `JDK_HOME` environment variable
   - `JAVA_HOME` environment variable
   - current system path
   
   `netbeans.jdkhome` is checked to give the user chance to exactly specify JDK just for NbCode. Other locations are checked for compatibility reasons.
   
   As soon as `netbeans.jdkhome` or  `java.home` settings are set the NbCode Java part is restarted.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on pull request #2480: Search for JDK in typical location

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480#issuecomment-716102299


   I've just noticed another integrated PR. I guess the integration is open.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #2480: Search for JDK in typical location

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480#discussion_r511015915



##########
File path: java/java.lsp.server/vscode/src/extension.ts
##########
@@ -65,33 +65,112 @@ function findClusters(myPath : string): string[] {
     return clusters;
 }
 
-export function activate(context: ExtensionContext) {
-    //verify acceptable JDK is available/set:
-    let specifiedJDK = workspace.getConfiguration('netbeans').get('jdkhome');
-    const beVerbose : boolean = workspace.getConfiguration('netbeans').get('verbose', false);
-    let info = {
-        clusters : findClusters(context.extensionPath),
-        extensionPath: context.extensionPath,
-        storagePath : context.globalStoragePath,
-        jdkHome : specifiedJDK,
-        verbose: beVerbose
-    };
-    
-    let log = vscode.window.createOutputChannel("Java Language Server");
+function findJDK(onChange: (path : string | null) => void): void {
+    function find(): string | null {
+        let nbJdk = workspace.getConfiguration('netbeans').get('jdkhome');
+        if (nbJdk) {
+            return nbJdk as string;
+        }
+        let javahome = workspace.getConfiguration('java').get('home');
+        if (javahome) {
+            return javahome as string;
+        }
 
-    vscode.extensions.all.forEach((e, index) => {
+        let jdkHome: any = process.env.JDK_HOME;
+        if (jdkHome) {
+            return jdkHome as string;
+        }
+        let jHome: any = process.env.JAVA_HOME;
+        if (jHome) {
+            return jHome as string;
+        }
+        return null;
+    }
+
+    let currentJdk = find();
+    workspace.onDidChangeConfiguration(params => {
+        if (!params.affectsConfiguration('java') && !params.affectsConfiguration('netbeans')) {

Review comment:
       `ConfigurationChangeEvent` doesn't seem to have a way to check that.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #2480: Search for JDK in typical location

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480#discussion_r511015000



##########
File path: java/java.lsp.server/vscode/src/extension.ts
##########
@@ -65,33 +65,112 @@ function findClusters(myPath : string): string[] {
     return clusters;
 }
 
-export function activate(context: ExtensionContext) {
-    //verify acceptable JDK is available/set:
-    let specifiedJDK = workspace.getConfiguration('netbeans').get('jdkhome');
-    const beVerbose : boolean = workspace.getConfiguration('netbeans').get('verbose', false);
-    let info = {
-        clusters : findClusters(context.extensionPath),
-        extensionPath: context.extensionPath,
-        storagePath : context.globalStoragePath,
-        jdkHome : specifiedJDK,
-        verbose: beVerbose
-    };
-    
-    let log = vscode.window.createOutputChannel("Java Language Server");
+function findJDK(onChange: (path : string | null) => void): void {
+    function find(): string | null {
+        let nbJdk = workspace.getConfiguration('netbeans').get('jdkhome');
+        if (nbJdk) {
+            return nbJdk as string;
+        }
+        let javahome = workspace.getConfiguration('java').get('home');
+        if (javahome) {
+            return javahome as string;
+        }
 
-    vscode.extensions.all.forEach((e, index) => {
+        let jdkHome: any = process.env.JDK_HOME;
+        if (jdkHome) {
+            return jdkHome as string;
+        }
+        let jHome: any = process.env.JAVA_HOME;
+        if (jHome) {
+            return jHome as string;
+        }
+        return null;
+    }
+
+    let currentJdk = find();
+    workspace.onDidChangeConfiguration(params => {
+        if (!params.affectsConfiguration('java') && !params.affectsConfiguration('netbeans')) {
+            return;
+        }
+        let newJdk = find();
+        if (newJdk !== currentJdk) {
+            onChange(newJdk);
+        }
+    });
+    onChange(currentJdk);
+}
+
+export function activate(context: ExtensionContext) {
+    vscode.extensions.all.forEach((e) => {

Review comment:
       OK, thanks: Done in e38771f 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach merged pull request #2480: Search for JDK in typical location

Posted by GitBox <gi...@apache.org>.
JaroslavTulach merged pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] Ondrej-Douda commented on a change in pull request #2480: Search for JDK in typical location

Posted by GitBox <gi...@apache.org>.
Ondrej-Douda commented on a change in pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480#discussion_r510924266



##########
File path: java/java.lsp.server/vscode/src/extension.ts
##########
@@ -65,33 +65,112 @@ function findClusters(myPath : string): string[] {
     return clusters;
 }
 
-export function activate(context: ExtensionContext) {
-    //verify acceptable JDK is available/set:
-    let specifiedJDK = workspace.getConfiguration('netbeans').get('jdkhome');
-    const beVerbose : boolean = workspace.getConfiguration('netbeans').get('verbose', false);
-    let info = {
-        clusters : findClusters(context.extensionPath),
-        extensionPath: context.extensionPath,
-        storagePath : context.globalStoragePath,
-        jdkHome : specifiedJDK,
-        verbose: beVerbose
-    };
-    
-    let log = vscode.window.createOutputChannel("Java Language Server");
+function findJDK(onChange: (path : string | null) => void): void {
+    function find(): string | null {
+        let nbJdk = workspace.getConfiguration('netbeans').get('jdkhome');
+        if (nbJdk) {
+            return nbJdk as string;
+        }
+        let javahome = workspace.getConfiguration('java').get('home');
+        if (javahome) {
+            return javahome as string;
+        }
 
-    vscode.extensions.all.forEach((e, index) => {
+        let jdkHome: any = process.env.JDK_HOME;
+        if (jdkHome) {
+            return jdkHome as string;
+        }
+        let jHome: any = process.env.JAVA_HOME;
+        if (jHome) {
+            return jHome as string;
+        }
+        return null;
+    }
+
+    let currentJdk = find();
+    workspace.onDidChangeConfiguration(params => {
+        if (!params.affectsConfiguration('java') && !params.affectsConfiguration('netbeans')) {

Review comment:
       I would rather check on full property name: `java.home` and `netbeans.jdkhome`...




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] Ondrej-Douda commented on a change in pull request #2480: Search for JDK in typical location

Posted by GitBox <gi...@apache.org>.
Ondrej-Douda commented on a change in pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480#discussion_r510925514



##########
File path: java/java.lsp.server/vscode/src/extension.ts
##########
@@ -65,33 +65,112 @@ function findClusters(myPath : string): string[] {
     return clusters;
 }
 
-export function activate(context: ExtensionContext) {
-    //verify acceptable JDK is available/set:
-    let specifiedJDK = workspace.getConfiguration('netbeans').get('jdkhome');
-    const beVerbose : boolean = workspace.getConfiguration('netbeans').get('verbose', false);
-    let info = {
-        clusters : findClusters(context.extensionPath),
-        extensionPath: context.extensionPath,
-        storagePath : context.globalStoragePath,
-        jdkHome : specifiedJDK,
-        verbose: beVerbose
-    };
-    
-    let log = vscode.window.createOutputChannel("Java Language Server");
+function findJDK(onChange: (path : string | null) => void): void {
+    function find(): string | null {
+        let nbJdk = workspace.getConfiguration('netbeans').get('jdkhome');
+        if (nbJdk) {
+            return nbJdk as string;
+        }
+        let javahome = workspace.getConfiguration('java').get('home');
+        if (javahome) {
+            return javahome as string;
+        }
 
-    vscode.extensions.all.forEach((e, index) => {
+        let jdkHome: any = process.env.JDK_HOME;
+        if (jdkHome) {
+            return jdkHome as string;
+        }
+        let jHome: any = process.env.JAVA_HOME;
+        if (jHome) {
+            return jHome as string;
+        }
+        return null;
+    }
+
+    let currentJdk = find();
+    workspace.onDidChangeConfiguration(params => {
+        if (!params.affectsConfiguration('java') && !params.affectsConfiguration('netbeans')) {
+            return;
+        }
+        let newJdk = find();
+        if (newJdk !== currentJdk) {
+            onChange(newJdk);
+        }
+    });
+    onChange(currentJdk);
+}
+
+export function activate(context: ExtensionContext) {
+    vscode.extensions.all.forEach((e) => {

Review comment:
       This asks for `vscode.extensions.getExtension('redhat.java') !== undefined`...




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on pull request #2480: Search for JDK in typical location

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on pull request #2480:
URL: https://github.com/apache/netbeans/pull/2480#issuecomment-715888279


   Can we merge, Laszlo?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists