Skip to content

Commit 90cc9aa

Browse files
authored
fix: Misleading behavior after cancelling exporting jar (#511)
1 parent 176c31c commit 90cc9aa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/ProjectCommand.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.eclipse.core.runtime.IStatus;
4141
import org.eclipse.core.runtime.MultiStatus;
4242
import org.eclipse.core.runtime.NullProgressMonitor;
43+
import org.eclipse.core.runtime.OperationCanceledException;
4344
import org.eclipse.core.runtime.Path;
4445
import org.eclipse.jdt.core.IJavaElement;
4546
import org.eclipse.jdt.core.IJavaProject;
@@ -147,6 +148,19 @@ public static boolean exportJar(List<Object> arguments, IProgressMonitor monitor
147148
Classpath[] classpaths = gson.fromJson(gson.toJson(arguments.get(1)), Classpath[].class);
148149
String destination = gson.fromJson(gson.toJson(arguments.get(2)), String.class);
149150
String terminalId = gson.fromJson(gson.toJson(arguments.get(3)), String.class);
151+
try {
152+
return exportJarExecution(mainClass, classpaths, destination, terminalId, monitor);
153+
} catch (OperationCanceledException e) {
154+
File jarFile = new File(destination);
155+
if (jarFile.exists()) {
156+
jarFile.delete();
157+
}
158+
}
159+
return false;
160+
}
161+
162+
private static boolean exportJarExecution(String mainClass, Classpath[] classpaths, String destination,
163+
String terminalId, IProgressMonitor monitor) throws OperationCanceledException {
150164
Manifest manifest = new Manifest();
151165
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
152166
if (mainClass.length() > 0) {

0 commit comments

Comments
 (0)