Skip to content

Commit 5c4f4f8

Browse files
authored
Add utility method to quickly construct JarContent if no filters or replacement manifests are to be used (#65)
The most common use of JarContentBuilder is: ```java new JarContentsBuilder().paths(path).build() ``` This allows: ```java JarContents.of(path) or paths.map(JarContents::of) ```
1 parent f4a3e66 commit 5c4f4f8

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/main/java/cpw/mods/jarhandling/JarContents.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.net.URI;
66
import java.nio.file.Path;
7+
import java.util.Collection;
78
import java.util.List;
89
import java.util.Optional;
910
import java.util.Set;
@@ -52,4 +53,20 @@ public interface JarContents {
5253
* Parses the {@code META-INF/services} files in the jar, and returns the list of service providers.
5354
*/
5455
List<SecureJar.Provider> getMetaInfServices();
56+
57+
/**
58+
* Create plain jar contents from a single jar file or folder.
59+
* For more advanced use-cases see {@link JarContentsBuilder}.
60+
*/
61+
static JarContents of(Path fileOrFolder) {
62+
return new JarContentsBuilder().paths(fileOrFolder).build();
63+
}
64+
65+
/**
66+
* Create a virtual jar that consists of the contents of the given jar-files and folders.
67+
* For more advanced use-cases see {@link JarContentsBuilder}.
68+
*/
69+
static JarContents of(Collection<Path> filesOrFolders) {
70+
return new JarContentsBuilder().paths(filesOrFolders.toArray(new Path[0])).build();
71+
}
5572
}

0 commit comments

Comments
 (0)