Skip to content

Commit 74af324

Browse files
committed
Updated build scripts so that extension can be built on windows
1 parent bbf71ef commit 74af324

File tree

8 files changed

+49
-43
lines changed

8 files changed

+49
-43
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
<copy file="vscode/package.json" todir="${build.dir}/bundles/package" />
147147
<copy file="vscode/package-lock.json" todir="${build.dir}/bundles/package" />
148148

149-
<exec executable="mvn" failonerror="true" dir="${nb_all}/nbbuild/misc/prepare-bundles">
149+
<exec executable="mvn${cmd.suffix}" failonerror="true" dir="${nb_all}/nbbuild/misc/prepare-bundles">
150150
<arg value="package" />
151151
<arg value="exec:java" />
152152
<arg value="-Dexec.mainClass=org.netbeans.prepare.bundles.PrepareBundles" />

patches/7271.diff

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/nbbuild/misc/prepare-bundles/src/main/java/org/netbeans/prepare/bundles/PrepareBundles.java b/nbbuild/misc/prepare-bundles/src/main/java/org/netbeans/prepare/bundles/PrepareBundles.java
2-
index 5349a20e09..952709d10b 100644
2+
index 5349a20e09..f2b040204e 100644
33
--- a/nbbuild/misc/prepare-bundles/src/main/java/org/netbeans/prepare/bundles/PrepareBundles.java
44
+++ b/nbbuild/misc/prepare-bundles/src/main/java/org/netbeans/prepare/bundles/PrepareBundles.java
55
@@ -58,7 +58,8 @@ public class PrepareBundles {
@@ -12,7 +12,21 @@ index 5349a20e09..952709d10b 100644
1212
);
1313
private static final String nl = "\n";
1414

