diff --git a/build.gradle b/build.gradle index 6cf98a9..50daa9c 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ allprojects { } } -version = getProperty("version.executableJar") +version = getProperty("version.envelope") configurations { embedded @@ -72,9 +72,9 @@ jar { gradlePlugin { plugins { - create("ExecutableJarPlugin") { - id = "net.woggioni.gradle.executable-jar" - implementationClass = "net.woggioni.gradle.executable.jar.ExecutableJarPlugin" + create("EnvelopePlugin") { + id = "net.woggioni.gradle.envelope" + implementationClass = "net.woggioni.gradle.envelope.EnvelopePlugin" } } } diff --git a/common/build.gradle b/common/build.gradle index 2cf9fef..dced01e 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -5,6 +5,6 @@ java { jar { manifest { - attributes "Automatic-Module-Name" : "net.woggioni.executable.jar" + attributes "Automatic-Module-Name" : "net.woggioni.envelope" } } \ No newline at end of file diff --git a/common/src/main/java/net/woggioni/executable/jar/Common.java b/common/src/main/java/net/woggioni/envelope/Common.java similarity index 99% rename from common/src/main/java/net/woggioni/executable/jar/Common.java rename to common/src/main/java/net/woggioni/envelope/Common.java index e72ad8f..ac95ce0 100644 --- a/common/src/main/java/net/woggioni/executable/jar/Common.java +++ b/common/src/main/java/net/woggioni/envelope/Common.java @@ -1,4 +1,4 @@ -package net.woggioni.executable.jar; +package net.woggioni.envelope; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; diff --git a/common/src/main/java/net/woggioni/executable/jar/Constants.java b/common/src/main/java/net/woggioni/envelope/Constants.java similarity index 90% rename from common/src/main/java/net/woggioni/executable/jar/Constants.java rename to common/src/main/java/net/woggioni/envelope/Constants.java index e770c8d..a82ff1b 100644 --- a/common/src/main/java/net/woggioni/executable/jar/Constants.java +++ b/common/src/main/java/net/woggioni/envelope/Constants.java @@ -1,4 +1,4 @@ -package net.woggioni.executable.jar; +package net.woggioni.envelope; import java.util.Calendar; import java.util.GregorianCalendar; @@ -10,8 +10,8 @@ public class Constants { public static final String LIBRARIES_FOLDER = "LIB-INF"; public static final String METADATA_FOLDER = "META-INF"; public static final int BUFFER_SIZE = 0x10000; - public static final String DEFAULT_LAUNCHER = "net.woggioni.executable.jar.Launcher"; - public static final String AGENT_LAUNCHER = "net.woggioni.executable.jar.JavaAgentLauncher"; + public static final String DEFAULT_LAUNCHER = "net.woggioni.envelope.Launcher"; + public static final String AGENT_LAUNCHER = "net.woggioni.envelope.JavaAgentLauncher"; public static final String JAVA_AGENTS_FILE = METADATA_FOLDER + "/javaAgents.properties"; public static class ManifestAttributes { diff --git a/gradle.properties b/gradle.properties index ca927bb..1c1b2db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ woggioniMavenRepositoryUrl=https://mvn.woggioni.net/ -version.executableJar=0.1 +version.envelope=0.1 version.lombok=1.18.16 version.xclassloader=1.0 version.junitJupiter=5.7.2 diff --git a/launcher/build.gradle b/launcher/build.gradle index 7aa130f..d03c5b2 100644 --- a/launcher/build.gradle +++ b/launcher/build.gradle @@ -4,7 +4,7 @@ plugins { id "net.woggioni.gradle.multi-release-jar" } -ext.setProperty("jpms.module.name", "net.woggioni.executable.jar") +ext.setProperty("jpms.module.name", "net.woggioni.envelope") configurations { embedded @@ -30,7 +30,7 @@ tasks.withType(JavaCompile).configureEach { jar { manifest { attributes([ - (Attributes.Name.SPECIFICATION_TITLE) : "executable-jar-launcher", + (Attributes.Name.SPECIFICATION_TITLE) : "envelope-launcher", (Attributes.Name.SEALED) : true ].collectEntries { [it.key.toString(), it.value.toString()] @@ -57,6 +57,6 @@ tasks.register("tar", Tar) { tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) { doFirst { String path = project(":common").extensions.getByType(JavaPluginExtension).sourceSets.named("main").get().output.asPath - options.compilerArgs.addAll(["--patch-module", "net.woggioni.executable.jar=$path"]) + options.compilerArgs.addAll(["--patch-module", "net.woggioni.envelope=$path"]) } } diff --git a/launcher/src/main/java/net/woggioni/executable/jar/JavaAgentLauncher.java b/launcher/src/main/java/net/woggioni/envelope/JavaAgentLauncher.java similarity index 97% rename from launcher/src/main/java/net/woggioni/executable/jar/JavaAgentLauncher.java rename to launcher/src/main/java/net/woggioni/envelope/JavaAgentLauncher.java index 7460868..b4bd093 100644 --- a/launcher/src/main/java/net/woggioni/executable/jar/JavaAgentLauncher.java +++ b/launcher/src/main/java/net/woggioni/envelope/JavaAgentLauncher.java @@ -1,4 +1,4 @@ -package net.woggioni.executable.jar; +package net.woggioni.envelope; import java.io.InputStream; import java.lang.instrument.Instrumentation; diff --git a/launcher/src/main/java/net/woggioni/executable/jar/Launcher.java b/launcher/src/main/java/net/woggioni/envelope/Launcher.java similarity index 99% rename from launcher/src/main/java/net/woggioni/executable/jar/Launcher.java rename to launcher/src/main/java/net/woggioni/envelope/Launcher.java index b77616c..7f86609 100644 --- a/launcher/src/main/java/net/woggioni/executable/jar/Launcher.java +++ b/launcher/src/main/java/net/woggioni/envelope/Launcher.java @@ -1,4 +1,4 @@ -package net.woggioni.executable.jar; +package net.woggioni.envelope; import java.io.InputStream; import java.lang.reflect.Method; diff --git a/launcher/src/main/java/net/woggioni/executable/jar/MainClassLoader.java b/launcher/src/main/java/net/woggioni/envelope/MainClassLoader.java similarity index 90% rename from launcher/src/main/java/net/woggioni/executable/jar/MainClassLoader.java rename to launcher/src/main/java/net/woggioni/envelope/MainClassLoader.java index 215bc56..3de1271 100644 --- a/launcher/src/main/java/net/woggioni/executable/jar/MainClassLoader.java +++ b/launcher/src/main/java/net/woggioni/envelope/MainClassLoader.java @@ -1,4 +1,4 @@ -package net.woggioni.executable.jar; +package net.woggioni.envelope; import java.nio.file.Path; import lombok.SneakyThrows; diff --git a/launcher/src/main/java/net/woggioni/executable/jar/PathClassLoader.java b/launcher/src/main/java/net/woggioni/executable/jar/PathClassLoader.java deleted file mode 100644 index 61282fc..0000000 --- a/launcher/src/main/java/net/woggioni/executable/jar/PathClassLoader.java +++ /dev/null @@ -1,190 +0,0 @@ -package net.woggioni.executable.jar; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import lombok.SneakyThrows; - -/** - * A classloader that loads classes from a {@link Path} instance - */ -public final class PathClassLoader extends ClassLoader { - - private final Iterable paths; - - static { - registerAsParallelCapable(); - } - - public PathClassLoader(Path ...path) { - this(Arrays.asList(path), null); - } - - public PathClassLoader(Iterable paths) { - this(paths, null); - } - - public PathClassLoader(Iterable paths, ClassLoader parent) { - super(parent); - this.paths = paths; - } - - @Override - @SneakyThrows - protected Class findClass(String name) { - String resource = name.replace('.', '/').concat(".class"); - for(Path path : paths) { - Path classPath = path.resolve(resource); - if (Files.exists(classPath)) { - byte[] byteCode = Files.readAllBytes(classPath); - return defineClass(name, byteCode, 0, byteCode.length); - } - } - throw new ClassNotFoundException(name); - } - - @Override - @SneakyThrows - protected URL findResource(String name) { - for(Path path : paths) { - Path resolved = path.resolve(name); - if (Files.exists(resolved)) { - return toURL(resolved); - } - } - return null; - } - - @Override - protected Enumeration findResources(final String name) throws IOException { - final List resources = new ArrayList<>(1); - for(Path path : paths) { - Files.walkFileTree(path, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if (!name.isEmpty()) { - this.addIfMatches(resources, file); - } - return super.visitFile(file, attrs); - } - - @Override - public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - if (!name.isEmpty() || path.equals(dir)) { - this.addIfMatches(resources, dir); - } - return super.preVisitDirectory(dir, attrs); - } - - void addIfMatches(List resources, Path file) throws IOException { - if (path.relativize(file).toString().equals(name)) { - resources.add(toURL(file)); - } - } - }); - } - return Collections.enumeration(resources); - } - - private static URL toURL(Path path) throws IOException { - return new URL(null, path.toUri().toString(), PathURLStreamHandler.INSTANCE); - } - - private static final class PathURLConnection extends URLConnection { - - private final Path path; - - PathURLConnection(URL url, Path path) { - super(url); - this.path = path; - } - - @Override - public void connect() {} - - @Override - public long getContentLengthLong() { - try { - return Files.size(this.path); - } catch (IOException e) { - throw new RuntimeException("could not get size of: " + this.path, e); - } - } - - @Override - public InputStream getInputStream() throws IOException { - return Files.newInputStream(this.path); - } - - @Override - public OutputStream getOutputStream() throws IOException { - return Files.newOutputStream(this.path); - } - - @Override - @SneakyThrows - public String getContentType() { - return Files.probeContentType(this.path); - } - - @Override - @SneakyThrows - public long getLastModified() { - BasicFileAttributes attributes = Files.readAttributes(this.path, BasicFileAttributes.class); - return attributes.lastModifiedTime().toMillis(); - } - } - - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class PathURLStreamHandler extends URLStreamHandler { - - static final URLStreamHandler INSTANCE = new PathURLStreamHandler(); - - @Override - @SneakyThrows - protected URLConnection openConnection(URL url) { - List stack = new ArrayList<>(); - URL currentURL = url; - while(true) { - String file = currentURL.getFile(); - int exclamationMark = file.lastIndexOf('!'); - if(exclamationMark != -1) { - stack.add(file.substring(exclamationMark + 1)); - currentURL = new URL(file.substring(0, exclamationMark)); - } else { - stack.add(file); - break; - } - } - - Path path; - FileSystem fs = FileSystems.getDefault(); - while(true) { - String pathString = stack.remove(stack.size() - 1); - path = fs.getPath(pathString); - if(stack.isEmpty()) break; - else { - fs = FileSystems.newFileSystem(path, null); - } - } - return new PathURLConnection(url, path); - } - } -} \ No newline at end of file diff --git a/launcher/src/main/java9/module-info.java b/launcher/src/main/java9/module-info.java index e39a33f..34c8c1f 100644 --- a/launcher/src/main/java9/module-info.java +++ b/launcher/src/main/java9/module-info.java @@ -1,4 +1,4 @@ -module net.woggioni.executable.jar { +module net.woggioni.envelope { requires java.logging; requires static lombok; requires net.woggioni.xclassloader; diff --git a/launcher/src/main/java9/net/woggioni/executable/jar/MainClassLoader.java b/launcher/src/main/java9/net/woggioni/envelope/MainClassLoader.java similarity index 98% rename from launcher/src/main/java9/net/woggioni/executable/jar/MainClassLoader.java rename to launcher/src/main/java9/net/woggioni/envelope/MainClassLoader.java index 6b889b9..258250f 100644 --- a/launcher/src/main/java9/net/woggioni/executable/jar/MainClassLoader.java +++ b/launcher/src/main/java9/net/woggioni/envelope/MainClassLoader.java @@ -1,4 +1,4 @@ -package net.woggioni.executable.jar; +package net.woggioni.envelope; import java.lang.module.Configuration; import java.lang.module.ModuleFinder; diff --git a/launcher/src/test/java/net/woggioni/executable/jar/FooTest.java b/launcher/src/test/java/net/woggioni/executable/jar/FooTest.java deleted file mode 100644 index 9b1a4ed..0000000 --- a/launcher/src/test/java/net/woggioni/executable/jar/FooTest.java +++ /dev/null @@ -1,149 +0,0 @@ -package net.woggioni.executable.jar; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; -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.nio.file.attribute.BasicFileAttributes; -import java.util.HashMap; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import lombok.SneakyThrows; -import org.gradle.internal.impldep.org.junit.Ignore; -import org.junit.jupiter.api.Test; - -public class FooTest { - @Test - @SneakyThrows - void foo() { - Path.of(new URI("jar:file:///home/woggioni/code/wson/benchmark/build/libs/benchmark-executable-1.0.jar")); - } - - @Test - @SneakyThrows - void foo2() { - Path p = Path.of(new URI("file:///home/woggioni/code/wson/benchmark/build/libs/benchmark-executable-1.0.jar")); - FileSystem fs = FileSystems.newFileSystem(p, null); - StreamSupport.stream(fs.getRootDirectories().spliterator(), false).flatMap(new Function>() { - @Override - @SneakyThrows - public Stream apply(Path path) { - return Files.list(path); - } - }).forEach(r -> { - System.out.println(r); - }); - } - - @Test - @SneakyThrows - void test() { - Path fatJar = Path.of("/home/woggioni/code/wson/benchmark/build/libs/benchmark-executable-1.0.jar"); - List jars = StreamSupport.stream(FileSystems.newFileSystem(fatJar, null).getRootDirectories().spliterator(), false) - .flatMap(new Function>() { - @Override - @SneakyThrows - public Stream apply(Path root) { - Path libDir = root.resolve("/LIB-INF"); - if (Files.exists(libDir) && Files.isDirectory(libDir)) { - return Files.list(libDir); - } else { - return Stream.empty(); - } - } - }).flatMap(new Function>() { - @Override - @SneakyThrows - public Stream apply(Path path) { - return StreamSupport.stream(FileSystems.newFileSystem(path, null).getRootDirectories().spliterator(), false); - } - }).collect(Collectors.toList()); - PathClassLoader p = new PathClassLoader(jars.toArray(new Path[jars.size()])); - Class cl = p.loadClass("net.woggioni.wson.serialization.binary.JBONParser"); - System.out.println(cl); - URL resource = p.findResource("citylots.json.xz"); - resource.openStream(); - } - - @Test - @Ignore - @SneakyThrows - void test2() { - FileSystem fs = FileSystems.newFileSystem(new URI("jar:file:/home/woggioni/code/wson/benchmark/build/libs/benchmark-executable-1.0.jar"), new HashMap<>()); - String s = "jar:jar:file:///home/woggioni/code/wson/benchmark/build/libs/benchmark-executable-1.0.jar!/LIB-INF/wson-test-utils-1.0.jar!/citylots.json.xz"; - URI uri = new URI(s); - Files.list(Path.of(uri)).forEach(System.out::println); - } - - private static final class PathURLConnection extends URLConnection { - - private final Path path; - - PathURLConnection(URL url, Path path) { - super(url); - this.path = path; - } - - @Override - public void connect() {} - - @Override - public long getContentLengthLong() { - try { - return Files.size(this.path); - } catch (IOException e) { - throw new RuntimeException("could not get size of: " + this.path, e); - } - } - - @Override - public InputStream getInputStream() throws IOException { - return Files.newInputStream(this.path); - } - - @Override - public OutputStream getOutputStream() throws IOException { - return Files.newOutputStream(this.path); - } - - @Override - @SneakyThrows - public String getContentType() { - return Files.probeContentType(this.path); - } - - @Override - @SneakyThrows - public long getLastModified() { - BasicFileAttributes attributes = Files.readAttributes(this.path, BasicFileAttributes.class); - return attributes.lastModifiedTime().toMillis(); - } - } - - @NoArgsConstructor(access = AccessLevel.PRIVATE) - private static final class PathURLStreamHandler extends URLStreamHandler { - - static final URLStreamHandler INSTANCE = new PathURLStreamHandler(); - - @Override - @SneakyThrows - protected URLConnection openConnection(URL url) { - URI uri = url.toURI(); - Path path = Paths.get(uri); - return new PathURLConnection(url, path); - } - } -} diff --git a/settings.gradle b/settings.gradle index d489b0e..92e1ad3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,7 +11,7 @@ pluginManagement { } } -rootProject.name = 'executable-jar' +rootProject.name = 'envelope' include 'common' -include 'launcher' \ No newline at end of file +include 'launcher' diff --git a/src/main/java/net/woggioni/gradle/executable/jar/ExecutableJarTask.java b/src/main/java/net/woggioni/gradle/envelope/EnvelopeJarTask.java similarity index 92% rename from src/main/java/net/woggioni/gradle/executable/jar/ExecutableJarTask.java rename to src/main/java/net/woggioni/gradle/envelope/EnvelopeJarTask.java index 9f3d048..326fe54 100644 --- a/src/main/java/net/woggioni/gradle/executable/jar/ExecutableJarTask.java +++ b/src/main/java/net/woggioni/gradle/envelope/EnvelopeJarTask.java @@ -1,15 +1,10 @@ -package net.woggioni.gradle.executable.jar; +package net.woggioni.gradle.envelope; import java.io.File; import java.io.InputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; import java.security.MessageDigest; -import java.util.AbstractMap; -import java.util.ArrayList; import java.util.Base64; import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Properties; @@ -26,8 +21,8 @@ import javax.inject.Inject; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; -import net.woggioni.executable.jar.Common; -import net.woggioni.executable.jar.Constants; +import net.woggioni.envelope.Common; +import net.woggioni.envelope.Constants; import org.gradle.api.GradleException; import org.gradle.api.internal.file.CopyActionProcessingStreamAction; import org.gradle.api.internal.file.copy.CopyAction; @@ -46,16 +41,15 @@ import org.gradle.util.GradleVersion; import static java.util.zip.Deflater.BEST_COMPRESSION; import static java.util.zip.Deflater.NO_COMPRESSION; -import static net.woggioni.executable.jar.Constants.*; @SuppressWarnings({"unused" }) -public class ExecutableJarTask extends AbstractArchiveTask { +public class EnvelopeJarTask extends AbstractArchiveTask { private static final String MINIMUM_GRADLE_VERSION = "6.0"; static { if (GradleVersion.current().compareTo(GradleVersion.version(MINIMUM_GRADLE_VERSION)) < 0) { - throw new GradleException(ExecutableJarTask.class.getName() + + throw new GradleException(EnvelopeJarTask.class.getName() + " requires Gradle " + MINIMUM_GRADLE_VERSION + " or newer."); } } @@ -78,12 +72,12 @@ public class ExecutableJarTask extends AbstractArchiveTask { } public void includeLibraries(Object... files) { - into(LIBRARIES_FOLDER, (copySpec) -> copySpec.from(files)); + into(Constants.LIBRARIES_FOLDER, (copySpec) -> copySpec.from(files)); } @Inject - public ExecutableJarTask(ObjectFactory objects) { + public EnvelopeJarTask(ObjectFactory objects) { setGroup("build"); setDescription("Creates an executable jar file, embedding all of its runtime dependencies"); BasePluginExtension basePluginExtension = getProject().getExtensions().getByType(BasePluginExtension.class); @@ -91,7 +85,7 @@ public class ExecutableJarTask extends AbstractArchiveTask { getArchiveBaseName().convention(getProject().getName()); getArchiveExtension().convention("jar"); getArchiveVersion().convention(getProject().getVersion().toString()); - getArchiveAppendix().convention("executable"); + getArchiveAppendix().convention("envelope"); exclude("**/module-info.class"); mainClass = objects.property(String.class); @@ -122,14 +116,14 @@ public class ExecutableJarTask extends AbstractArchiveTask { @SneakyThrows public void processFile(FileCopyDetailsInternal fileCopyDetails) { String entryName = fileCopyDetails.getRelativePath().toString(); - if (!fileCopyDetails.isDirectory() && entryName.startsWith(LIBRARIES_FOLDER)) { + if (!fileCopyDetails.isDirectory() && entryName.startsWith(Constants.LIBRARIES_FOLDER)) { Supplier streamSupplier = () -> Common.read(fileCopyDetails.getFile(), false); Attributes attr = manifest.getEntries().computeIfAbsent(entryName, it -> new Attributes()); md.reset(); attr.putValue(Constants.ManifestAttributes.ENTRY_HASH, Base64.getEncoder().encodeToString(Common.computeDigest(streamSupplier, md, buffer))); } - if (METADATA_FOLDER.equals(entryName)) return; + if (Constants.METADATA_FOLDER.equals(entryName)) return; if (fileCopyDetails.isDirectory()) { ZipEntry zipEntry = zipEntryFactory.createDirectoryEntry(entryName, fileCopyDetails.getLastModified()); zoos.putNextEntry(zipEntry); @@ -164,7 +158,7 @@ public class ExecutableJarTask extends AbstractArchiveTask { @Nonnull ZipEntry createZipEntry(String entryName, long lastModifiedTime) { ZipEntry zipEntry = new ZipEntry(entryName); - zipEntry.setTime(isPreserveFileTimestamps ? lastModifiedTime : ZIP_ENTRIES_DEFAULT_TIMESTAMP); + zipEntry.setTime(isPreserveFileTimestamps ? lastModifiedTime : Constants.ZIP_ENTRIES_DEFAULT_TIMESTAMP); return zipEntry; } @@ -218,9 +212,9 @@ public class ExecutableJarTask extends AbstractArchiveTask { Manifest manifest = new Manifest(); Attributes mainAttributes = manifest.getMainAttributes(); mainAttributes.put(Attributes.Name.MANIFEST_VERSION, "1.0"); - mainAttributes.put(Attributes.Name.MAIN_CLASS, DEFAULT_LAUNCHER); + mainAttributes.put(Attributes.Name.MAIN_CLASS, Constants.DEFAULT_LAUNCHER); mainAttributes.put(Attributes.Name.MULTI_RELEASE, "true"); - mainAttributes.put(new Attributes.Name("Launcher-Agent-Class"), AGENT_LAUNCHER); + mainAttributes.put(new Attributes.Name("Launcher-Agent-Class"), Constants.AGENT_LAUNCHER); mainAttributes.put(new Attributes.Name("Can-Redefine-Classes"), "true"); mainAttributes.put(new Attributes.Name("Can-Retransform-Classes"), "true"); mainAttributes.putValue(Constants.ManifestAttributes.MAIN_CLASS, mainClass.get()); @@ -253,13 +247,13 @@ public class ExecutableJarTask extends AbstractArchiveTask { try (ZipOutputStream zipOutputStream = new ZipOutputStream(Common.write(destination, true)); ZipInputStream zipInputStream = new ZipInputStream(Common.read(temporaryJar, true))) { zipOutputStream.setLevel(BEST_COMPRESSION); - ZipEntry zipEntry = zipEntryFactory.createDirectoryEntry(METADATA_FOLDER); + ZipEntry zipEntry = zipEntryFactory.createDirectoryEntry(Constants.METADATA_FOLDER); zipOutputStream.putNextEntry(zipEntry); zipEntry = zipEntryFactory.createZipEntry(JarFile.MANIFEST_NAME); zipEntry.setMethod(ZipEntry.DEFLATED); zipOutputStream.putNextEntry(zipEntry); manifest.write(zipOutputStream); - zipEntry = zipEntryFactory.createZipEntry(JAVA_AGENTS_FILE); + zipEntry = zipEntryFactory.createZipEntry(Constants.JAVA_AGENTS_FILE); zipEntry.setMethod(ZipEntry.DEFLATED); zipOutputStream.putNextEntry(zipEntry); javaAgents.store(zipOutputStream, null); diff --git a/src/main/java/net/woggioni/gradle/executable/jar/ExecutableJarPlugin.java b/src/main/java/net/woggioni/gradle/envelope/EnvelopePlugin.java similarity index 75% rename from src/main/java/net/woggioni/gradle/executable/jar/ExecutableJarPlugin.java rename to src/main/java/net/woggioni/gradle/envelope/EnvelopePlugin.java index 8caeb06..e38f6f1 100644 --- a/src/main/java/net/woggioni/gradle/executable/jar/ExecutableJarPlugin.java +++ b/src/main/java/net/woggioni/gradle/envelope/EnvelopePlugin.java @@ -1,4 +1,4 @@ -package net.woggioni.gradle.executable.jar; +package net.woggioni.gradle.envelope; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -6,11 +6,11 @@ import org.gradle.api.plugins.BasePluginExtension; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.tasks.bundling.Jar; -public class ExecutableJarPlugin implements Plugin { +public class EnvelopePlugin implements Plugin { @Override public void apply(Project project) { BasePluginExtension basePluginExtension = project.getExtensions().getByType(BasePluginExtension.class); - project.getTasks().register("executable-jar", ExecutableJarTask.class, t -> { + project.getTasks().register("envelopeJar", EnvelopeJarTask.class, t -> { t.includeLibraries(project.getConfigurations().named(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)); t.includeLibraries(project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class)); }); diff --git a/src/main/java/net/woggioni/gradle/executable/jar/LauncherResource.java b/src/main/java/net/woggioni/gradle/envelope/LauncherResource.java similarity index 95% rename from src/main/java/net/woggioni/gradle/executable/jar/LauncherResource.java rename to src/main/java/net/woggioni/gradle/envelope/LauncherResource.java index a7f746e..e636722 100644 --- a/src/main/java/net/woggioni/gradle/executable/jar/LauncherResource.java +++ b/src/main/java/net/woggioni/gradle/envelope/LauncherResource.java @@ -1,4 +1,4 @@ -package net.woggioni.gradle.executable.jar; +package net.woggioni.gradle.envelope; import java.io.InputStream; import java.net.URI;