Skip to content

Commit

Permalink
Update blaze to public project v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlauer committed Jan 20, 2025
1 parent 5c423f3 commit 2374af9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 138 deletions.
3 changes: 1 addition & 2 deletions .blaze/blaze.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
blaze.dependencies = [
"com.fizzed:blaze-ssh"
"com.fizzed:buildx:1.2.0"
"com.fizzed:jne:4.3.0"
"com.fizzed:blaze-public-project:1.0.0"
]

java.source.version = 8
114 changes: 3 additions & 111 deletions .blaze/blaze.java
Original file line number Diff line number Diff line change
@@ -1,115 +1,7 @@
import com.fizzed.blaze.Config;
import com.fizzed.blaze.Contexts;
import com.fizzed.blaze.Task;
import com.fizzed.buildx.Buildx;
import com.fizzed.buildx.Target;
import com.fizzed.jne.HardwareArchitecture;
import com.fizzed.jne.JavaHome;
import com.fizzed.jne.JavaHomeFinder;
import org.slf4j.Logger;
import com.fizzed.blaze.project.PublicBlaze;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
public class blaze extends PublicBlaze {

import static com.fizzed.blaze.Contexts.withBaseDir;
import static com.fizzed.blaze.Systems.exec;
import static java.util.Arrays.asList;
import static java.util.Optional.ofNullable;

public class blaze {

private final Logger log = Contexts.logger();
private final Config config = Contexts.config();
private final Path projectDir = withBaseDir("../").toAbsolutePath();

@Task(order = 1)
public void test() throws Exception {
final Integer jdkVersion = this.config.value("jdk.version", Integer.class).orNull();
final HardwareArchitecture jdkArch = ofNullable(this.config.value("jdk.arch").orNull())
.map(HardwareArchitecture::resolve)
.orElse(null);

final long start = System.currentTimeMillis();
final JavaHome jdkHome = new JavaHomeFinder()
.jdk()
.version(jdkVersion)
.hardwareArchitecture(jdkArch)
.preferredDistributions()
.sorted(jdkVersion != null || jdkArch != null) // sort if any criteria provided
.find();

log.info("");
log.info("Detected {} (in {} ms)", jdkHome, (System.currentTimeMillis()-start));
log.info("");

exec("mvn", "clean", "test")
.workingDir(this.projectDir)
.env("JAVA_HOME", jdkHome.getDirectory().toString())
.verbose()
.run();
}

@Task(order = 2)
public void test_all_jdks() throws Exception {
// collect and find all the jdks we will test on
final List<JavaHome> jdks = new ArrayList<>();
for (int jdkVersion : asList(21, 17, 11, 8)) {
jdks.add(new JavaHomeFinder()
.jdk()
.version(jdkVersion)
.preferredDistributions()
.sorted()
.find());
}

log.info("Detected JDKs:");
jdks.forEach(jdk -> log.info(" {}", jdk));

for (JavaHome jdk : jdks) {
try {
log.info("");
log.info("Using JDK {}", jdk);
log.info("");

exec("mvn", "clean", "test")
.workingDir(this.projectDir)
.env("JAVA_HOME", jdk.getDirectory().toString())
.verbose()
.run();
} catch (Exception e) {
log.error("");
log.error("Failed on JDK " + jdk);
log.error("");
throw e;
}
}

log.info("Success on JDKs:");
jdks.forEach(jdk -> log.info(" {}", jdk));
}

private final List<Target> crossTestTargets = asList(
new Target("linux", "x64").setTags("test").setHost("bmh-build-x64-linux-latest"),
new Target("linux", "arm64").setTags("test").setHost("bmh-build-arm64-linux-latest"),
new Target("linux", "riscv64").setTags("test").setHost("bmh-build-riscv64-linux-latest"),
new Target("linux_musl", "x64").setTags("test").setHost("bmh-build-x64-linux-musl-latest"),
new Target("macos", "x64").setTags("test").setHost("bmh-build-x64-macos-latest"),
new Target("macos", "arm64").setTags("test").setHost("bmh-build-arm64-macos-latest"),
new Target("windows", "x64").setTags("test").setHost("bmh-build-x64-windows-latest"),
new Target("windows", "arm64").setTags("test").setHost("bmh-build-arm64-windows-latest"),
new Target("freebsd", "x64").setTags("test").setHost("bmh-build-x64-freebsd-latest"),
new Target("openbsd", "x64").setTags("test").setHost("bmh-build-x64-openbsd-latest")
);

@Task(order = 1)
public void cross_tests() throws Exception {
new Buildx(crossTestTargets)
.tags("test")
.execute((target, project) -> {
project.action("mvn", "clean", "test")
.run();
});
}
// all public blaze methods

}
45 changes: 20 additions & 25 deletions .blaze/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,40 @@
<sourceDirectory>${project.basedir}</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>org.apache.ivy</groupId>
<artifactId>ivy</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-ivy</artifactId>
<version>1.5.0</version>
<artifactId>blaze-core</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.ivy</groupId>
<artifactId>ivy</artifactId>
<version>2.5.2</version>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-core</artifactId>
<version>1.5.0</version>
<artifactId>blaze-ivy</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.7</version>
<version>2.0.13</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
</dependency>
<dependency>
<groupId>org.zeroturnaround</groupId>
Expand All @@ -63,17 +63,12 @@
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-ssh</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>buildx</artifactId>
<version>1.0.7</version>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>jne</artifactId>
<version>4.1.1</version>
<artifactId>blaze-public-project</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>

0 comments on commit 2374af9

Please sign in to comment.