Skip to content

Properties

Properties are pairs of String key-values that are used across JeKa. They typically carry URLs, local paths, tool versions, or credentials.

Properties can be defined at different levels, in order of precedence:

  • System properties: Properties can be defined using system properties as -DpropertyName=value. System properties can be injected from the JeKa command line.
  • OS environment variables: Properties can also be defined as OS environment variables.
  • Project: Defined in [Project Root]/jeka.properties. Typically used to store tool versions (e.g. jeka.kotlin.version=1.5.21).
  • Global: Defined in the [User Home]/.jeka/global.properties file. Typically used to define URLs, local paths, and credentials.

Properties inherit from project properties defined in project parent folders, up to the first parent folder without a jeka.properties file. In a hierarchical structure, add a jeka.properties file, even empty, in each intermediate folder.

Here, project2 will inherit properties defined in project1/jeka.properties:

project1
   + jeka.properties
   + project2   (sub-project)
      + jeka.properties

Info

Properties support interpolation via ${} tokens.

For example, if we define the following properties: foo=fooValue and bar=bar ${foo} then JkProperties.get("bar") will return 'bar fooValue'.

A property prefixed with _ applies only to the directory declaring it, and is not inherited by child projects. A property prefixed with + is appended to the value inherited from the parent instead of replacing it. See Multi-Modules for examples.

Standard properties

  • jeka.version: JeKa version used to run the project.
  • jeka.java.version: Version of the JDK used to run JeKa and compile code located in jeka-src. Projects target this version too, unless @project.javaVersion is specified.
  • jeka.java.distrib: Distribution of the JDK to download (temurin by default).
  • jeka.jdk.X: Location of the JDK version X (e.g., jeka.jdk.11=/my/java/jdk11). It is used instead of downloading the JDK, and to compile projects when the project JVM target version differs from the Jeka running version.
  • jeka.kotlin.version: Version of Kotlin used to compile both jeka-src and Kotlin project sources.
  • jeka.classpath: Additional dependencies that will be added to the JeKa classpath. We can specify many dependencies separated by <space>. It can be either Maven coordinates or file paths. If a file path is relative, it is resolved upon project base dir (could be distinct from working dir). Example: jeka.classpath=dev.jeka:springboot-plugin com.google.guava:guava:31.1-jre ../other-project/jeka-output/other-project.jar
  • jeka.kbean.default: The KBean to use when omitting the KBean prefix in command or field assignment. Example: declaring jeka.kbean.default=myBean makes jeka myBean: run and jeka run equivalent.
  • jeka.test.skip: If true, tests are skipped.
  • jeka.dep.engine: Engine used to resolve dependencies: ivy (default) or native (experimental). See Native Dependency Engine.
  • jeka.dep.offline: If true, dependencies are resolved from the cache only, without contacting remote repositories. Only the native engine honors it. Example: jeka project: pack -Djeka.dep.offline=true.
  • jeka.dep.updatePolicy: How often snapshots, and the version lists used for dynamic versions, are checked against remote repositories: always, daily (default), never or interval:N (N in minutes), as Maven's updatePolicy. Use -Djeka.dep.updatePolicy=always to force a check, as mvn -U. Only the native engine honors it.
  • jeka.child-bases: Comma-separated locations of the child modules. Generally declared as _jeka.child-bases. See Multi-Modules.
  • jeka.program.build, jeka.program.build.native, jeka.program.build.bundle: Commands used to build the application when running or installing it from source. See Source-Runnable Applications.
  • jeka.program.bundle.dist: Location of the distribution generated by jeka.program.build.bundle.
  • jeka.app.url.trusted: Space-separated Git URL prefixes to trust. Only read from global.properties (or from the JEKA_APP_URL_TRUSTED environment variable by the launcher scripts). See App KBean.

