Skip to content

Base KBean

Manages the build and execution of code located in 'jeka-src' directory.

The code stands for neither an application nor a library. For applications, code should contain a class including a main method to:

  • Run application
  • Create bootable jar
  • Create bootable fat jar, and create Docker images.

This KBean exposes the following fields:

Field Description
jvmOptions [String] Space separated list of options to pass to the JVM that will run the program.
programArgs [String] Space separated list of program arguments to pass to the command line running the program.
moduleId [String] Group and name for publication, formatted as 'groupId:nameId'.
jarType [enum:JkProjectPackaging$JarType] Type of jar to produce for the main artifact.
gitVersioning.enable [boolean] If true, a version computed from the current Git branch/tag will be injected into the Maven KBean to determine the published version.
gitVersioning.tagPrefix [String] Some prefer to prefix version tags like 'v1.3.1' instead of simply using '1.3.1'. In such cases, this value can be set to 'v' or any other chosen prefix.
scaffold.kind [enum:JkBaseScaffold$Kind] Kind of Jeka base to generate.
scaffold.jekaVersion [String] Set a specific jeka.version to include in jeka.properties. NO: no jeka.version specified, [EMPTY]: last version found in Maven Central.
scaffold.jekaLocation [String] Set a specific jeka.distrib.location to include in jeka.properties.
scaffold.jekaDistribRepo [String] Set a specific jeka.distrib.repo to include in jeka.properties.
scaffold.extraJekaProps [String] Coma separated string representing properties to add to jeka.properties.
scaffold.rawJekaPropsContentPath [Path] Set the path of a file containing the exact content of the jeka.properties file to generate.
If this field is set, all others related to jeka.properties generation are ignored.

This KBean exposes the following methods:

Method Description
depTree Displays exported dependency tree on console.
info Displays info about this base KBean.
pack Creates runnable fat jar and optional artifacts.
runJar Runs fat jar.
runMain Launches application.
scaffold Creates a skeleton in the current working directory.
test Launches test suite.

BaseKBean is similar to ProjectKBean, but it facilitates building JVM-based code hosted entirely in the jeka-src folder with a simpler classpath organization.

  • Single Classpath: By default, there is a single classpath. However, if a _dev package exists in the code structure, its contents are excluded when creating JARs, native executables, or Docker images. Typically, build and test classes are placed in _dev for application builds.
  • Dependency Declaration: Dependencies are declared by annotating any class with the @JkDep annotation. Dependencies within the _dev package are excluded from production artifacts.

Key Features

  • Resolves dependencies, compiles code, and runs tests.
  • Creates various types of JAR files out-of-the-box: regular, fat, shaded, source, and Javadoc JARs.
  • Infers project versions from Git metadata.
  • Executes packaged JARs.
  • Displays dependency trees and project setups.
  • Scaffolds skeletons for new projects.

Example

  • Base Application: The BaseKBean is set as the default KBean in jeka.properties. The accompanying README.md file details the available base: methods that can be invoked.