Compare commits

...

12 commits

Author SHA1 Message Date
Geert Bevin ba6c5693ae
Merge pull request #82 from ethauvin/main
Some checks are pending
bld-ci / build-linux (17) (push) Waiting to run
bld-ci / build-linux (20) (push) Waiting to run
bld-ci / build-linux (21) (push) Waiting to run
bld-ci / build-linux (22) (push) Waiting to run
bld-ci / build-linux (23) (push) Waiting to run
bld-ci / build-linux (24) (push) Waiting to run
bld-ci / build-linux (25) (push) Waiting to run
bld-ci / build-macos (17) (push) Waiting to run
bld-ci / build-macos (20) (push) Waiting to run
bld-ci / build-macos (21) (push) Waiting to run
bld-ci / build-macos (22) (push) Waiting to run
bld-ci / build-macos (23) (push) Waiting to run
bld-ci / build-macos (24) (push) Waiting to run
bld-ci / build-macos (25) (push) Waiting to run
bld-ci / build-windows (17) (push) Waiting to run
bld-ci / build-windows (20) (push) Waiting to run
bld-ci / build-windows (21) (push) Waiting to run
bld-ci / build-windows (22) (push) Waiting to run
bld-ci / build-windows (23) (push) Waiting to run
bld-ci / build-windows (24) (push) Waiting to run
bld-ci / build-windows (25) (push) Waiting to run
javadocs-pages / deploy (push) Waiting to run
Remove no long necessary download CI steps
2026-06-24 02:05:25 -04:00
Erik C. Thauvin 10b204ead4
Remove no long necessary download CI steps 2026-06-23 23:03:39 -07:00
Geert Bevin 877b4f758b
Merge pull request #81 from ethauvin/main
Enable CI dependencies caching
2026-06-24 01:48:10 -04:00
Erik C. Thauvin 462e8fc10a
Use Product user-agent standardized formatting 2026-06-23 22:41:44 -07:00
Erik C. Thauvin cd545df730
Remove download CI workflow step, no longer needed when using autoDownloadPurge and caching 2026-06-23 22:37:51 -07:00
Erik C. Thauvin 83f8997e33
Update GitHub actions to latest versions 2026-06-23 22:17:25 -07:00
Geert Bevin c4228fb067 Cleanup of --auto argument, now named --auto-download-purge.
Instead of randomized repositories in tests, round-robin repositories so that the tests are repeatable.
2026-06-23 22:37:57 -04:00
Erik C. Thauvin f1468a24c6
Randomize repositories in tests 2026-05-29 16:04:14 -07:00
Erik C. Thauvin acef8fd031
Add publish (snapshots only) GitHub workflow 2026-05-29 16:04:14 -07:00
Erik C. Thauvin 8f46145386
Add dependencies caching for GitHub workflows 2026-05-29 16:04:14 -07:00
Erik C. Thauvin c521d6578f
Add download --auto argument, emulating autoDownloadPurge = true in the CLI.
To be used when caching dependencies in CI workflows.
2026-05-28 23:25:19 -07:00
Erik C. Thauvin 8ca8c213d5
Add Google Maven Central mirrors 2026-05-28 23:25:19 -07:00
14 changed files with 785 additions and 563 deletions

View file

@ -94,24 +94,29 @@ jobs:
steps:
- name: Checkout source repository
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
clean: true
submodules: 'true'
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: 'corretto'
java-version: ${{ matrix.java-version }}
check-latest: true
- name: Download dependencies
run: ./bld clean download
- name: Cache bld dependencies
id: cache-bld
uses: actions/cache@v5
with:
path: lib
key: ${{ runner.os }}-bld-java${{ matrix.java-version}}-lib
restore-keys: ${{ runner.os }}-bld-java${{ matrix.java-version}}-lib
- name: Compile source
run: ./bld compile
run: ./bld clean compile
- name: Run tests
id: tests
@ -135,24 +140,29 @@ jobs:
steps:
- name: Checkout source repository
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
clean: true
submodules: 'true'
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: 'corretto'
java-version: ${{ matrix.java-version }}
check-latest: true
- name: Download dependencies
run: ./bld clean download
- name: Cache bld dependencies
id: cache-bld
uses: actions/cache@v5
with:
path: lib
key: ${{ runner.os }}-bld-java${{ matrix.java-version}}-lib
restore-keys: ${{ runner.os }}-bld-java${{ matrix.java-version}}-lib
- name: Compile source
run: ./bld compile
run: ./bld clean compile
- name: Run tests
id: tests
@ -174,24 +184,29 @@ jobs:
run: git config --global core.autocrlf input
- name: Checkout source repository
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
clean: true
submodules: 'true'
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: 'corretto'
java-version: ${{ matrix.java-version }}
check-latest: true
- name: Download dependencies
run: .\bld.bat clean download
- name: Cache bld dependencies
id: cache-bld
uses: actions/cache@v5
with:
path: lib
key: ${{ runner.os }}-bld-java${{ matrix.java-version}}-lib
restore-keys: ${{ runner.os }}-bld-java${{ matrix.java-version}}-lib
- name: Compile source
run: .\bld.bat compile
run: .\bld.bat clean compile
- name: Run tests
id: tests