15-
@@ -107,18 +108,18 @@ public class PrepareBundles {
15+
@@ -69,7 +70,12 @@ public class PrepareBundles {
16+
17+
Path targetDir = Paths.get(args[0]);
18+
Path packagesDir = targetDir.resolve("package");
19+
- new ProcessBuilder("npm", "install").directory(packagesDir.toFile()).inheritIO().start().waitFor();
20+
+ String os = System.getProperty("os.name").toLowerCase();
21+
+ if (os.contains("windows")) {
22+
+ new ProcessBuilder("npm.cmd", "install").directory(packagesDir.toFile()).inheritIO().start().waitFor();
23+
+ } else{
24+
+ new ProcessBuilder("npm", "install").directory(packagesDir.toFile()).inheritIO().start().waitFor();
25+
+ }
26+
Path bundlesDir = targetDir.resolve("bundles");
27+
Files.createDirectories(bundlesDir);
28+
try (DirectoryStream<Path> ds = Files.newDirectoryStream(bundlesDir)) {
29+
@@ -107,18 +113,18 @@ public class PrepareBundles {
1630
if ("@types".equals(module.getFileName().toString())) continue;
1731
if ("@esbuild".equals(module.getFileName().toString())) continue;
1832
if ("@microsoft".equals(module.getFileName().toString())) continue;

vscode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,9 +755,9 @@
755755
},
756756
"scripts": {
757757
"vscode:prepublish": "npm run compile",
758-
"compile": "tsc -p ./; node ./esbuild.js",
758+
"compile": "tsc -p ./ && node ./esbuild.js",
759759
"watch": "tsc -watch -p ./ | node ./esbuild.js --watch",
760-
"test": "node ./out/test/runTest.js",
760+
"test": "npm run compile && node ./out/test/runTest.js",
761761
"nbcode": "node ./out/nbcode.js",
762762
"nbjavac": "node ./out/nbcode.js -J-Dnetbeans.close=true --modules --install .*nbjavac.*",
763763
"apisupport": "node ./out/nbcode.js -J-Dnetbeans.close=true --modules --install '(org.netbeans.libs.xerces|org.netbeans.modules.editor.structure|org.netbeans.modules.xml|org.netbeans.modules.xml.axi|org.netbeans.modules.xml.retriever|org.netbeans.modules.xml.schema.model|org.netbeans.modules.xml.tax|org.netbeans.modules.xml.text|org.netbeans.modules.ant.browsetask|.*apisupport.*|org.netbeans.modules.debugger.jpda.ant)' && node ./out/nbcode.js -J-Dnetbeans.close=true --modules --enable .*apisupport.ant",

vscode/src/test/runTest.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,27 @@ async function main() {
2828
// The folder containing the Extension Manifest package.json
2929
// Passed to `--extensionDevelopmentPath`
3030
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
31+
const outRootPath = path.join(extensionDevelopmentPath, 'out');
3132

3233
const vscodeExecutablePath: string = await downloadAndUnzipVSCode('stable');
3334

34-
const outRoot = path.join(extensionDevelopmentPath, "out");
35-
const extDir = path.join(outRoot, "test", "vscode", "exts");
36-
const userDir = path.join(outRoot, "test", "vscode", "user");
37-
38-
const testSuites = fs.readdirSync(path.resolve(__dirname, './suite'));
35+
const vscodeTestDir = path.join(__dirname, "vscode");
36+
const extDir = path.join(vscodeTestDir, "exts");
37+
const userDir = path.join(vscodeTestDir, "user");
38+
const suitesDir = path.join(__dirname, 'suite');
39+
const testSuites = fs.readdirSync(suitesDir);
3940

4041
for (const suiteName of testSuites) {
4142
// The path to test runner
4243
// Passed to --extensionTestsPath
43-
const extensionTestsPath = path.resolve(__dirname, `./suite/${suiteName}/index`);
44-
const workspaceDir = path.join(extensionDevelopmentPath, 'out', 'test', 'suite', suiteName, 'ws');
45-
if (!fs.statSync(workspaceDir).isDirectory()) {
46-
throw `Expecting ${workspaceDir} to be a directory!`;
44+
const suiteDir = path.join(suitesDir, suiteName);
45+
const extensionTestsPath = path.join(suiteDir, 'index');
46+
const workspaceDir = path.join(suiteDir, 'ws');
47+
48+
if (fs.existsSync(workspaceDir)) {
49+
fs.rmdirSync(workspaceDir, { recursive: true });
4750
}
51+
fs.mkdirSync(workspaceDir, { recursive: true });
4852

4953
// Download VS Code, unzip it and run the integration test
5054
await runTests({
@@ -53,7 +57,7 @@ async function main() {
5357
extensionTestsPath,
5458
extensionTestsEnv: {
5559
'ENABLE_CONSOLE_LOG': 'true',
56-
"netbeans.extra.options": `-J-Dproject.limitScanRoot=${outRoot} -J-Dnetbeans.logger.console=true`
60+
"netbeans.extra.options": `-J-Dproject.limitScanRoot=${outRootPath} -J-Dnetbeans.logger.console=true`
5761
},
5862
launchArgs: [
5963
'--disable-extensions',
@@ -66,6 +70,7 @@ async function main() {
6670
}
6771
} catch (err) {
6872
console.error('Failed to run tests');
73+
console.error((err as Error).message);
6974
process.exit(1);
7075
}
7176
}

vscode/src/test/suite/general/explorer.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,12 @@
2121
*/
2222

2323
import * as assert from 'assert';
24-
import * as fs from 'fs';
25-
import * as Mocha from 'mocha';
2624

2725
// You can import and use all API from the 'vscode' module
2826
// as well as import your extension to test it
2927
import * as vscode from 'vscode';
3028
import * as myExtension from '../../../extension';
3129
import * as myExplorer from '../../../explorer';
32-
import { assertWorkspace } from '../../testutils';
33-
34-
Mocha.before(async () => {
35-
vscode.window.showInformationMessage('Cleaning up workspace.');
36-
let folder: string = assertWorkspace();
37-
await fs.promises.rmdir(folder, { recursive: true });
38-
await fs.promises.mkdir(folder, { recursive: true });
39-
});
4030

4131
suite('Explorer Test Suite', () => {
4232
vscode.window.showInformationMessage('Start explorer tests.');

vscode/src/test/suite/general/extension.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ suite('Extension Test Suite', function () {
7474
let found: string[] = [];
7575
function assertCluster(name: string) {
7676
for (let c of clusters) {
77-
if (c.endsWith('/' + name)) {
77+
if (c.endsWith('/' + name) || c.endsWith('\\' + name)) {
7878
found.push(c);
7979
return;
8080
}
@@ -232,31 +232,31 @@ suite('Extension Test Suite', function () {
232232
console.log(`Test: get project java source roots finished with ${res}`);
233233
assert.ok(res, "No java source root returned");
234234
assert.strictEqual(res.length, 2, `Invalid number of java roots returned`);
235-
assert.strictEqual(res[0], path.join('file:', folder, 'src', 'main', 'java') + path.sep, `Invalid java main source root returned`);
236-
assert.strictEqual(res[1], path.join('file:', folder, 'src', 'test', 'java') + path.sep, `Invalid java test source root returned`);
235+
assert.strictEqual(path.join(res[0]).toLowerCase(), (path.join('file:', folder, 'src', 'main', 'java') + path.sep).toLowerCase(), `Invalid java main source root returned`);
236+
assert.strictEqual(path.join(res[1]).toLowerCase(), (path.join('file:', folder, 'src', 'test', 'java') + path.sep).toLowerCase(), `Invalid java test source root returned`);
237237

238238
console.log("Test: get project resource roots");
239239
res = await commands.executeCommand("jdk.java.get.project.source.roots", Uri.file(folder).toString(), 'resources');
240240
console.log(`Test: get project resource roots finished with ${res}`);
241241
assert.ok(res, "No resource root returned");
242242
assert.strictEqual(res.length, 1, `Invalid number of resource roots returned`);
243-
assert.strictEqual(res[0], path.join('file:', folder, 'src', 'main', 'resources') + path.sep, `Invalid resource root returned`);
243+
assert.strictEqual(path.join(res[0]).toLowerCase(), (path.join('file:', folder, 'src', 'main', 'resources') + path.sep).toLowerCase(), `Invalid resource root returned`);
244244

245245
console.log("Test: get project compile classpath");
246246
res = await commands.executeCommand("jdk.java.get.project.classpath", Uri.file(folder).toString());
247247
console.log(`Test: get project compile classpath finished with ${res}`);
248248
assert.ok(res, "No compile classpath returned");
249249
assert.strictEqual(res.length, 9, `Invalid number of compile classpath roots returned`);
250-
assert.ok(res.find((item: any) => item === path.join('file:', folder, 'target', 'classes') + path.sep, `Invalid compile classpath root returned`));
250+
assert.ok(res.find((item: string) => path.join(item).toLowerCase() === (path.join('file:', folder, 'target', 'classes') + path.sep).toLowerCase(), `Invalid compile classpath root returned`));
251251

252252
console.log("Test: get project source classpath");
253253
res = await commands.executeCommand("jdk.java.get.project.classpath", Uri.file(folder).toString(), 'SOURCE');
254254
console.log(`Test: get project source classpath finished with ${res}`);
255255
assert.ok(res, "No source classpath returned");
256256
assert.strictEqual(res.length, 3, `Invalid number of source classpath roots returned`);
257-
assert.ok(res.find((item: any) => item === path.join('file:', folder, 'src', 'main', 'java') + path.sep, `Invalid source classpath root returned`));
258-
assert.ok(res.find((item: any) => item === path.join('file:', folder, 'src', 'main', 'resources') + path.sep, `Invalid source classpath root returned`));
259-
assert.ok(res.find((item: any) => item === path.join('file:', folder, 'src', 'test', 'java') + path.sep, `Invalid source classpath root returned`));
257+
assert.ok(res.find((item: string) => path.join(item).toLowerCase() === (path.join('file:', folder, 'src', 'main', 'java') + path.sep).toLowerCase(), `Invalid source classpath root returned`));
258+
assert.ok(res.find((item: string) => path.join(item).toLowerCase() === (path.join('file:', folder, 'src', 'main', 'resources') + path.sep).toLowerCase(), `Invalid source classpath root returned`));
259+
assert.ok(res.find((item: string) => path.join(item).toLowerCase() === (path.join('file:', folder, 'src', 'test', 'java') + path.sep).toLowerCase(), `Invalid source classpath root returned`));
260260

261261
console.log("Test: get project boot classpath");
262262
res = await commands.executeCommand("jdk.java.get.project.classpath", Uri.file(folder).toString(), 'BOOT');

vscode/src/test/suite/gradle/extension.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,11 @@
2323

2424
import * as assert from "assert";
2525
import * as fs from "fs";
26-
import * as Mocha from 'mocha';
2726
import * as path from "path";
2827

2928
import { commands, window } from "vscode";
3029
import { assertWorkspace, dumpJava, gradleInitJavaApplication } from "../../testutils";
3130

32-
Mocha.before(async () => {
33-
window.showInformationMessage('Cleaning up workspace.');
34-
let folder: string = assertWorkspace();
35-
await fs.promises.rmdir(folder, { recursive: true });
36-
await fs.promises.mkdir(folder, { recursive: true });
37-
});
3831

3932
suite("Extension gradle tests", function () {
4033
window.showInformationMessage("Starting Gradle tests");
@@ -49,8 +42,12 @@ suite("Extension gradle tests", function () {
4942
const mainClass = path.join(
5043
folder,
5144
"build",
52-
"classes/java",
53-
"main/org/yourCompany/yourProject",
45+
"classes",
46+
"java",
47+
"main",
48+
"org",
49+
"yourCompany",
50+
"yourProject",
5451
"App.class"
5552
);
5653
assert.ok(

vscode/src/test/testutils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ export function runTestSuite(folder: string): Promise<void> {
299299
const mocha = new Mocha({
300300
ui: 'tdd',
301301
color: true,
302-
timeout: 60000
302+
timeout: 10*1000*60
303303
});
304304

305305
const testsRoot = path.resolve(folder);

0 commit comments

Comments
 (0)