You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "lahodaj (via GitHub)" <gi...@apache.org> on 2023/08/17 12:57:02 UTC
[GitHub] [netbeans] lahodaj opened a new pull request, #6354: For Gradle debug, the IDE should listen, and the debugee should connect to it, not the other way around, for safety reasons.
lahodaj opened a new pull request, #6354:
URL: https://github.com/apache/netbeans/pull/6354
Currently Gradle debugging uses `--debug-jvm` Gradle option of the application plugin(?), which lets the debugee listen on port 5005. This has two problems: a) given the port is hardcoded, the may clash with some other VM already listening at the port; b) someone might accidentally connect to the instead of the IDE.
The typical way NB is doing debugging is that the IDE listens on a random port, and the debugee attaches to it. I tried to tweak Gradle here to do that as well. But, it feels a bit tricky, so I'd be happy to know if there's an input about this.
Thanks!
---
**^Add meaningful description above**
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
- are all your own work, and you have the right to contribute them.
- are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).
Please make sure (eg. `git log`) that all commits have a valid name and email address for you in the Author field.
If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
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] lahodaj commented on a diff in pull request #6354: For Gradle debug, the IDE should listen, and the debugee should connect to it, not the other way around, for safety reasons.
Posted by "lahodaj (via GitHub)" <gi...@apache.org>.
lahodaj commented on code in PR #6354:
URL: https://github.com/apache/netbeans/pull/6354#discussion_r1298466784
##########
java/gradle.java/src/org/netbeans/modules/gradle/java/execute/JavaDebugTokenProvider.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.netbeans.modules.gradle.java.execute;
+
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.api.GradleBaseProject;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.netbeans.modules.gradle.spi.actions.BeforeBuildActionHook;
+import org.netbeans.modules.gradle.spi.actions.ReplaceTokenProvider;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ProjectServiceProvider;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ *
+ * @author sdedic
+ */
+@ProjectServiceProvider(
+ service = ReplaceTokenProvider.class,
+ projectType = NbGradleProject.GRADLE_PROJECT_TYPE
Review Comment:
That's a question what to do about these - Maven has that as well, and I suspect it is simply not used when the IDE listens. But, when the debugee listens, then this would (hopefully) be automatically used (and it is presumably the case with Maven).
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
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] lkishalmi commented on pull request #6354: For Gradle debug, the IDE should listen, and the debugee should connect to it, not the other way around, for safety reasons.
Posted by "lkishalmi (via GitHub)" <gi...@apache.org>.
lkishalmi commented on PR #6354:
URL: https://github.com/apache/netbeans/pull/6354#issuecomment-1686939939
Well, what about this: https://docs.gradle.org/current/userguide/command_line_interface.html#sec:command_line_debugging
So we have a standard way to pass the port, and listen options which are going to be used when people are using `--debug-jvm`
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
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] sdedic commented on a diff in pull request #6354: For Gradle debug, the IDE should listen, and the debugee should connect to it, not the other way around, for safety reasons.
Posted by "sdedic (via GitHub)" <gi...@apache.org>.
sdedic commented on code in PR #6354:
URL: https://github.com/apache/netbeans/pull/6354#discussion_r1297219459
##########
java/gradle.java/src/org/netbeans/modules/gradle/java/execute/JavaDebugTokenProvider.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.netbeans.modules.gradle.java.execute;
+
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.api.GradleBaseProject;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.netbeans.modules.gradle.spi.actions.BeforeBuildActionHook;
+import org.netbeans.modules.gradle.spi.actions.ReplaceTokenProvider;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ProjectServiceProvider;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ *
+ * @author sdedic
+ */
+@ProjectServiceProvider(
+ service = ReplaceTokenProvider.class,
+ projectType = NbGradleProject.GRADLE_PROJECT_TYPE
+)
+public class JavaDebugTokenProvider implements ReplaceTokenProvider {
+ /**
+ * Replaceable token for debugging port.
+ */
+ public static String TOKEN_JAVAEXEC_DEBUG_PORT = "javaExec.debug.port"; // NOI18N
+
+ private static final Set<String> TOKENS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
+ TOKEN_JAVAEXEC_DEBUG_PORT
+ )));
+
+ private static final Set<String> DEBUG_ACTIONS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
+ ActionProvider.COMMAND_DEBUG,
+ ActionProvider.COMMAND_DEBUG_SINGLE,
+ ActionProvider.COMMAND_DEBUG_TEST_SINGLE
+ )));
+
+ private final Project project;
+
+ public JavaDebugTokenProvider(Project project) {
+ this.project = project;
+ }
+
+ @Override
+ public Set<String> getSupportedTokens() {
+ return isEnabled() ? TOKENS : Collections.emptySet();
+ }
+
+ private boolean isEnabled() {
+ Set<String> plugins = GradleBaseProject.get(project).getPlugins();
+ return plugins.contains("java"); // NOI18N
+ }
+
+ @Override
+ public Map<String, String> createReplacements(String action, Lookup context) {
+ if (!isEnabled() || !DEBUG_ACTIONS.contains(action)) {
+ return Collections.emptyMap();
+ }
+
+ OutputHolder output = context.lookup(OutputHolder.class);
+
+ if (output == null) {
+ return Collections.emptyMap();
+ }
+
+ Map<String, String> result = new HashMap<>();
+
+ try {
+ result.put(TOKEN_JAVAEXEC_DEBUG_PORT, "" + new JPDAStart(output.out, project).execute());
+ } catch (Exception ex) {
+ Exceptions.printStackTrace(ex);
Review Comment:
Is there a way how to report the failure upwards / to the user ? Maybe a message to `output.out` ... or maybe it is done by JPDAStart.execute() already. But the Exceptions.printStackTrace shouldn't be there IMHO.
##########
extide/gradle/netbeans-gradle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NetBeansRunSinglePlugin.java:
##########
@@ -43,37 +43,49 @@ class NetBeansRunSinglePlugin implements Plugin<Project> {
private static final String RUN_SINGLE_TASK = "runSingle";
private static final String RUN_SINGLE_MAIN = "runClassName";
- private static final String RUN_SINGLE_ARGS = "runArgs";
- private static final String RUN_SINGLE_JVM_ARGS = "runJvmArgs";
- private static final String RUN_SINGLE_CWD = "runWorkingDir";
+ private static final String RUN_ARGS = "runArgs";
+ private static final String RUN_JVM_ARGS = "runJvmArgs";
+ private static final String RUN_JVM_DEBUG_ARGS = "runJvmDebugArgs";
+ private static final String RUN_CWD = "runWorkingDir";
@Override
public void apply(Project project) {
project.afterEvaluate(p -> {
- if (project.getPlugins().hasPlugin("java")
- && (project.getTasks().findByPath(RUN_SINGLE_TASK) == null)
- && project.hasProperty(RUN_SINGLE_MAIN)) {
- Set<Task> runTasks = p.getTasksByName("run", false);
- Task r = runTasks.isEmpty() ? null : runTasks.iterator().next();
- String mainClass = project.property(RUN_SINGLE_MAIN).toString();
+ if (project.getPlugins().hasPlugin("java")) {
+ String mainClass = project.hasProperty(RUN_SINGLE_MAIN) ? project.property(RUN_SINGLE_MAIN).toString()
+ : null;
p.getTasks().withType(JavaExec.class).configureEach(je -> {
Review Comment:
Hm .. on a second thought, maybe there should be some trigger that causes this code to decorate exec tasks; just some arbitrary property present in run/debug actions just to trigger this. Otherwise, it might reconfigure execs even for `gradle compile` ...
##########
java/gradle.java/src/org/netbeans/modules/gradle/java/execute/JavaDebugTokenProvider.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.netbeans.modules.gradle.java.execute;
+
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.api.GradleBaseProject;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.netbeans.modules.gradle.spi.actions.BeforeBuildActionHook;
+import org.netbeans.modules.gradle.spi.actions.ReplaceTokenProvider;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ProjectServiceProvider;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ *
+ * @author sdedic
+ */
+@ProjectServiceProvider(
+ service = ReplaceTokenProvider.class,
+ projectType = NbGradleProject.GRADLE_PROJECT_TYPE
Review Comment:
There's also `org.netbeans.modules.gradle.java.GradleJavaDebuggerImpl` and `org.netbeans.modules.gradle.java.spi.debug.GradleJavaDebugger` which may need some tweaking that do JPDA attach to the listening debugee
##########
java/gradle.java/src/org/netbeans/modules/gradle/java/execute/JavaDebugTokenProvider.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.netbeans.modules.gradle.java.execute;
+
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.api.GradleBaseProject;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.netbeans.modules.gradle.spi.actions.BeforeBuildActionHook;
+import org.netbeans.modules.gradle.spi.actions.ReplaceTokenProvider;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ProjectServiceProvider;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ *
+ * @author sdedic
+ */
+@ProjectServiceProvider(
+ service = ReplaceTokenProvider.class,
+ projectType = NbGradleProject.GRADLE_PROJECT_TYPE
+)
+public class JavaDebugTokenProvider implements ReplaceTokenProvider {
+ /**
+ * Replaceable token for debugging port.
+ */
+ public static String TOKEN_JAVAEXEC_DEBUG_PORT = "javaExec.debug.port"; // NOI18N
+
+ private static final Set<String> TOKENS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
+ TOKEN_JAVAEXEC_DEBUG_PORT
+ )));
+
+ private static final Set<String> DEBUG_ACTIONS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
+ ActionProvider.COMMAND_DEBUG,
+ ActionProvider.COMMAND_DEBUG_SINGLE,
+ ActionProvider.COMMAND_DEBUG_TEST_SINGLE
+ )));
+
+ private final Project project;
+
+ public JavaDebugTokenProvider(Project project) {
+ this.project = project;
+ }
+
+ @Override
+ public Set<String> getSupportedTokens() {
+ return isEnabled() ? TOKENS : Collections.emptySet();
+ }
+
+ private boolean isEnabled() {
+ Set<String> plugins = GradleBaseProject.get(project).getPlugins();
+ return plugins.contains("java"); // NOI18N
+ }
+
+ @Override
+ public Map<String, String> createReplacements(String action, Lookup context) {
+ if (!isEnabled() || !DEBUG_ACTIONS.contains(action)) {
+ return Collections.emptyMap();
+ }
+
+ OutputHolder output = context.lookup(OutputHolder.class);
+
+ if (output == null) {
+ return Collections.emptyMap();
+ }
+
+ Map<String, String> result = new HashMap<>();
+
+ try {
+ result.put(TOKEN_JAVAEXEC_DEBUG_PORT, "" + new JPDAStart(output.out, project).execute());
+ } catch (Exception ex) {
+ Exceptions.printStackTrace(ex);
+ }
+
+ return result;
+ }
+
+ private static final class OutputHolder {
Review Comment:
Please document this hack ;)) except for passing `out`, it also prevents premature JPDAStart -- worth documenting.
##########
java/gradle.java/src/org/netbeans/modules/gradle/java/execute/JavaDebugTokenProvider.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.netbeans.modules.gradle.java.execute;
+
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.api.GradleBaseProject;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.netbeans.modules.gradle.spi.actions.BeforeBuildActionHook;
+import org.netbeans.modules.gradle.spi.actions.ReplaceTokenProvider;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ProjectServiceProvider;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ *
+ * @author sdedic
+ */
+@ProjectServiceProvider(
+ service = ReplaceTokenProvider.class,
+ projectType = NbGradleProject.GRADLE_PROJECT_TYPE
+)
+public class JavaDebugTokenProvider implements ReplaceTokenProvider {
+ /**
+ * Replaceable token for debugging port.
+ */
+ public static String TOKEN_JAVAEXEC_DEBUG_PORT = "javaExec.debug.port"; // NOI18N
Review Comment:
I'd use `javaExec.debug.connectPort` here, or something that could eventually allow to pass listen port to the debugee (maybe in future).
##########
java/gradle.java/src/org/netbeans/modules/gradle/java/execute/JPDAStart.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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.netbeans.modules.gradle.java.execute;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.sun.jdi.Bootstrap;
+import com.sun.jdi.connect.ListeningConnector;
+import com.sun.jdi.connect.Transport;
+import com.sun.jdi.connect.Connector;
+import java.io.PrintWriter;
+import java.util.Iterator;
+
+import org.netbeans.api.debugger.jpda.DebuggerStartException;
+
+import org.openide.util.RequestProcessor;
+import org.openide.filesystems.FileUtil;
+
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.debugger.jpda.JPDADebugger;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectUtils;
+import org.netbeans.modules.gradle.java.Utils;
+
+/**
+ * Start the JPDA debugger.
+ *
+ * @author Arunava Sinha
+ */
+public class JPDAStart implements Runnable {
+
+ private static final RequestProcessor RP = new RequestProcessor(JPDAStart.class);
+ private static final String TRANSPORT = "dt_socket"; //NOI18N
+
+ private final Object[] lock = new Object[2];
+ private final PrintWriter out;
+ private final Project project;
+
+ JPDAStart(PrintWriter out, Project project) {
+ this.out = out;
+ this.project = project;
+ }
+
+ /**
+ * returns the port that the debugger listens to..
+ */
+ public String execute() throws Exception {
+ synchronized (lock) {
+ RP.post(this);
+ lock.wait();
+ if (lock[1] != null) {
+ throw ((Exception) lock[1]); //NOI18N
+ }
+ }
+ return (String) lock[0];
+ }
+
+ @Override
+ public void run() {
+ synchronized (lock) {
+
+ try {
+
+ ListeningConnector lc = null;
+ Iterator i = Bootstrap.virtualMachineManager().
+ listeningConnectors().iterator();
+ for (; i.hasNext();) {
+ lc = (ListeningConnector) i.next();
+ Transport t = lc.transport();
+ if (t != null && t.name().equals(getTransport())) {
+ break;
+ }
+ }
+ if (lc == null) {
+ throw new RuntimeException("No trasports named " + getTransport() + " found!"); //NOI18N
+ }
+
+ final Map args = lc.defaultArguments();
+ String address = lc.startListening(args);
+ try {
+ int port = Integer.parseInt(address.substring(address.indexOf(':') + 1));
+ Connector.IntegerArgument portArg = (Connector.IntegerArgument) args.get("port"); //NOI18N
+ portArg.setValue(port);
+ lock[0] = Integer.toString(port);
+ } catch (NumberFormatException e) {
+ lock[0] = address;
+ }
+
+ final Map properties = new HashMap();
+
+ ClassPath sourcePath = Utils.getSources(project);
+ ClassPath jdkSourcePath = Utils.getJdkSources(project);
+
+ properties.put("sourcepath", sourcePath); //NOI18N
+ properties.put("jdksources", jdkSourcePath); //NOI18N
+ File baseDir = FileUtil.toFile(project.getProjectDirectory());
+ properties.put("baseDir", baseDir); //NOI18N
+ properties.put("name", ProjectUtils.getInformation(project).getDisplayName()); //NOI18N
+
+ final ListeningConnector flc = lc;
+ RP.post(() -> {
+ try {
+ JPDADebugger.startListening(flc, args,
+ new Object[]{properties});
+ } catch (DebuggerStartException ex) {
+ out.println("Debugger Start Error."); //NOI18N
+ }
+ });
+ } catch (java.io.IOException ioex) {
+ out.println("IO Error:"); //NOI18N
+// org.openide.ErrorManager.getDefault().notify(ioex);
+ lock[1] = ioex;
Review Comment:
Maybe print ioex.getMessage() as well ?
##########
java/gradle.java/src/org/netbeans/modules/gradle/java/execute/JavaDebugTokenProvider.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.netbeans.modules.gradle.java.execute;
+
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.api.GradleBaseProject;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.netbeans.modules.gradle.spi.actions.BeforeBuildActionHook;
+import org.netbeans.modules.gradle.spi.actions.ReplaceTokenProvider;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ProjectServiceProvider;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ *
+ * @author sdedic
+ */
+@ProjectServiceProvider(
+ service = ReplaceTokenProvider.class,
+ projectType = NbGradleProject.GRADLE_PROJECT_TYPE
+)
+public class JavaDebugTokenProvider implements ReplaceTokenProvider {
+ /**
+ * Replaceable token for debugging port.
+ */
+ public static String TOKEN_JAVAEXEC_DEBUG_PORT = "javaExec.debug.port"; // NOI18N
+
+ private static final Set<String> TOKENS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
+ TOKEN_JAVAEXEC_DEBUG_PORT
+ )));
+
+ private static final Set<String> DEBUG_ACTIONS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
+ ActionProvider.COMMAND_DEBUG,
+ ActionProvider.COMMAND_DEBUG_SINGLE,
+ ActionProvider.COMMAND_DEBUG_TEST_SINGLE
+ )));
+
+ private final Project project;
+
+ public JavaDebugTokenProvider(Project project) {
+ this.project = project;
+ }
+
+ @Override
+ public Set<String> getSupportedTokens() {
+ return isEnabled() ? TOKENS : Collections.emptySet();
+ }
+
+ private boolean isEnabled() {
+ Set<String> plugins = GradleBaseProject.get(project).getPlugins();
+ return plugins.contains("java"); // NOI18N
Review Comment:
`java-base` may be safer.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
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