Skip to content

Commit

Permalink
Merge pull request #121 from ia3andy/bundle-deps
Browse files Browse the repository at this point in the history
Bundle artifacts
  • Loading branch information
ia3andy authored Oct 1, 2024
2 parents 30b39ea + bb4ed48 commit 4836e5b
Show file tree
Hide file tree
Showing 85 changed files with 681 additions and 357 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target/
.idea/
*.iml
/src/main/resources/**.tgz
**/src/main/resources/**.tgz
/nbactions.xml
83 changes: 83 additions & 0 deletions bundle-original/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.mvnpm</groupId>
<artifactId>esbuild-java-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>esbuild-java-bundle-original</artifactId>
<name>Esbuild wrapper for Java bundled with original binaries</name>
<properties>
<esbuild.version>0.23.0</esbuild.version>
</properties>
<dependencies>
<dependency>
<groupId>io.mvnpm</groupId>
<artifactId>esbuild-java</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources-filtered</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>download</id>
<phase>generate-resources</phase>
<configuration>
<target>
<get dest="src/main/resources" skipexisting="true">
<url url="https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-${esbuild.version}.tgz"/>
<url url="https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-${esbuild.version}.tgz"/>
<url url="https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-${esbuild.version}.tgz"/>
<url url="https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-${esbuild.version}.tgz"/>
<url url="https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-${esbuild.version}.tgz"/>
<url url="https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-${esbuild.version}.tgz"/>
<url url="https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-${esbuild.version}.tgz"/>
</get>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
esbuild.version=${esbuild.version}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.mvnpm.esbuild.resolve;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.nio.file.Path;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import io.mvnpm.esbuild.Bundler;

public class BundleResolverTest extends BundleTester {

public static final Resolver THROWING_RESOLVER = version -> {
throw new RuntimeException("Should not call this");
};

@BeforeAll
public static void cleanUp() throws IOException {
cleanUpDefault();
}

@Test
public void resolve() throws IOException {
// when
final Path resolve = new BundledResolver(THROWING_RESOLVER).resolve(Bundler.ESBUILD_EMBEDDED_VERSION);

assertFalse(Bundler.ESBUILD_EMBEDDED_VERSION.contains("mvnpm"));

// then
assertTrue(resolve.toFile().exists());
}
}
86 changes: 86 additions & 0 deletions bundle-scss/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.mvnpm</groupId>
<artifactId>esbuild-java-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>esbuild-java-bundle-scss</artifactId>
<name>Esbuild wrapper for Java bundled with mvnpm scss binaries</name>
<packaging>jar</packaging>
<properties>
<esbuild.scss.version>v0.0.8</esbuild.scss.version>
<esbuild.version>0.23.0-mvnpm-0.0.8</esbuild.version>
</properties>
<dependencies>
<dependency>
<groupId>io.mvnpm</groupId>
<artifactId>esbuild-java</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources-filtered</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>download</id>
<phase>generate-resources</phase>
<configuration>
<target>
<get dest="src/main/resources" skipexisting="true">
<url url="https://github.com/mvnpm/esbuild/releases/download/${esbuild.scss.version}/esbuild-darwin-arm64-${esbuild.version}.tgz"/>
<url url="https://github.com/mvnpm/esbuild/releases/download/${esbuild.scss.version}/esbuild-darwin-x64-${esbuild.version}.tgz"/>
<url url="https://github.com/mvnpm/esbuild/releases/download/${esbuild.scss.version}/esbuild-win32-x64-${esbuild.version}.tgz"/>
<url url="https://github.com/mvnpm/esbuild/releases/download/${esbuild.scss.version}/esbuild-win32-ia32-${esbuild.version}.tgz"/>
<url url="https://github.com/mvnpm/esbuild/releases/download/${esbuild.scss.version}/esbuild-linux-arm64-${esbuild.version}.tgz"/>
<url url="https://github.com/mvnpm/esbuild/releases/download/${esbuild.scss.version}/esbuild-linux-x64-${esbuild.version}.tgz"/>
<url url="https://github.com/mvnpm/esbuild/releases/download/${esbuild.scss.version}/esbuild-linux-ia32-${esbuild.version}.tgz"/>
</get>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
esbuild.scss.version=${esbuild.scss.version}
esbuild.version=${esbuild.version}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void cleanUp() throws IOException {
public void resolve() throws IOException {
// when
final Path resolve = new BundledResolver(THROWING_RESOLVER).resolve(Bundler.ESBUILD_EMBEDDED_VERSION);

assertTrue(Bundler.ESBUILD_EMBEDDED_VERSION.contains("mvnpm"));
// then
assertTrue(resolve.toFile().exists());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.mvnpm.esbuild.resolve;

import java.io.IOException;

import io.mvnpm.esbuild.Bundler;
import io.mvnpm.esbuild.util.PathUtils;

public abstract class BundleTester {

public static void cleanUp(String version) throws IOException {
PathUtils.deleteRecursive(Resolvers.getLocation(version));
}

public static void cleanUpDefault() throws IOException {
cleanUp(Bundler.ESBUILD_EMBEDDED_VERSION);
}
}
90 changes: 90 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.mvnpm</groupId>
<artifactId>esbuild-java-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>esbuild-java</artifactId>
<name>Esbuild wrapper for Java</name>

<description>Small wrapper around esbuild to be able to use it in Java</description>
<properties>
<esbuild.scss.version>v0.0.8</esbuild.scss.version>
<esbuild.version>0.23.0-mvnpm-0.0.8</esbuild.version>
</properties>

<dependencies>
<dependency>
<groupId>io.mvnpm</groupId>
<artifactId>importmap</artifactId>
<version>1.0.10</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>


<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources-filtered</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>java.util.logging.config.file</name>
<value>src/test/resources/logging.properties</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
</plugin>

</plugins>
</build>

</project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package io.mvnpm.esbuild.resolve;

import static io.mvnpm.esbuild.Bundler.ESBUILD_EMBEDDED_VERSION;
import static io.mvnpm.esbuild.resolve.Resolvers.*;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.logging.Logger;

public class BundledResolver implements Resolver {

private static final Logger logger = Logger.getLogger(DownloadResolver.class.getName());
private final Resolver fallbackResolver;

public BundledResolver(Resolver fallbackResolver) {
Expand All @@ -18,19 +18,22 @@ public BundledResolver(Resolver fallbackResolver) {

@Override
public Path resolve(String version) throws IOException {
final Path path = getLocation(ESBUILD_EMBEDDED_VERSION);
final String bundledExecutableRelativePath = resolveBundledExecutablePath();
final Path executablePath = path.resolve(bundledExecutableRelativePath);
if (Files.isExecutable(executablePath)) {
final Path path = getLocation(version);
final Path executablePath = resolveExecutablePath(path);
if (Files.isExecutable(path)) {
return executablePath;
}

final InputStream resource = getClass().getResourceAsStream("/esbuild-%s-%s.tgz".formatted(CLASSIFIER, version));
final String tgz = getTgzPath(version);
final InputStream resource = getClass().getResourceAsStream(tgz);

if (resource != null) {
return extract(resource, ESBUILD_EMBEDDED_VERSION).resolve(bundledExecutableRelativePath);
final Path bundleDir = extract(resource, version);
return requireExecutablePath(bundleDir);
}

return fallbackResolver.resolve(version);

}

}
Loading

0 comments on commit 4836e5b

Please sign in to comment.