Skip to content

Commit ecb14dd

Browse files
authored
fix: Exporting Jar lasts all time in unmanaged folders (#420)
1 parent b3b80ca commit ecb14dd

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/model/PackageNode.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class PackageNode {
4848
*/
4949
private static final String NATURE_ID = "NatureId";
5050

51+
private static final String UNMANAGED_FOLDER_INNER_PATH = "UnmanagedFolderInnerPath";
52+
5153
public static final String K_TYPE_KIND = "TypeKind";
5254

5355
/**
@@ -154,6 +156,9 @@ public static PackageNode createNodeForProject(IJavaElement javaElement) {
154156
projectNode.setUri(ProjectUtils.getProjectRealFolder(proj).toFile().toURI().toString());
155157
try {
156158
projectNode.setMetaDataValue(NATURE_ID, proj.getDescription().getNatureIds());
159+
if (!ProjectUtils.isVisibleProject(proj)) {
160+
projectNode.setMetaDataValue(UNMANAGED_FOLDER_INNER_PATH, proj.getLocationURI().toString());
161+
}
157162
} catch (CoreException e) {
158163
// do nothing
159164
}

src/exportJarSteps/GenerateJarExecutor.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,18 @@ export class GenerateJarExecutor implements IExportJarStepExecutor {
115115
return reject(new Error(ExportJarMessages.fieldUndefinedMessage(ExportJarMessages.Field.WORKSPACEFOLDER, this.currentStep)));
116116
}
117117
for (const project of projectList) {
118-
const classpaths: IClasspathResult = await extensionApi.getClasspaths(project.uri, { scope: "runtime" });
118+
const projectUri: string = project.metaData?.UnmanagedFolderInnerPath || project.uri;
119+
let classpaths: IClasspathResult;
120+
let testClasspaths: IClasspathResult;
121+
try {
122+
classpaths = await extensionApi.getClasspaths(projectUri, { scope: "runtime" });
123+
testClasspaths = await extensionApi.getClasspaths(projectUri, { scope: "test" });
124+
} catch (e) {
125+
return reject(new Error(e));
126+
}
119127
pickItems.push(
120128
...await this.parseDependencyItems(classpaths.classpaths, uriSet, workspaceFolder.uri.fsPath, "runtime"),
121129
...await this.parseDependencyItems(classpaths.modulepaths, uriSet, workspaceFolder.uri.fsPath, "runtime"));
122-
const testClasspaths: IClasspathResult = await extensionApi.getClasspaths(project.uri, { scope: "test" });
123130
pickItems.push(
124131
...await this.parseDependencyItems(testClasspaths.classpaths, uriSet, workspaceFolder.uri.fsPath, "test"),
125132
...await this.parseDependencyItems(testClasspaths.modulepaths, uriSet, workspaceFolder.uri.fsPath, "test"));

src/exportJarSteps/ResolveJavaProjectExecutor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class ResolveJavaProjectExecutor implements IExportJarStepExecutor {
6060
}
6161
const disposables: Disposable[] = [];
6262
try {
63-
await new Promise((resolve, reject) => {
63+
await new Promise<void>((resolve, reject) => {
6464
const pickBox = createPickBox<IJavaProjectQuickPickItem>("Export Jar : Determine workspace",
6565
"Select the workspace", pickItems, false);
6666
disposables.push(

0 commit comments

Comments
 (0)