mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-11-21 01:00:54 +08:00
Allow to debug external process running from Gradle task
This commit is contained in:
parent
4cfbca96b8
commit
bf2cfa83f0
@ -50,7 +50,6 @@ public class BuildDaemon extends UnicastRemoteObject implements RemoteBuildServi
|
||||
private static final int MAX_PORT = 1 << 16;
|
||||
private static final String DAEMON_MESSAGE_PREFIX = "TeaVM daemon port: ";
|
||||
private static final String INCREMENTAL_PROPERTY = "teavm.daemon.incremental";
|
||||
private static final String DEBUG_PORT_PROPERTY = "teavm.daemon.debug.port";
|
||||
private boolean incremental;
|
||||
private int port;
|
||||
private Registry registry;
|
||||
@ -269,6 +268,11 @@ public class BuildDaemon extends UnicastRemoteObject implements RemoteBuildServi
|
||||
|
||||
public static DaemonInfo start(boolean incremental, int daemonMemory, DaemonLog log,
|
||||
String... classPathEntries) throws IOException {
|
||||
return start(0, incremental, daemonMemory, log, classPathEntries);
|
||||
}
|
||||
|
||||
public static DaemonInfo start(int debugPort, boolean incremental, int daemonMemory, DaemonLog log,
|
||||
String... classPathEntries) throws IOException {
|
||||
String javaHome = System.getProperty("java.home");
|
||||
String javaCommand = javaHome + "/bin/java";
|
||||
String classPath = String.join(File.pathSeparator, classPathEntries);
|
||||
@ -278,8 +282,7 @@ public class BuildDaemon extends UnicastRemoteObject implements RemoteBuildServi
|
||||
"-D" + INCREMENTAL_PROPERTY + "=" + incremental,
|
||||
"-Xmx" + daemonMemory + "m"));
|
||||
|
||||
String debugPort = System.getProperty(DEBUG_PORT_PROPERTY);
|
||||
if (debugPort != null) {
|
||||
if (debugPort != 0) {
|
||||
arguments.add("-agentlib:jdwp=transport=dt_socket,quiet=y,server=y,address=" + debugPort + ",suspend=y");
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import org.gradle.api.provider.MapProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.Classpath;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
import org.gradle.api.tasks.Optional;
|
||||
import org.gradle.api.tasks.OutputDirectory;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
@ -97,6 +98,9 @@ public abstract class TeaVMTask extends DefaultTask {
|
||||
|
||||
@Classpath
|
||||
public abstract ConfigurableFileCollection getDaemonClasspath();
|
||||
|
||||
@Internal
|
||||
public abstract Property<Integer> getDaemonDebugPort();
|
||||
|
||||
@TaskAction
|
||||
public void execute() throws BuildException, IOException, NotBoundException {
|
||||
@ -108,7 +112,8 @@ public abstract class TeaVMTask extends DefaultTask {
|
||||
}
|
||||
|
||||
private void executeInSeparateProcess() throws BuildException, IOException, NotBoundException {
|
||||
var daemon = BuildDaemon.start(false, getProcessMemory().get(), new DaemonLogImpl(),
|
||||
var debugPort = getDaemonDebugPort().isPresent() ? getDaemonDebugPort().get() : 0;
|
||||
var daemon = BuildDaemon.start(debugPort, false, getProcessMemory().get(), new DaemonLogImpl(),
|
||||
createDaemonClassPath());
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user