Command shorthands

  • jeka.cmd.xxx= defines an alias that can be substituted for its value in the command line using the :: symbol. Example: jeka.cmd.myBuild=project: pack sonarqube: run allows you to simply execute jeka ::myBuild. Single or double quotes group words into one argument, and are removed: jeka.cmd.hi=-p "Hello World" passes Hello World to the program.
  • jeka.cmd._append= will append the argument to every Jeka execution command. Example: jeka.cmd._append=-cp=dev.jeka:springboot-plugin will add springboot plugin to Jeka classpath for each execution. This property can be split when the argument line becomes too long. In fact, every property starting with jeka.cmd._append will be taken in account to assemble the extra command line arguments. For example, we can define jeka.cmd._append.0=, jeka.cmd._append.1=, and so on.

Note

Command shorthands are a really powerful mechanism for getting rid of build classes. Many projects can be built using properties only!

Repositories

The repositories used to download and publish artifacts can be defined using properties. The download repositories are set using the jeka.repos.download property, while the publish repository is defined using jeka.repos.publish.

Use the JkRepoProperties class to get the repositories defined by properties.

Note

By default, when no repository is configured, artifacts are downloaded from the Maven Central repo.

Using a single repo

jeka.repos.download=https://my.company/repo

Using multiple repos

jeka.repos.download=https://my.company/repo1, file://path/to/a/local/repo 

Using a single repo with credentials

jeka.repos.download=https://my.company/repo
jeka.repos.download.username=myUsername
jeka.repos.download.password=myPassword

Specifying HTTP headers to include in each request towards the repo

jeka.repos.download.headers.my-header-name=myHeaderValue
jeka.repos.download.headers.another-header-name=anotherHeaderValue

Same for the publish repo

jeka.repos.publish=https://my.company/myrepo
jeka.repos.publish.username=myUsername
jeka.repos.publish.password=myPassword
jeka.repos.publish.headers.Authorization=Bearer XHrU8hHKJHJ454==67g

For convenience, we can define multiple repositories and reference them using aliases:

jeka.repos.myRepo1=https://my.company/repo
jeka.repos.myRepo1.username=myUsername
jeka.repos.myRepo1.password=myPassword

jeka.repos.myRepo2=https://my.company/repo2
jeka.repos.myRepo2.username=myUsername2
jeka.repos.myRepo2.password=myPassword2

jeka.repos.download=myRepo1, myRepo2
jeka.repos.publish=myRepo2

Aliases are predefined for Maven Central and JeKa GitHub Repos:

jeka.repos.download=https://my.company/repo1, mavenCentral, jekaGithub
jeka.repos.jekaGithub.username=myGithubAccountName
jeka.repos.jekaGithub.password=myGithubPersonalAccessToken

KBean field value injection

If a property is named as @xxx.yyyyy then Jeka will inject its value in field yyyyy of KBean xxx. If no such KBean or field exists, JeKa displays a warning, or fails when running with the --strict option.

Examples:

@springboot.exposedPorts=8081
@project.test.skip=true

The same field can be set from the command line, either as a system property or scoped to the KBean:

jeka project: test -D@project.test.skip=true
jeka project: test test.skip=true

Note

In multi-module projects, these two forms differ: with -D@project.test.skip=true, the value is injected in every module. With test.skip=true, the value is injected only in the root module.

Multivalue fields

Multi-value fields allow using map-like structures in KBean objects.

Example:

class MyBean extends KBean {

      public final JkMultiValue<String> phones = JkMultiValue.of(String.class);
      public final JkMultiValue<Address> addresses = JkMultiValue.of(Address.class);

      public static class Address {

          @JkDoc("The street name and number")
          public String street;
          public int zip;
      }
 }
JkMultiValue is a map-like structure that allows access to values according to a given key.

Address mainAddress = myBean.addresses.get("main");
String gsmNum = myBean.phones.get("gsm");

These values can be set using jeka.properties files or command-line arguments as:

@myBean.phones.gsm=0978765432
@myBean.phones.home=0111334455

@myBean.addresses.main.street=Georges street 32
@myBean.addresses.main.zip=50600

Note

JkMultiValue objects support nesting, allowing you to create hierarchical data structures with multiple levels of key-value pairs.