Skip to content

Intellij KBean

Manages Intellij metadata files.

This KBean exposes the following fields:

Field Description
useVarPath [boolean] If true, dependency paths will be expressed relatively to $JEKA_REPO$ and $JEKA_HOME$ path variable instead of absolute paths.
failOnDepsResolutionError [boolean] If true, the iml generation fails when a dependency can not be resolved. If false, it will be ignored (only a warning will be notified).
imlFile [Path] The path where iml file must be generated. If null, Jeka will decide for a proper place. Mostly used by external tools.
suggestedJdkName [String] If mentioned, and jdkName is null, the generated iml will specify this jdkName.
jdkName [String] If mentioned, the generated iml will specify this jdkName.
downloadSources [boolean] If true, sources will be downloaded will resolving dependencies.

This KBean exposes the following methods:

Method Description
allIml Deprecated: Use 'syncAll' instead.
iml Deprecated: Use 'sync' instead.
initProject Re-init the project by deleting workspace.xml and regenerating .idea/modules.xml.
modulesXml Generates ./idea/modules.xml file by grabbing all .iml files presents in root or sub-directory of the project.
sync Generates IntelliJ [my-module].iml file.
syncAll Generates iml files on this folder and its descendant recursively.

IntellijKBean provides methods for generating metadata files for IntelliJ IDE. The content of an iml file is computed according the JkBuildable object found in found in the base directory.

This KBean proposes methods to customize generated iml file.

Configuration in a Build.java class
@JkPostInit
private void postInit(IntellijKBean intellijKBean) {
    intellijKBean
            .replaceLibByModule("dev.jeka.jeka-core.jar", "dev.jeka.core")
            .setModuleAttributes("dev.jeka.core", JkIml.Scope.COMPILE, null);