What is it ?

Jerkar is a Java build tool ala Gradle, Ant/Ivy or Maven. It differs from the others in that it requires pure Java code instead of XML files or dynamic language scripts to describe builds.

Into the box

Also as an automation tool Jerkar provides :

Motivation

As a Java developer you may have already been frustrated of not being able to write your build scripts with your favorite language and, moreover, with the same language as the project to build.
Indeed most of mainstream and JVM languages have first class build tool where definitions are expressed using the language itself : Gradle for Groovy, Nodejs based tools for Javascript, SBT for Scala, PyBuilder for Python, Rake for Ruby, Leiningen for Clojure, Kobalt for Kotlin ...

Jerkar purposes to fill the gap by providing a full-featured build tool allowing Java developers to build their projects by just writing regular Java classes as they are so familiar with.

Benefits

As said, with Jerkar, build definitions are plain old java classes. This bare metal approach brings concrete benefits :

See it !

You just need to add such a class in your project in order to make it buildable by Jerkar. To build a project, just execute jerkar in a shell at its root folder.


class BuildSampleClassic extends JkJavaBuild {
	
    @Override protected JkDependencies dependencies() {
        return JkDependencies.builder() 
            .on(GUAVA, "18.0")  
            .on(JERSEY_SERVER, "1.19")
            .on("com.orientechnologies:orientdb-client:2.0.8")
            .on(JUNIT, "4.11").scope(TEST)
            .on(MOCKITO_ALL, "1.9.5").scope(TEST).build();
    }
    
    public static void main(String[] args) {
        JkInit.instanceOf(BuildSampleClassic.class, args).doDefault();
    }	
}
No more needed to build and publish your artifact. Group and artifact name are inferred from the project folder name and version is defaulted to 'trunk-SNAPSHOT' unless injected at invocation time.
It's possible to launch build class directly within the IDE thanks to the main method.

class MavenStyleBuild extends JkJavaBuild {
	
    @Override public JkModuleId moduleId() {
        return JkModuleId.of("org.jerkar", "script-samples");
    }

    @Override protected JkVersion version() {
        return JkVersion.name("0.3-SNAPSHOT");
    }

    @Override protected JkDependencies dependencies() {
        return JkDependencies.builder()
            .on(GUAVA, "18.0") 
            .on(JERSEY_SERVER, "1.19")
            .on("com.orientechnologies:orientdb-client:2.0.8")
            .on(JUNIT, "4.11").scope(TEST)
            .on(MOCKITO_ALL, "1.9.5").scope(TEST).build();
    }

}
Same as previous but explicitly define group, artifact and current version.

class AntStyleBuild extends JkBuild {
	
    String name = "myProject";
    File src = file("src");
    File buildDir = file("build/output");
    File classDir = new File(buildDir, "classes");
    JkClasspath classpath = JkClasspath.of(baseDir().include("libs/*.jar"));
    File reportDir = new File(buildDir, "junitRreport");
	
    @Override public void doDefault() {
        clean();compile();test();
    }
	
    public void compile() {
        JkJavaCompiler.outputtingIn(classDir).withClasspath(classpath).andSourceDir(src).compile();
        JkFileTree.of(src).exclude("**/*.java").copyTo(classDir);
    }
		
    public void test() {
        JkUnit.of(classpath.and(classDir))
            .withClassesToTest(JkFileTree.of(classDir).include("**/*Test.class"))
            .withReportDir(reportDir).run();
    }

}
This build class does not extend JkJavaBuild. As such it explicitly defines what does the build.

If the project embeds all its dependency jar files locally, no build class/configuration is needed at all :-)

Plugin mechanism allows to add behavior without modifying build classes. jerkar sonar# jacoco# doPublish processes test coverage along SonarQube analysis prior publishing artifacts.

Multi-techno projects

Beside building Java projects, Jerkar can be used for any automation purpose, for example, Jerkar is used to generate this site.

For building multi-techno projects embedding other technologies than java, we suggest the following approach :

Library

Jerkar can also be embedded in your product as a simple jar library, to leverage directly the fluent API for manipulating files, launch external tools or other. It is available on Maven Central.

Icing on the cake : Jerkar has zero dependency.