diff --git a/bundle-original/pom.xml b/bundle-original/pom.xml
index cc696dca..377c8910 100644
--- a/bundle-original/pom.xml
+++ b/bundle-original/pom.xml
@@ -10,7 +10,7 @@
esbuild-java-bundle-original
Esbuild wrapper for Java bundled with original binaries
- 0.23.0
+ 0.25.9
@@ -64,11 +64,23 @@
-
+
-
+
+
+
+
+
diff --git a/bundle-scss/pom.xml b/bundle-scss/pom.xml
index 5317d025..f7e36882 100644
--- a/bundle-scss/pom.xml
+++ b/bundle-scss/pom.xml
@@ -11,8 +11,8 @@
Esbuild wrapper for Java bundled with mvnpm scss binaries
jar
- 0.0.9
- 0.23.0-mvnpm-${esbuild.mvnpm-build.version}
+ 0.0.10
+ 0.25.9-mvnpm-${esbuild.mvnpm-build.version}
@@ -63,14 +63,27 @@
-
-
-
-
+
+
+
+
-
+
+
+
+
+
+
diff --git a/core/pom.xml b/core/pom.xml
index 370bd946..a4642012 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -12,8 +12,8 @@
Small wrapper around esbuild to be able to use it in Java
- 0.0.9
- 0.23.0-mvnpm-${esbuild.mvnpm-build.version}
+ 0.0.11
+ 0.25.9-mvnpm-${esbuild.mvnpm-build.version}
diff --git a/core/src/main/java/io/mvnpm/esbuild/resolve/DownloadResolver.java b/core/src/main/java/io/mvnpm/esbuild/resolve/DownloadResolver.java
index cd35165d..c712185f 100644
--- a/core/src/main/java/io/mvnpm/esbuild/resolve/DownloadResolver.java
+++ b/core/src/main/java/io/mvnpm/esbuild/resolve/DownloadResolver.java
@@ -1,11 +1,14 @@
package io.mvnpm.esbuild.resolve;
-import static io.mvnpm.esbuild.resolve.Resolvers.*;
+import static io.mvnpm.esbuild.resolve.Resolvers.CLASSIFIER;
+import static io.mvnpm.esbuild.resolve.Resolvers.createDestination;
+import static io.mvnpm.esbuild.resolve.Resolvers.extract;
+import static io.mvnpm.esbuild.resolve.Resolvers.getTgzPath;
+import static io.mvnpm.esbuild.resolve.Resolvers.requireExecutablePath;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.UncheckedIOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
@@ -31,7 +34,7 @@ public Path resolve(String version) throws IOException {
try {
downloadFile(new URL(url), tarFile);
} catch (IOException e) {
- throw new UncheckedIOException("could not download esbuild with version " + version, e);
+ throw new EsbuildResolutionException("could not download esbuild with version " + version, e);
}
try {
final File file = destination.toFile();
@@ -40,7 +43,7 @@ public Path resolve(String version) throws IOException {
return requireExecutablePath(extracted);
} catch (IOException e) {
Files.deleteIfExists(tarFile);
- throw new UncheckedIOException("could not resolve esbuild with version " + version, e);
+ throw new EsbuildResolutionException("could not resolve esbuild with version " + version, e);
}
}
@@ -62,7 +65,7 @@ private String getDownloadUrl(String version) {
if (version.contains("mvnpm")) {
return MVNPM_URL_TEMPLATE.formatted(version.substring(version.lastIndexOf("-") + 1)) + tgz;
}
- return ESBUILD_URL_TEMPLATE.formatted(CLASSIFIER) + tgz;
+ return (ESBUILD_URL_TEMPLATE.formatted(CLASSIFIER) + tgz).replace("windows", "win32").replace("macos", "darwin");
}
}
diff --git a/core/src/main/java/io/mvnpm/esbuild/resolve/EsbuildResolutionException.java b/core/src/main/java/io/mvnpm/esbuild/resolve/EsbuildResolutionException.java
new file mode 100644
index 00000000..6ec1fc8b
--- /dev/null
+++ b/core/src/main/java/io/mvnpm/esbuild/resolve/EsbuildResolutionException.java
@@ -0,0 +1,11 @@
+package io.mvnpm.esbuild.resolve;
+
+public class EsbuildResolutionException extends RuntimeException {
+ public EsbuildResolutionException(String message) {
+ super(message);
+ }
+
+ public EsbuildResolutionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/core/src/main/java/io/mvnpm/esbuild/resolve/Resolvers.java b/core/src/main/java/io/mvnpm/esbuild/resolve/Resolvers.java
index b0da5daf..328858b8 100644
--- a/core/src/main/java/io/mvnpm/esbuild/resolve/Resolvers.java
+++ b/core/src/main/java/io/mvnpm/esbuild/resolve/Resolvers.java
@@ -13,6 +13,7 @@
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+import org.apache.commons.io.FileUtils;
final class Resolvers {
private static final Logger logger = Logger.getLogger(Resolvers.class.getName());
@@ -39,10 +40,29 @@ static Path resolveExecutablePath(Path bundleDir) {
return bundleDir.resolve(isWindows() ? path + ".exe" : path);
}
- static Path requireExecutablePath(Path bundleDir) throws IOException {
+ static Path resolveSassExecutablePath(Path bundleDir) {
+ String path = "dart-sass/sass";
+ return bundleDir.resolve(isWindows() ? path + ".bat" : path);
+ }
+
+ static Path getExecutablePath(Path bundleDir) throws IOException {
final Path path = resolveExecutablePath(bundleDir);
if (!Files.isExecutable(path)) {
- throw new IOException("Invalid esbuild executable: " + path);
+ return null;
+ }
+ if (bundleDir.toString().contains("-mvnpm-")) {
+ // check for scss
+ if (!Files.isExecutable(resolveSassExecutablePath(bundleDir))) {
+ return null;
+ }
+ }
+ return path;
+ }
+
+ static Path requireExecutablePath(Path bundleDir) throws IOException {
+ final Path path = getExecutablePath(bundleDir);
+ if (path == null) {
+ throw new IOException("Invalid esbuild executable in: " + bundleDir);
}
return path;
}
@@ -63,27 +83,29 @@ private static boolean isWindows() {
private static String determineClassifier() {
final String osName = System.getProperty("os.name").toLowerCase();
final String osArch = System.getProperty("os.arch").toLowerCase();
- String classifier;
-
+ String classifier = null;
if (osName.contains("mac")) {
if (osArch.equals("aarch64") || osArch.contains("arm")) {
- classifier = "darwin-arm64";
+ classifier = "macos-arm64";
} else {
- classifier = "darwin-x64";
+ classifier = "macos-x64";
}
} else if (osName.contains("win")) {
- classifier = osArch.contains("64") ? "win32-x64" : "win32-ia32";
+ if (osArch.equals("aarch64") || osArch.equals("arm64")) {
+ classifier = "windows-arm64";
+ } else if (osArch.contains("64")) {
+ classifier = "windows-x64";
+ }
} else {
if (osArch.equals("aarch64") || osArch.equals("arm64")) {
classifier = "linux-arm64";
- } else if (osArch.contains("arm")) {
- classifier = "linux-arm";
} else if (osArch.contains("64")) {
classifier = "linux-x64";
- } else {
- classifier = "linux-ia32";
}
}
+ if (classifier == null) {
+ throw new EsbuildResolutionException("Incompatible os: '%s' and arch: '%s' for esbuild".formatted(osName, osArch));
+ }
return classifier;
}
@@ -93,9 +115,10 @@ static Path extract(InputStream archive, String destination) throws IOException
}
static Path extract(InputStream archive, File destination) throws IOException {
- if (!destination.exists()) {
- destination.mkdirs();
+ if (destination.isDirectory() && destination.exists()) {
+ FileUtils.deleteDirectory(destination);
}
+ destination.mkdirs();
try (GzipCompressorInputStream gzipIn = new GzipCompressorInputStream(archive);
TarArchiveInputStream tarIn = new TarArchiveInputStream(gzipIn)) {