-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Not all systems have zip, so use a simple java utility to strip
META-INF/services from the repackaged jetty jar.
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
java_binary( | ||
name = "DeleteFromZip", | ||
srcs = ["DeleteFromZip.java"], | ||
main_class = "org.openqa.selenium.tools.DeleteFromZip", | ||
visibility = ["//third_party/java/jetty:__pkg__"], | ||
deps = ["//third_party/java/guava"], | ||
) |
40 changes: 40 additions & 0 deletions
40
java/client/src/org/openqa/selenium/tools/DeleteFromZip.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.openqa.selenium.tools; | ||
|
||
import com.google.common.io.MoreFiles; | ||
import com.google.common.io.RecursiveDeleteOption; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.nio.file.FileSystem; | ||
import java.nio.file.FileSystems; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
final class DeleteFromZip { | ||
public static void main(String[] args) throws IOException { | ||
if (args.length < 2) { | ||
throw new RuntimeException("usage: [zip file] [paths to delete...]"); | ||
} | ||
|
||
Map<String, String> properties = new HashMap<>(); | ||
properties.put("create", "false"); | ||
|
||
Path zip = Paths.get(args[0]).toAbsolutePath(); | ||
URI uri = URI.create("jar:file:" + zip); | ||
try (FileSystem zipfs = FileSystems.newFileSystem(uri, properties)) { | ||
System.out.println("Opened " + args[0]); | ||
for (int i = 1; i < args.length; i++) { | ||
Path path = zipfs.getPath(args[i]); | ||
if (Files.isDirectory(path)) { | ||
MoreFiles.deleteRecursively(path, RecursiveDeleteOption.ALLOW_INSECURE); | ||
System.out.println("Deleted directory " + args[i]); | ||
} else if (Files.exists(path)) { | ||
Files.delete(path); | ||
System.out.println("Deleted file " + args[i]); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters