Skip to content

What Is Bld

Geert Bevin edited this page Aug 30, 2024 · 9 revisions

bld is designed with the following principles in mind:

  • tasks don't happen without you telling them to happen
  • no auto-magical behavior, task behavior is explicit and API-defined
  • managing libs yourself is fine, having that automated also, or mix and match
  • build logic is written in Java, with all the advantages of Java
  • standard collection of Java-centric tasks for common operations
  • bld is distributed in a single jar, if you have the jar, you have the build system

Designed for modern Java

bld relies on Java 17 and leverages many of the features that this version of Java provides. Thanks to the modern language constructs, your Java build logic ends up looking very concise, is easily readable and understood by any IDE. You automatically get support for auto-completion and javadoc documentation, and you can split your build logic into multiple files and classes when you outgrow a single file.

Here is a complete bld file for a RIFE2 web application, nothing else is needed to be able to run it, test it and deploy it:

public class MyappBuild extends WebProject {
    public MyappBuild() {
        pkg = "com.example";
        name = "Myapp";
        mainClass = "com.example.MyappSite";
        uberJarMainClass = "com.example.MyappSiteUber";
        version = version(0,1,0);

        downloadSources = true;
        repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
        scope(compile)
            .include(dependency("com.uwyn.rife2", "rife2", version(1,8,0)));
        scope(test)
            .include(dependency("org.jsoup", "jsoup", version(1,18,1)))
            .include(dependency("org.junit.jupiter", "junit-jupiter", version(5,11,0)))
            .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,11,0)));
        scope(standalone)
            .include(dependency("org.eclipse.jetty.ee10", "jetty-ee10", version(12,0,12)))
            .include(dependency("org.eclipse.jetty.ee10", "jetty-ee10-servlet", version(12,0,12)))
            .include(dependency("org.slf4j", "slf4j-simple", version(2,0,13)));

        precompileOperation()
            .templateTypes(HTML);
    }

    public static void main(String[] args) {
        new MyappBuild().start(args);
    }
}

NOTE: bld supports different ways to describe dependencies, dependency("com.uwyn.rife2", "rife2", version(1,8,0)) can for instance also be written as dependency("com.uwyn.rife2:rife2:1.8.0"). Which format you use, is a matter of personal taste.

Where does bld fit?

From a very high level, build tools can be organized in a matrix:

  • either your tool is declarative or in code
  • either your tool first describes a plan or immediately executes a plan
Declarative Code Describes Immediate
Maven X X
Gradle X X
bld X X

Writing your build logic in the same language as your application (Java), significantly reduces the cognitive load, and taking actions immediately without having to mentally construct a described plan, makes it easier to reason about your build.

bld lets your build logic get out of the way so that you can focus on writing applications.

Let's take a look at how to install bld.


Next learn more about Quickstart Tutorial

Clone this wiki locally