langtools/test/tools/javac/modules/AutomaticModules.java
author alanb
Thu, 17 Mar 2016 19:04:28 +0000
changeset 36526 3b41f1c69604
child 36778 e04318f39f92
permissions -rw-r--r--
8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: jjg, jlahoda, vromero, mcimadamore, bpatel, ksrini, darcy, anazarov, dfuchs Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, jan.lahoda@oracle.com, vicente.romero@oracle.com, andreas.lundblad@oracle.com, andrey.x.nazarov@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, kumar.x.srinivasan@oracle.com, sundararajan.athijegannathan@oracle.com
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
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 *      jdk.jdeps/com.sun.tools.javap
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 * @build ToolBox ModuleTestBase
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 * @run main AutomaticModules
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    34
 */
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    35
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    36
import java.nio.file.Files;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    37
import java.nio.file.Path;
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    38
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    39
public class AutomaticModules extends ModuleTestBase {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    40
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    41
    public static void main(String... args) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    42
        AutomaticModules t = new AutomaticModules();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    43
        t.runTests();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    44
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    45
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    46
    @Test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    47
    void testSimple(Path base) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    48
        Path legacySrc = base.resolve("legacy-src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    49
        tb.writeJavaFiles(legacySrc,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    50
                          "package api; import java.awt.event.ActionListener; public abstract class Api implements ActionListener {}");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    51
        Path legacyClasses = base.resolve("legacy-classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    52
        Files.createDirectories(legacyClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    53
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    54
        String log = tb.new JavacTask()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    55
                .options()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    56
                .outdir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    57
                .files(findJavaFiles(legacySrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    58
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    59
                .writeAll()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    60
                .getOutput(ToolBox.OutputKind.DIRECT);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    61
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    62
        if (!log.isEmpty()) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    63
            throw new Exception("unexpected output: " + log);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    64
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    65
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    66
        Path modulePath = base.resolve("module-path");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    67
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    68
        Files.createDirectories(modulePath);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    69
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    70
        Path jar = modulePath.resolve("test-api-1.0.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    71
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    72
        tb.new JarTask(jar)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    73
          .baseDir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    74
          .files("api/Api.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    75
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    76
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    77
        Path moduleSrc = base.resolve("module-src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    78
        Path m1 = moduleSrc.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    79
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    80
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    81
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    82
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    83
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    84
        tb.writeJavaFiles(m1,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    85
                          "module m1 { requires test.api; }",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    86
                          "package impl; public class Impl { public void e(api.Api api) { api.actionPerformed(null); } }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    87
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    88
        tb.new JavacTask()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    89
                .options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString(), "-addmods", "java.desktop")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    90
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    91
                .files(findJavaFiles(moduleSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    92
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    93
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    94
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    95
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    96
    @Test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    97
    void testUnnamedModule(Path base) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    98
        Path legacySrc = base.resolve("legacy-src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
    99
        tb.writeJavaFiles(legacySrc,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   100
                          "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
   101
                          "package base; public interface Base { public void run(); }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   102
        Path legacyClasses = base.resolve("legacy-classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   103
        Files.createDirectories(legacyClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   104
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   105
        String log = tb.new JavacTask()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   106
                .options()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   107
                .outdir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   108
                .files(findJavaFiles(legacySrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   109
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   110
                .writeAll()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   111
                .getOutput(ToolBox.OutputKind.DIRECT);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   112
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   113
        if (!log.isEmpty()) {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   114
            throw new Exception("unexpected output: " + log);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   115
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   116
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   117
        Path modulePath = base.resolve("module-path");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   118
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   119
        Files.createDirectories(modulePath);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   120
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   121
        Path apiJar = modulePath.resolve("test-api-1.0.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   122
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   123
        tb.new JarTask(apiJar)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   124
          .baseDir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   125
          .files("api/Api.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   126
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   127
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   128
        Path baseJar = base.resolve("base.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   129
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   130
        tb.new JarTask(baseJar)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   131
          .baseDir(legacyClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   132
          .files("base/Base.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   133
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   134
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   135
        Path moduleSrc = base.resolve("module-src");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   136
        Path m1 = moduleSrc.resolve("m1");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   137
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   138
        Path classes = base.resolve("classes");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   139
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   140
        Files.createDirectories(classes);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   141
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   142
        tb.writeJavaFiles(m1,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   143
                          "module m1 { requires test.api; }",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   144
                          "package impl; public class Impl { public void e(api.Api api) { api.run(\"\"); } }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   145
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   146
        tb.new JavacTask()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   147
                .options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString(), "-classpath", baseJar.toString())
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   148
                .outdir(classes)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   149
                .files(findJavaFiles(moduleSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   150
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   151
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   152
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   153
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   154
    @Test
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   155
    void testModuleInfoFromClassFileDependsOnAutomatic(Path base) throws Exception {
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   156
        Path automaticSrc = base.resolve("automaticSrc");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   157
        tb.writeJavaFiles(automaticSrc, "package api; public class Api {}");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   158
        Path automaticClasses = base.resolve("automaticClasses");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   159
        tb.createDirectories(automaticClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   160
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   161
        String automaticLog = tb.new JavacTask()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   162
                                .outdir(automaticClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   163
                                .files(findJavaFiles(automaticSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   164
                                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   165
                                .writeAll()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   166
                                .getOutput(ToolBox.OutputKind.DIRECT);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   167
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   168
        if (!automaticLog.isEmpty())
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   169
            throw new Exception("expected output not found: " + automaticLog);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   170
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   171
        Path modulePath = base.resolve("module-path");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   172
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   173
        Files.createDirectories(modulePath);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   174
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   175
        Path automaticJar = modulePath.resolve("automatic-1.0.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   176
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   177
        tb.new JarTask(automaticJar)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   178
          .baseDir(automaticClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   179
          .files("api/Api.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   180
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   181
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   182
        Path depSrc = base.resolve("depSrc");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   183
        Path depClasses = base.resolve("depClasses");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   184
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   185
        Files.createDirectories(depSrc);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   186
        Files.createDirectories(depClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   187
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   188
        tb.writeJavaFiles(depSrc,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   189
                          "module m1 { requires public automatic; }",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   190
                          "package dep; public class Dep { api.Api api; }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   191
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   192
        tb.new JavacTask()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   193
                .options("-modulepath", modulePath.toString())
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   194
                .outdir(depClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   195
                .files(findJavaFiles(depSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   196
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   197
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   198
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   199
        Path moduleJar = modulePath.resolve("m1.jar");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   200
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   201
        tb.new JarTask(moduleJar)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   202
          .baseDir(depClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   203
          .files("module-info.class", "dep/Dep.class")
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   204
          .run();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   205
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   206
        Path testSrc = base.resolve("testSrc");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   207
        Path testClasses = base.resolve("testClasses");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   208
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   209
        Files.createDirectories(testSrc);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   210
        Files.createDirectories(testClasses);
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   211
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   212
        tb.writeJavaFiles(testSrc,
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   213
                          "module m2 { requires automatic; }",
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   214
                          "package test; public class Test { }");
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   215
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   216
        tb.new JavacTask()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   217
                .options("-modulepath", modulePath.toString())
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   218
                .outdir(testClasses)
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   219
                .files(findJavaFiles(testSrc))
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   220
                .run()
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   221
                .writeAll();
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   222
    }
3b41f1c69604 8142968: Module System implementation
alanb
parents:
diff changeset
   223
}