View file

@ -22,6 +22,7 @@ concurrency:
jobs:
# Single deploy job since we're just deploying
deploy:
if: github.repository == 'rife2/bld'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
@ -30,14 +31,14 @@ jobs:
steps:
- name: Checkout source repository
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
clean: true
submodules: 'true'
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: 'corretto'
java-version: 17
@ -46,14 +47,14 @@ jobs:
run: ./bld clean download clean compile javadoc
- name: Setup Pages
uses: actions/configure-pages@v5
uses: actions/configure-pages@v6
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
uses: actions/upload-pages-artifact@v5
with:
# Upload generated Javadocs repository
path: 'build/javadoc/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v5

49
.github/workflows/publish.yml vendored Normal file
View file

@ -0,0 +1,49 @@
name: publish-snapshots
on:
workflow_dispatch:
jobs:
build-bld-project:
runs-on: ubuntu-latest
steps:
- name: Checkout source repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Check version is SNAPSHOT
shell: bash
run: |
VERSION=$(tr -d '[:space:]' < src/main/resources/BLD_VERSION)
echo "Current version: $VERSION"
if ! echo "$VERSION" | grep -q 'SNAPSHOT$'; then
echo "::error:: Version '$VERSION' is not a SNAPSHOT. Aborting publish."
exit 1
fi
- name: Set up JDK
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: 17
- name: Download dependencies
run: ./bld download
- name: Import key
run: echo "${{ secrets.SIGN_SECRET_KEY }}" | gpg --batch --import
- name: Publish
run: >-
./bld compile test publish
-Drife2Username=${{ secrets.RIFE2_USERNAME }}
-Drife2Password=${{ secrets.RIFE2_PASSWORD }}
-DsonatypeUser=${{ secrets.SONATYPE_USER }}
-DsonatypePassword=${{ secrets.SONATYPE_PASSWORD }}
-DsignKey=${{ secrets.SIGN_KEY }}
-DsignPassphrase=${{ secrets.SIGN_PASSPHRASE }}
- name: Delete GnuPG data
run: rm -rfv $HOME/.gnupg

27
.github/workflows/purge-cache.yml vendored Normal file
View file

