Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rife2/bld
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.2.0
Choose a base ref
...
head repository: rife2/bld
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 8 commits
  • 12 files changed
  • 1 contributor

Commits on Jan 22, 2025

  1. Copy the full SHA
    4b76279 View commit details
  2. Copy the full SHA
    f9f20e6 View commit details
  3. Copy the full SHA
    ca7fa0c View commit details
  4. More tests

    gbevin committed Jan 22, 2025
    Copy the full SHA
    9362a60 View commit details

Commits on Jan 23, 2025

  1. Copy the full SHA
    4b6cac6 View commit details

Commits on Feb 25, 2025

  1. Updated version to 2.2.1

    gbevin committed Feb 25, 2025
    Copy the full SHA
    b1b5c89 View commit details
  2. Upgraded GitHub actions

    gbevin committed Feb 25, 2025
    Copy the full SHA
    9158e72 View commit details
  3. Copy the full SHA
    d6d3c0f View commit details
6 changes: 3 additions & 3 deletions .github/workflows/bld.yml
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ jobs:
fetch-depth: 0

- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: ${{ matrix.java-version }}
@@ -127,7 +127,7 @@ jobs:
fetch-depth: 0

- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: ${{ matrix.java-version }}
@@ -156,7 +156,7 @@ jobs:
fetch-depth: 0

- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: ${{ matrix.java-version }}
8 changes: 4 additions & 4 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ jobs:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: 17
@@ -46,14 +46,14 @@ jobs:
run: ./bld clean download clean compile javadoc

- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
# Upload generated Javadocs repository
path: 'build/javadoc/'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
4 changes: 2 additions & 2 deletions .idea/libraries/bld.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
[![bld](https://img.shields.io/badge/2.2.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
[![bld](https://img.shields.io/badge/2.2.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
[![Release](https://img.shields.io/github/release/rife2/bld.svg)](https://github.com/rife2/bld/releases/latest)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.uwyn.rife2/bld/badge.svg?color=blue)](https://maven-badges.herokuapp.com/maven-central/com.uwyn.rife2/bld)
[![Nexus Snapshot](https://img.shields.io/nexus/s/com.uwyn.rife2/bld?server=https%3A%2F%2Fs01.oss.sonatype.org%2F)](https://s01.oss.sonatype.org/content/repositories/snapshots/com/uwyn/rife2/bld/)
Binary file modified lib/bld/bld-wrapper.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions lib/bld/bld-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
bld.downloadLocation=
bld.extension-antlr=com.uwyn.rife2:bld-antlr4:1.4.1
bld.extension-archive=com.uwyn.rife2:bld-archive:0.6.1
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.6.1
bld.extension-antlr=com.uwyn.rife2:bld-antlr4:1.4.2
bld.extension-archive=com.uwyn.rife2:bld-archive:0.6.2
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.6.2
bld.javaOptions=
bld.javacOptions=
bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES
bld.sourceDirectories=core/src/bld/java
bld.version=2.2.0
bld.version=2.2.1
33 changes: 33 additions & 0 deletions src/main/java/rife/bld/BaseProject.java
Original file line number Diff line number Diff line change
@@ -1376,6 +1376,17 @@ public String pkg() {
return pkg;
}

/**
* Returns whether this project's package was set.
*
* @return {@code true} if the package was set; or
* {@code false} otherwise
* @since 2.2.1
*/
public boolean hasPkg() {
return pkg != null;
}

/**
* Returns the project's name.
*
@@ -1388,6 +1399,17 @@ public String name() {
return name;
}

/**
* Returns whether this project's name was set.
*
* @return {@code true} if the name was set; or
* {@code false} otherwise
* @since 2.2.1
*/
public boolean hasName() {
return name != null;
}

/**
* Returns the project's version.
*
@@ -1400,6 +1422,17 @@ public VersionNumber version() {
return version;
}

/**
* Returns whether this project's version was set.
*
* @return {@code true} if the version was set; or
* {@code false} otherwise
* @since 2.2.1
*/
public boolean hasVersion() {
return version != null;
}

/**
* Returns the project's main class to execute.
*
44 changes: 44 additions & 0 deletions src/main/java/rife/bld/operations/AbstractProcessOperation.java
Original file line number Diff line number Diff line change
@@ -11,7 +11,9 @@

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
@@ -24,6 +26,7 @@ public abstract class AbstractProcessOperation<T extends AbstractProcessOperatio
public static final String DEFAULT_JAVA_TOOL = "java";

protected File workDirectory_ = new File(System.getProperty("user.dir"));
protected final Map<String, String> environment_ = new HashMap<>();
protected String javaTool_ = DEFAULT_JAVA_TOOL;
protected final JavaOptions javaOptions_ = new JavaOptions();
protected final List<String> classpath_ = new ArrayList<>();
@@ -87,6 +90,10 @@ protected Process executeStartProcess()
var builder = new ProcessBuilder(executeConstructProcessCommandList());
builder.directory(workDirectory());

if (!environment_.isEmpty()) {
builder.environment().putAll(environment_);
}

builder.redirectInput(ProcessBuilder.Redirect.INHERIT);

final var output_processor = outputProcessor();
@@ -163,6 +170,31 @@ public T workDirectory(File directory) {
return (T) this;
}

/**
* Provides an environment variable to use for the operation.
*
* @param name the name of the environment variable
* @param value the value of the environment variable
* @return this operation instance
* @since 2.2.1
*/
public T environment(String name, String value) {
environment_.put(name, value);
return (T) this;
}

/**
* Provides environment variable entries to use for the operation.
*
* @param environment environment entries for the operation
* @return this operation instance
* @since 2.2.1
*/
public T environment(Map<String, String> environment) {
environment_.putAll(environment);
return (T) this;
}

/**
* Provides the name of the tool to use for {@code java} execution.
* <p>
@@ -303,6 +335,18 @@ public File workDirectory() {
return workDirectory_;
}

/**
* Retrieves the environment to use for the operation.
* <p>
* This is a modifiable map that can be retrieved and changed.
*
* @return the operation's environment
* @since 2.2.1
*/
public Map<String, String> environment() {
return environment_;
}

/**
* retrieves the name of the tool to use for {@code java} execution.
*
2 changes: 1 addition & 1 deletion src/main/resources/BLD_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.2.2-SNAPSHOT
19 changes: 19 additions & 0 deletions src/test/java/rife/bld/TestProject.java
Original file line number Diff line number Diff line change
@@ -29,10 +29,13 @@ void testInstantiation() {
assertTrue(project.workDirectory().exists());
assertTrue(project.workDirectory().isDirectory());
assertNull(project.pkg);
assertFalse(project.hasPkg());
assertThrows(IllegalStateException.class, project::pkg);
assertNull(project.name);
assertFalse(project.hasName());
assertThrows(IllegalStateException.class, project::name);
assertNull(project.version);
assertFalse(project.hasVersion());
assertThrows(IllegalStateException.class, project::version);
assertNull(project.mainClass);
assertNull(project.module);
@@ -140,6 +143,22 @@ public void newcommand() {
}
}

@Test
void testCustomProject()
throws Exception {
var tmp = Files.createTempDirectory("test").toFile();
try {
var result = new StringBuilder();
var project = new CustomProject(tmp, result);

assertTrue(project.hasPkg());
assertTrue(project.hasName());
assertTrue(project.hasVersion());
} finally {
FileUtils.deleteDirectory(tmp);
}
}

@Test
void testCustomCommand()
throws Exception {
14 changes: 13 additions & 1 deletion src/test/java/rife/bld/operations/TestJUnitOperation.java
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import java.io.File;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import static org.junit.jupiter.api.Assertions.*;
@@ -25,6 +26,7 @@ void testInstantiation() {
assertTrue(operation.workDirectory().exists());
assertTrue(operation.workDirectory().isDirectory());
assertTrue(operation.workDirectory().canWrite());
assertTrue(operation.environment().isEmpty());
assertEquals("java", operation.javaTool());
assertTrue(operation.javaOptions().isEmpty());
assertTrue(operation.classpath().isEmpty());
@@ -37,6 +39,8 @@ void testInstantiation() {
@Test
void testPopulation()
throws Exception {
var environment = Map.of("env1", "val1", "env2", "val2", "env3", "val3");
var environment_full = Map.of("env1", "val1", "env2", "val2", "env3", "val3", "env4", "val4");
var work_directory = Files.createTempDirectory("test").toFile();
try {
var java_tool = "javatool";
@@ -53,6 +57,8 @@ void testPopulation()
var operation1 = new JUnitOperation();
operation1
.workDirectory(work_directory)
.environment(environment)
.environment("env4", "val4")
.javaTool(java_tool)
.javaOptions(List.of(test_java_option1, test_java_option2))
.testToolOptions(List.of(test_tool_option1, test_tool_option2))
@@ -62,6 +68,7 @@ void testPopulation()
.errorProcessor(test_error_consumer);

assertEquals(work_directory, operation1.workDirectory());
assertEquals(environment_full, operation1.environment());
assertEquals(java_tool, operation1.javaTool());
assertTrue(operation1.javaOptions().contains(test_java_option1));
assertTrue(operation1.javaOptions().contains(test_java_option2));
@@ -75,6 +82,8 @@ void testPopulation()

var operation2 = new JUnitOperation();
operation2.workDirectory(work_directory);
operation2.environment(environment);
operation2.environment("env4", "val4");
operation2.javaTool(java_tool);
operation2.javaOptions().add(test_java_option1);
operation2.javaOptions().add(test_java_option2);
@@ -87,6 +96,7 @@ void testPopulation()
operation2.errorProcessor(test_error_consumer);

assertEquals(work_directory, operation2.workDirectory());
assertEquals(environment_full, operation2.environment());
assertEquals(java_tool, operation2.javaTool());
assertTrue(operation2.javaOptions().contains(test_java_option1));
assertTrue(operation2.javaOptions().contains(test_java_option2));
@@ -124,7 +134,7 @@ void testExecute()
public class Source1 {
public final String name_;
public Source1() {
name_ = "source1";
name_ = System.getenv("execute_name") + System.getenv("execute_number");
}
public static void main(String[] arguments)
@@ -156,6 +166,8 @@ public static void main(String[] arguments)

var output = new StringBuilder();
var test_operation = new JUnitOperation()
.environment(Map.of("execute_name", "source"))
.environment("execute_number", "1")
.mainClass("Source2")
.classpath(List.of(build_main.getAbsolutePath(), build_test.getAbsolutePath()))
.outputProcessor(s -> {
Loading