Skip to content

Reuse Elements

Jeka provides powerful and easy means to reuse build elements across projects.

Elements can be reused as sources in a multi-project structure or exported as binaries in order to be used as third-party dependencies to create a plugin ecosystem.

From Sources

In a multi-project (aka multi-module project), it is possible to use classes defined in other projects. When using @JkInjectProject, classes defined in ../sub-project-1/jeka/def and in the classpath of sub-project-1.

import dev.jeka.core.tool.JkBean;

class MyJkBean extends JkBean {


In a KBean, it is possible to use a KBean coming from another project.

import dev.jeka.core.tool.JkBean;

class MyJkBean extends JkBean {

    private OtherJkBean importedBean;

From Binaries

To extend Jeka capabilities, it's possible to create a jar file in order to be used in any Jeka project. An extension (or plugin) can contain KBean or not and can have many purposes (integrate a specific technology, predefine set of dependencies, provide utiliy classes, ...).

To achieve it, we need to create a project to pack and export the library.

The project may declare dependencies on Jeka : the simplest is to add a dependency on the jeka jar that is actually building the project using JkLocator.getJekaJarPath().

import dev.jeka.core.api.project.JkProject;

class Build extends JkBean {

    ProjectJkBean projectBean = getBean(ProjectJkean.class).configure(this::configure);

    private void configure(JkProject project) {

        // Optional indication about Jeka version compatibility

                .configureCompileDeps(deps -> deps


Check Jeka Version Compatibility

JkJekaVersionCompatibilityChecker.setCompatibilityRange insert information about Jeka version compatibility within the Manifest. This information will be used by Jeka to alert if the library is marked as incompatible with the running Jeka version.

The method take 3 arguments :

  • The object standing for the Manifest file
  • The lowest version of Jeka which is compatible with the library
  • An url string pointing on a file mentioning the versions of Jeka that are no longer compatible with the version of the library

For the last, the information has to be stored outside the library itself as the author can not guess which future version of Jeka will break the compatibility.

An example of such a file is available here