aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox/find/find-jdk.qbs
blob: 81d84fa203e83a7ded6e03783a808f662901b1c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import qbs.TextFile

Product {
    Depends { name: "java"; required: false }
    type: ["json"]
    Rule {
        multiplex: true
        Artifact {
            filePath: ["jdk.json"]
            fileTags: ["json"]
        }
        prepare: {
            var cmd = new JavaScriptCommand();
            cmd.description = output.filePath;
            cmd.sourceCode = function() {
                var tools = {};
                if (product.moduleProperty("java", "present")) {
                    tools["javac"] = product.moduleProperty("java", "compilerFilePath");
                    tools["java"] = product.moduleProperty("java", "interpreterFilePath");
                    tools["jar"] = product.moduleProperty("java", "jarFilePath");
                }

                var tf;
                try {
                    tf = new TextFile(output.filePath, TextFile.WriteOnly);
                    tf.writeLine(JSON.stringify(tools, undefined, 4));
                } finally {
                    if (tf)
                        tf.close();
                }
            };
            return cmd;
        }
    }
}