test/jdk/tools/jar/ReleaseBeforeFiles.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 45467 jdk/test/tools/jar/ReleaseBeforeFiles.java@99c87a16a8e4
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41489
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
     1
/*
45286
cd809e28c082 8180887: move FileUtils to top level testlibrary
iignatyev
parents: 41489
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
41489
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
     4
 *
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
     8
 *
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    13
 * accompanied this code).
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    14
 *
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    18
 *
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    21
 * questions.
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    22
 */
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    23
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    24
/*
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    25
 * @test
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    26
 * @bug 8167237
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    27
 * @summary test that both old style command line options and new gnu style
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    28
 *          command line options work with the --release option whether or
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    29
 *          not the --release option is preceded by a file name.
45286
cd809e28c082 8180887: move FileUtils to top level testlibrary
iignatyev
parents: 41489
diff changeset
    30
 * @library /test/lib
41489
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    31
 * @modules jdk.jartool/sun.tools.jar
45467
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45286
diff changeset
    32
 * @build jdk.test.lib.Platform
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45286
diff changeset
    33
 *        jdk.test.lib.util.FileUtils
41489
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    34
 * @run testng ReleaseBeforeFiles
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    35
 */
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    36
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    37
import org.testng.Assert;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    38
import org.testng.annotations.AfterMethod;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    39
import org.testng.annotations.BeforeMethod;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    40
import org.testng.annotations.Test;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    41
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    42
import java.io.IOException;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    43
import java.io.UncheckedIOException;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    44
import java.nio.file.Files;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    45
import java.nio.file.Path;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    46
import java.nio.file.Paths;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    47
import java.util.Arrays;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    48
import java.util.stream.Stream;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    49
45286
cd809e28c082 8180887: move FileUtils to top level testlibrary
iignatyev
parents: 41489
diff changeset
    50
import jdk.test.lib.util.FileUtils;
41489
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    51
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    52
public class ReleaseBeforeFiles {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    53
    private Runnable onCompletion;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    54
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    55
    @BeforeMethod
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    56
    public void reset() {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    57
        onCompletion = null;
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    58
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    59
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    60
    @AfterMethod
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    61
    public void run() {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    62
        if (onCompletion != null) {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    63
            onCompletion.run();
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    64
        }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    65
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    66
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    67
    @Test  // passes before bug fix
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    68
    public void test1() throws IOException {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    69
        mkdir("test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    70
        touch("test1/testfile1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    71
        jar("cf test.jar --release 9 test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    72
        jar("tf test.jar");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    73
        rm("test.jar test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    74
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    75
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    76
    @Test  // fails before bug fix
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    77
    public void test2() throws IOException {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    78
        System.out.println("=====");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    79
        mkdir("test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    80
        touch("test1/testfile1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    81
        onCompletion = () -> rm("test.jar test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    82
        jar("--create --file=test.jar --release 9 test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    83
        jar("tf test.jar");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    84
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    85
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    86
    @Test  // passes before bug fix
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    87
    public void test3() throws IOException {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    88
        System.out.println("=====");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    89
        mkdir("test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    90
        touch("test1/testfile1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    91
        jar("-cf test.jar -C test1 .");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    92
        jar("-uf test.jar --release 9 -C test1 .");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    93
        jar("tf test.jar");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    94
        rm("test.jar test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    95
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    96
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    97
    @Test  // fails before bug fix
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    98
    public void test4() throws IOException {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
    99
        System.out.println("=====");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   100
        mkdir("test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   101
        touch("test1/testfile1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   102
        onCompletion = () -> rm("test.jar test1");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   103
        jar("--create --file=test.jar -C test1 .");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   104
        jar("--update --file=test.jar --release 9 -C test1 .");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   105
        jar("tf test.jar");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   106
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   107
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   108
    @Test  // passes before bug fix since test2 precedes --release 9
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   109
    public void test5() throws IOException {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   110
        System.out.println("=====");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   111
        mkdir("test1 test2");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   112
        touch("test1/testfile1 test2/testfile2");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   113
        jar("--create --file=test.jar -C test1 .");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   114
        jar("--update --file=test.jar test2 --release 9 -C test1 .");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   115
        jar("tf test.jar");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   116
        rm("test.jar test1 test2");
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   117
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   118
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   119
    private Stream<Path> mkpath(String... args) {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   120
        return Arrays.stream(args).map(d -> Paths.get(".", d.split("/")));
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   121
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   122
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   123
    private void mkdir(String cmdline) {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   124
        System.out.println("mkdir -p " + cmdline);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   125
        mkpath(cmdline.split(" +")).forEach(p -> {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   126
            try {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   127
                Files.createDirectories(p);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   128
            } catch (IOException x) {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   129
                throw new UncheckedIOException(x);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   130
            }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   131
        });
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   132
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   133
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   134
    private void touch(String cmdline) {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   135
        System.out.println("touch " + cmdline);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   136
        mkpath(cmdline.split(" +")).forEach(p -> {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   137
            try {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   138
                Files.createFile(p);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   139
            } catch (IOException x) {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   140
                throw new UncheckedIOException(x);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   141
            }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   142
        });
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   143
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   144
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   145
    private void rm(String cmdline) {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   146
        System.out.println("rm -rf " + cmdline);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   147
        mkpath(cmdline.split(" +")).forEach(p -> {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   148
            try {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   149
                if (Files.isDirectory(p)) {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   150
                    FileUtils.deleteFileTreeWithRetry(p);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   151
                } else {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   152
                    FileUtils.deleteFileIfExistsWithRetry(p);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   153
                }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   154
            } catch (IOException x) {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   155
                throw new UncheckedIOException(x);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   156
            }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   157
        });
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   158
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   159
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   160
    private void jar(String cmdline) throws IOException {
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   161
        System.out.println("jar " + cmdline);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   162
        boolean ok = new sun.tools.jar.Main(System.out, System.err, "jar")
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   163
                .run(cmdline.split(" +"));
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   164
        Assert.assertTrue(ok);
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   165
    }
a289f1778f14 8167237: Jar tool can not correctly find/process the --release option if it occurs before the file list
sdrach
parents:
diff changeset
   166
}