langtools/test/tools/javac/modules/AutomaticModules.java
author jjg
Thu, 31 Mar 2016 15:20:50 -0700
changeset 36778 e04318f39f92
parent 36526 3b41f1c69604
child 37758 3ecf9b414e05
permissions -rw-r--r--
8152897: refactor ToolBox to allow reduced documented dependencies Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    23
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    24
/**
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    25
 * @test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    26
 * @summary Test automatic modules
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    27
 * @library /tools/lib
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    28
 * @modules
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    29
 *      jdk.compiler/com.sun.tools.javac.api
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    30
 *      jdk.compiler/com.sun.tools.javac.main
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    31
 * @build toolbox.ToolBox toolbox.JavacTask toolbox.JarTask ModuleTestBase
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 * @run main AutomaticModules
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    34
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    35
import java.nio.file.Files;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    36
import java.nio.file.Path;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    37
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    38
import toolbox.JarTask;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    39
import toolbox.JavacTask;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    40
import toolbox.Task;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    41
import toolbox.ToolBox;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    42
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    43
public class AutomaticModules extends ModuleTestBase {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    44
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    45
    public static void main(String... args) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    46
        AutomaticModules t = new AutomaticModules();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    47
        t.runTests();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    48
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    49
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    50
    @Test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    51
    void testSimple(Path base) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    52
        Path legacySrc = base.resolve("legacy-src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    53
        tb.writeJavaFiles(legacySrc,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    54
                          "package api; import java.awt.event.ActionListener; public abstract class Api implements ActionListener {}");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    55
        Path legacyClasses = base.resolve("legacy-classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    56
        Files.createDirectories(legacyClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    57
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    58
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    59
                .options()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    60
                .outdir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    61
                .files(findJavaFiles(legacySrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    62
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    63
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    64
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    65
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    66
        if (!log.isEmpty()) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    67
            throw new Exception("unexpected output: " + log);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    68
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    69
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    70
        Path modulePath = base.resolve("module-path");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    71
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    72
        Files.createDirectories(modulePath);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    73
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    74
        Path jar = modulePath.resolve("test-api-1.0.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    75
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    76
        new JarTask(tb, jar)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    77
          .baseDir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    78
          .files("api/Api.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    79
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    80
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    81
        Path moduleSrc = base.resolve("module-src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    82
        Path m1 = moduleSrc.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    83
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    84
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    85
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    86
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    87
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    88
        tb.writeJavaFiles(m1,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    89
                          "module m1 { requires test.api; }",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    90
                          "package impl; public class Impl { public void e(api.Api api) { api.actionPerformed(null); } }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    91
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    92
        new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    93
                .options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString(), "-addmods", "java.desktop")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    94
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    95
                .files(findJavaFiles(moduleSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    96
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    97
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    98
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    99
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   100
    @Test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   101
    void testUnnamedModule(Path base) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   102
        Path legacySrc = base.resolve("legacy-src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   103
        tb.writeJavaFiles(legacySrc,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   104
                          "package api; public abstract class Api { public void run(CharSequence str) { } private void run(base.Base base) { } }",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   105
                          "package base; public interface Base { public void run(); }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   106
        Path legacyClasses = base.resolve("legacy-classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   107
        Files.createDirectories(legacyClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   108
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   109
        String log = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   110
                .options()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   111
                .outdir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   112
                .files(findJavaFiles(legacySrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   113
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   114
                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   115
                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   116
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   117
        if (!log.isEmpty()) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   118
            throw new Exception("unexpected output: " + log);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   119
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   120
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   121
        Path modulePath = base.resolve("module-path");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   122
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   123
        Files.createDirectories(modulePath);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   124
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   125
        Path apiJar = modulePath.resolve("test-api-1.0.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   126
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   127
        new JarTask(tb, apiJar)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   128
          .baseDir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   129
          .files("api/Api.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   130
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   131
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   132
        Path baseJar = base.resolve("base.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   133
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   134
        new JarTask(tb, baseJar)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   135
          .baseDir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   136
          .files("base/Base.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   137
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   138
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   139
        Path moduleSrc = base.resolve("module-src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   140
        Path m1 = moduleSrc.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   141
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   142
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   143
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   144
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   145
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   146
        tb.writeJavaFiles(m1,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   147
                          "module m1 { requires test.api; }",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   148
                          "package impl; public class Impl { public void e(api.Api api) { api.run(\"\"); } }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   149
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   150
        new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   151
                .options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString(), "-classpath", baseJar.toString())
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   152
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   153
                .files(findJavaFiles(moduleSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   154
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   155
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   156
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   157
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   158
    @Test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   159
    void testModuleInfoFromClassFileDependsOnAutomatic(Path base) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   160
        Path automaticSrc = base.resolve("automaticSrc");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   161
        tb.writeJavaFiles(automaticSrc, "package api; public class Api {}");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   162
        Path automaticClasses = base.resolve("automaticClasses");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   163
        tb.createDirectories(automaticClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   164
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   165
        String automaticLog = new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   166
                                .outdir(automaticClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   167
                                .files(findJavaFiles(automaticSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   168
                                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   169
                                .writeAll()
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   170
                                .getOutput(Task.OutputKind.DIRECT);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   171
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   172
        if (!automaticLog.isEmpty())
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   173
            throw new Exception("expected output not found: " + automaticLog);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   174
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   175
        Path modulePath = base.resolve("module-path");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   176
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   177
        Files.createDirectories(modulePath);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   178
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   179
        Path automaticJar = modulePath.resolve("automatic-1.0.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   180
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   181
        new JarTask(tb, automaticJar)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   182
          .baseDir(automaticClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   183
          .files("api/Api.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   184
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   185
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   186
        Path depSrc = base.resolve("depSrc");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   187
        Path depClasses = base.resolve("depClasses");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   188
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   189
        Files.createDirectories(depSrc);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   190
        Files.createDirectories(depClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   191
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   192
        tb.writeJavaFiles(depSrc,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   193
                          "module m1 { requires public automatic; }",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   194
                          "package dep; public class Dep { api.Api api; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   195
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   196
        new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   197
                .options("-modulepath", modulePath.toString())
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   198
                .outdir(depClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   199
                .files(findJavaFiles(depSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   200
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   201
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   202
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   203
        Path moduleJar = modulePath.resolve("m1.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   204
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   205
        new JarTask(tb, moduleJar)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   206
          .baseDir(depClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   207
          .files("module-info.class", "dep/Dep.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   208
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   209
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   210
        Path testSrc = base.resolve("testSrc");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   211
        Path testClasses = base.resolve("testClasses");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   212
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   213
        Files.createDirectories(testSrc);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   214
        Files.createDirectories(testClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   215
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   216
        tb.writeJavaFiles(testSrc,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   217
                          "module m2 { requires automatic; }",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   218
                          "package test; public class Test { }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   219
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
   220
        new JavacTask(tb)
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   221
                .options("-modulepath", modulePath.toString())
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   222
                .outdir(testClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   223
                .files(findJavaFiles(testSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   224
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   225
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   226
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   227
}