Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/blaze build #189

Merged
merged 8 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .blaze/blaze.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
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.1"
]
212 changes: 22 additions & 190 deletions .blaze/blaze.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
import com.fizzed.blaze.Config;
import com.fizzed.blaze.Contexts;
import static com.fizzed.blaze.Contexts.fail;
import static com.fizzed.blaze.Contexts.withBaseDir;
import static com.fizzed.blaze.Systems.exec;
import static java.util.Arrays.asList;

import com.fizzed.blaze.Task;
import com.fizzed.blaze.util.Streamables;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.fizzed.blaze.project.PublicBlaze;
import com.fizzed.buildx.Buildx;
import com.fizzed.buildx.Target;
import com.fizzed.jne.JavaHome;
import com.fizzed.jne.JavaHomeFinder;
import org.slf4j.Logger;

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

import java.util.List;
import java.util.stream.Collectors;

public class blaze extends PublicBlaze {

@Override
protected int minimumSupportedJavaVersion() {
// we want to release with Java 17
return 17;
}

@Override
protected List<Target> crossTestTargets() {
// weird gradle test issue occurs only on riscv64
return super.crossTestTargets().stream()
.filter(v -> !v.getArch().contains("riscv64"))
.collect(Collectors.toList());
}

// public demos

@Task(order=1, value="Demo of parsing a template and logs its structure. Argument of -Drocker.file=<file>")
public void parser() {
String rockerFile = config.value("rocker.file").get();
Expand Down Expand Up @@ -74,170 +72,4 @@ public void netty() {
"-Dexec.mainClass=com.fizzed.rocker.bin.NettyMain").run();
}

@Task(order = 20)
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));
}

@Task(order = 98)
public void release() throws Exception {
// we MUST be running on Java 17+
final JavaHome javaHome = new JavaHomeFinder()
.jdk()
.version(17)
.preferredDistributions()
.find();

log.info("");
log.info("Using JDK {}", javaHome);
log.info("");

exec("mvn", "release:prepare", "release:perform")
.workingDir(this.projectDir)
.env("JAVA_HOME", javaHome.getDirectory().toString())
.verbose()
.run();
}

@Task(order=99, value="Use by maintainers only. Updates REAME.md with latest git tag.")
public void after_release() throws Exception {
int exitValue = (int)exec("git", "diff-files", "--quiet")
.exitValues(0,1)
.run();

if (exitValue == 1) {
fail("Uncommitted changes in git. Commit them first then re-run this task");
}

update_readme();

exec("git", "commit", "-am", "Updated README with latest version").run();
exec("git", "push", "origin").run();
}

private String latest_tag() {
// get latest tag and trim off "v"
String latestTag = exec("git", "describe", "--abbrev=0", "--tags")
.pipeOutput(Streamables.captureOutput())
.runCaptureOutput()
.toString()
.trim()
.substring(1);

return latestTag;
}

public void update_readme() throws Exception {
Path readmeFile = withBaseDir("../README.md");
Path newReadmeFile = withBaseDir("../README.md.new");

// find latest version via git tag
String latestVersion = latest_tag();

log.info("Latest version in git {}", latestVersion);

// find current version in readme
final Pattern versionPattern = Pattern.compile(".*<version>(\\d+\\.\\d+\\.\\d+)</version>.*");

String currentVersion
= Files.lines(readmeFile)
.map((l) -> {
Matcher matcher = versionPattern.matcher(l);
if (matcher.matches()) {
return matcher.group(1);
} else {
return null;
}
})
.filter((l) -> l != null)
.findFirst()
.get();

log.info("Current version in README {}", currentVersion);

if (currentVersion.equals(latestVersion)) {
log.info("Versions match (no need to update README)");
return;
}

final Pattern replacePattern = Pattern.compile(currentVersion);

try (BufferedWriter writer = Files.newBufferedWriter(newReadmeFile)) {
Files.lines(readmeFile)
.forEach((l) -> {
Matcher matcher = replacePattern.matcher(l);
String newLine = matcher.replaceAll(latestVersion);
try {
writer.append(newLine);
writer.append("\n");
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
});
writer.flush();
}

// replace readme with updated version
Files.delete(readmeFile);
Thread.sleep(2000L);
Files.move(newReadmeFile, readmeFile, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
}

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("extended-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 = 100)
public void cross_tests() throws Exception {
new Buildx(crossTestTargets)
.tags("test")
.execute((target, project) -> {
project.action("mvn", "clean", "test")
.run();
});
}

}
25 changes: 10 additions & 15 deletions .blaze/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
<sourceDirectory>${project.basedir}</sourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-ivy</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.ivy</groupId>
<artifactId>ivy</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-core</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand All @@ -42,8 +42,8 @@
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-ivy</artifactId>
<version>1.8.0</version>
<artifactId>blaze-core</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -63,17 +63,12 @@
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>blaze-ssh</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>buildx</artifactId>
<version>1.2.0</version>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>jne</artifactId>
<version>4.3.0</version>
<artifactId>blaze-public-project</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,6 @@ following for a complete list:

## License

Copyright (C) 2015+ Fizzed, Inc.
Copyright (C) 2025+ Fizzed, Inc.

This work is licensed under the Apache License, Version 2.0. See LICENSE for details.
Binary file modified blaze.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions buildx-results.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Buildx Results
--------------
Cross platform tests use the Buildx project: /~https://github.com/fizzed/buildx
Commit: 49cd2575e4d4f6456a8b9f4bdc10cac1b5991061
Date: 2025-01-10T20:36:56.774381Z[UTC]
Commit: f75455e02e8fc2f46e8718ee8c126e5c8599531f
Date: 2025-01-22T18:24:55.593635Z[UTC]

linux-x64 success
linux-arm64 success
Expand Down
38 changes: 6 additions & 32 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.fizzed</groupId>
<artifactId>maven-parent</artifactId>
<version>2.6.0</version>
<version>2.7.0</version>
</parent>

<scm>
Expand All @@ -19,7 +19,7 @@

<properties>
<main.java.package />
<slf4j.version>1.7.7</slf4j.version>
<slf4j.version>1.7.36</slf4j.version>
<antlr.version>4.5.3</antlr.version>
<java.version>1.8</java.version>
<license.skip>true</license.skip>
Expand All @@ -39,35 +39,9 @@
<module>rocker-bom</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<configuration>
<additionalparam>${javadoc.opts}</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>

<!-- compile -->

<dependency>
Expand All @@ -91,7 +65,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
<version>3.17.0</version>
</dependency>

<!-- an optional dependency that's used for html escaping but only
Expand Down Expand Up @@ -126,7 +100,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.14.0</version>
<version>2.16.1</version>
<scope>test</scope>
</dependency>

Expand All @@ -147,7 +121,7 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.7</version>
<version>2.12.7</version>
<scope>test</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion rocker-gradle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-tooling-api</artifactId>
<version>7.4.2</version>
<version>8.12</version>
</dependency>
</dependencies>
<executions>
Expand Down
Loading
Loading