@ -0,0 +1,27 @@
name: purge-cache
on:
workflow_dispatch:
inputs:
confirm:
description: 'Type "yes" to confirm purging all bld caches'
required: true
default: 'no'
jobs:
clear-cache:
if: github.event.inputs.confirm == 'yes'
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
permissions:
actions: write
steps:
- name: Purge bld caches for ${{ runner.os }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Purging all caches with key ${{ runner.os }}-bld-"
gh cache delete --all --key "${{ runner.os }}-bld-"
echo "Done for ${{ runner.os }}"

2
core

@ -1 +1 @@
Subproject commit fa567721c00d99626ed439db4f0340eadff0ec03
Subproject commit 5f977636531d1b978b762a615d720097baa37830

View file

@ -3,10 +3,10 @@ bld.downloadExtensionSources=true
bld.downloadLocation=
bld.extension-antlr=com.uwyn.rife2:bld-antlr4:1.4.3
bld.extension-archive=com.uwyn.rife2:bld-archive:0.6.3
bld.extension-reporter=com.uwyn.rife2:bld-junit-reporter:0.9.2
bld.extension-reporter=com.uwyn.rife2:bld-junit-reporter:1.2.0-SNAPSHOT
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.6.3
bld.javaOptions=
bld.javacOptions=
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES,RIFE2_SNAPSHOTS
bld.sourceDirectories=core/src/bld/java
bld.version=2.3.0
bld.version=2.3.1-SNAPSHOT

View file

@ -26,6 +26,13 @@ import static rife.tools.FileUtils.JAR_FILE_PATTERN;
* @since 1.5.20
*/
public class BaseProject extends BuildExecutor {
/**
* The CLI option to trigger automatic dependency download and purge.
*
* @since 2.3.1
*/
public static final String AUTO_DOWNLOAD_PURGE_OPTION = "--auto-download-purge";
/**
* The work directory of the project.
*
@ -2011,11 +2018,14 @@ public class BaseProject extends BuildExecutor {
@Override
public int execute(String[] arguments) {
var remainingArguments = new ArrayList<>(List.of(arguments));
var auto = remainingArguments.remove(AUTO_DOWNLOAD_PURGE_OPTION);
if (!offline() &&
autoDownloadPurge()) {
(autoDownloadPurge() || auto)) {
performAutoDownloadPurge();
}
return super.execute(arguments);
return super.execute(remainingArguments.toArray(new String[0]));
}
}

View file

@ -6,6 +6,8 @@ package rife.bld.dependencies;
import rife.bld.BldVersion;
import rife.tools.FileUtils;
import rife.tools.HttpUtils;
import rife.tools.Product;
import rife.tools.exceptions.FileUtilsErrorException;
import java.io.File;
@ -191,7 +193,7 @@ public abstract class ArtifactRetriever {
private static URLConnection openUrlConnection(RepositoryArtifact artifact) throws IOException {
var connection = new URL(artifact.location()).openConnection();
connection.setUseCaches(false);
connection.setRequestProperty("User-Agent", "bld " + BldVersion.getVersion());
connection.setRequestProperty(HttpUtils.HEADER_USER_AGENT, Product.BLD.toUserAgent(BldVersion.getVersion()));
return connection;
}

View file

@ -25,6 +25,9 @@ public record Repository(String location, String username, String password) {
public static Repository MAVEN_LOCAL = null;
public static final Repository APACHE = new Repository("https://repo.maven.apache.org/maven2/");
public static final Repository GOOGLE = new Repository("https://maven.google.com/");
public static final Repository GOOGLE_MAVEN_CENTRAL = new Repository("https://maven-central.storage-download.googleapis.com/maven2/");
public static final Repository GOOGLE_MAVEN_CENTRAL_EU = new Repository("https://maven-central-eu.storage-download.googleapis.com/maven2/");
public static final Repository GOOGLE_MAVEN_CENTRAL_ASIA = new Repository("https://maven-central-asia.storage-download.googleapis.com/maven2/");
public static final Repository MAVEN_CENTRAL = new Repository("https://repo1.maven.org/maven2/");
public static final Repository SECURECHAIN_REBUILT = new Repository("https://nexus-repo.corp.cloudlinux.com/repository/tuxcare_rebuilt");
public static final Repository SECURECHAIN_VETTED = new Repository("https://nexus-repo.corp.cloudlinux.com/repository/tuxcare_vetted");
@ -91,6 +94,9 @@ public record Repository(String location, String username, String password) {
return switch (locationOrName) {
case "APACHE" -> Repository.APACHE;
case "GOOGLE" -> Repository.GOOGLE;
case "GOOGLE_MAVEN_CENTRAL" -> Repository.GOOGLE_MAVEN_CENTRAL;
case "GOOGLE_MAVEN_CENTRAL_EU" -> Repository.GOOGLE_MAVEN_CENTRAL_EU;
case "GOOGLE_MAVEN_CENTRAL_ASIA" -> Repository.GOOGLE_MAVEN_CENTRAL_ASIA;
case "MAVEN_CENTRAL" -> Repository.MAVEN_CENTRAL;
case "MAVEN_LOCAL" -> Repository.MAVEN_LOCAL;
case "RIFE2_RELEASES" -> Repository.RIFE2_RELEASES;

View file

@ -5,7 +5,6 @@
package rife.bld.help;
import rife.bld.CommandHelp;
import rife.tools.StringUtils;
/**
* Provides help for the download command.
@ -19,9 +18,9 @@ public class DownloadHelp implements CommandHelp {
}
public String getDescription(String topic) {
return StringUtils.replace("""
Downloads all dependencies of the project
Usage : ${topic}""", "${topic}", topic);
return String.format("""
Downloads all dependencies of the project
Usage : %s""", topic);
}
}
}

View file

@ -830,7 +830,7 @@ public class Wrapper {
throws IOException {
var connection = url.openConnection();
connection.setUseCaches(false);
connection.setRequestProperty("User-Agent", "bld " + version);
connection.setRequestProperty(HttpUtils.HEADER_USER_AGENT, Product.BLD.toUserAgent(version));
try (var in = connection.getInputStream()) {
return new String(in.readAllBytes(), StandardCharsets.UTF_8);
}

View file

@ -0,0 +1,52 @@
/*
* Copyright 2026 Erik C. Thauvin (https://erik.thauvin.net/)
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.dependencies;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import static rife.bld.dependencies.Repository.*;
public final class RepositoryTestHelper {
public static final List<Repository> MAVEN_CENTRAL_REPOSITORIES = List.of(
MAVEN_CENTRAL,
APACHE,
GOOGLE_MAVEN_CENTRAL,
GOOGLE_MAVEN_CENTRAL_EU,
GOOGLE_MAVEN_CENTRAL_ASIA
);
private static final AtomicInteger COUNTER = new AtomicInteger(0);
private RepositoryTestHelper() {
}
public static Repository getNextRepository() {
var index = COUNTER.getAndIncrement() % MAVEN_CENTRAL_REPOSITORIES.size();
return MAVEN_CENTRAL_REPOSITORIES.get(index);
}
public static List<Repository> getNextRepositories(int count) {
if (count < 0) {
throw new IllegalArgumentException("count cannot be negative");
}
if (count > MAVEN_CENTRAL_REPOSITORIES.size()) {
throw new IllegalArgumentException("count cannot exceed repository list size: "
+ MAVEN_CENTRAL_REPOSITORIES.size());
}
var start = COUNTER.getAndAdd(count) % MAVEN_CENTRAL_REPOSITORIES.size();
var result = new ArrayList<Repository>(count);
for (var i = 0; i < count; i++) {
result.add(MAVEN_CENTRAL_REPOSITORIES.get((start + i) % MAVEN_CENTRAL_REPOSITORIES.size()));
}
return List.copyOf(result);
}
public static List<Repository> getNextRepositories() {
return getNextRepositories(2);
}
}

File diff suppressed because it is too large Load diff

View file

@ -5,13 +5,13 @@
package rife.bld.dependencies;
import org.junit.jupiter.api.Test;
import rife.ioc.HierarchicalProperties;
import rife.tools.StringUtils;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
import static rife.bld.dependencies.Repository.*;
import static rife.bld.dependencies.RepositoryTestHelper.getNextRepository;
import static rife.bld.dependencies.Scope.compile;
import static rife.bld.dependencies.Scope.runtime;
@ -92,7 +92,7 @@ public class TestDependencySet {
org.eclipse.jetty:jetty-io:11.0.14
org.slf4j:slf4j-simple:2.0.6
org.slf4j:slf4j-api:2.0.6
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(getNextRepository()), compile));
}
@Test
@ -118,7 +118,7 @@ public class TestDependencySet {
org.springframework:spring-core:6.0.6
org.springframework:spring-jcl:6.0.6
org.yaml:snakeyaml:1.33
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(getNextRepository()), compile));
}
@Test
@ -158,7 +158,7 @@ public class TestDependencySet {
org.codehaus.plexus:plexus-component-annotations:2.1.0
org.apache.commons:commons-lang3:3.8.1
org.slf4j:slf4j-api:1.7.36
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(getNextRepository()), compile));
}
@Test
@ -214,7 +214,7 @@ public class TestDependencySet {
org.scala-lang.modules:scala-java8-compat_2.13:1.0.2
com.typesafe:ssl-config-core_2.13:0.4.3
org.scala-lang.modules:scala-parser-combinators_2.13:1.1.2
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(getNextRepository()), compile));
}
@Test
@ -310,7 +310,7 @@ public class TestDependencySet {
net.java.dev.jna:jna:5.11.0
net.java.dev.jna:jna-platform:5.11.0
com.auth0:java-jwt:3.19.2
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(getNextRepository()), compile));
}
@Test
@ -353,7 +353,7 @@ public class TestDependencySet {
com.google.zxing:javase:3.5.1
com.google.zxing:core:3.5.1
com.beust:jcommander:1.82
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
"""), dependencies.generateTransitiveDependencyTree(VersionResolution.dummy(), ArtifactRetriever.instance(), List.of(getNextRepository()), compile));
}
@Test