JAR Assembly

Build JARs, sources and Javadoc JARs, and runnable application distributions.

Common operations

jar options go after --:

elide jar -- --create --file app.jar -C out .                              # create
elide jar -- --list --file app.jar                                         # list
elide jar -- --extract --file app.jar --dir extracted                      # extract
elide jar -- --create --file app.jar --main-class com.example.Main -C out . # executable JAR
elide jar -- -help

Compile and create a JAR

elide javac --jar target/app.jar -- src/Main.java src/Util.java
elide javac --jar target/app.jar --manifest src/MANIFEST.MF -- src/Main.java

Project artifacts

amends "elide:project.pkl"
import "elide:Jvm.pkl" as Jvm

artifacts {
  ["app"] = new Jvm.Jar {
    name = "app"
    options {
      entrypoint = "com.example.Main"
    }
  }
}

elide build writes .dev/artifacts/jar/<name>/. The JAR holds every non-test source set’s classes and resources.

Jvm.Jar

PropertyMeaningDefault
nameFile name; "app" and "app.jar" both give app.jar.the artifact key
sourcesSource sets to package; empty means every non-test set.none
resourcesExtra files: paths or new { from = …; into = … }.none
manifestExtra META-INF/MANIFEST.MF attributes.none
manifestFileManifest file to use instead of a generated one.—
excludesEntries to omit: a pattern with / * ? [ ] is a path glob; a dotted name is a package prefix.none
options.entrypointMain-Class.jvm.main
options.compressCompress entries.true
options.defaultManifestPropertiesAdd Implementation-* attributes.true
mainNot read when packaging; use options.entrypoint.—
dependsOnArtifacts to build first.none
artifacts {
  ["app"] = new Jvm.Jar {
    sources { "main" }
    excludes {
      "com.example.internal"   // a package and its subpackages
      "**/*.proto"             // a path glob
    }
    manifest {
      ["Implementation-Vendor"] = "Example"
    }
    resources {
      "LICENSE.txt"
      new { from = "config"; into = "META-INF/config" }
    }
  }
}

Sources and Javadoc JARs

artifacts {
  ["sources"] = new Jvm.SourceJar {
    classifier = "sources"
    excludes { "**/internal/**" }
  }
  ["javadoc"] = new Jvm.JavadocJar {
    windowTitle = "Example API"
    links { "https://docs.oracle.com/en/java/javase/25/docs/api/" }
    groups {
      ["Core"] { "com.example.core" }
    }
  }
}
Jvm.SourceJarMeaning
sourcesSource sets to package; empty means every non-test set.
classifierInserted before the extension (app-sources.jar).
includes, excludesPath globs over the sources.
Jvm.JavadocJarMeaning
sourcesSource sets to document; empty means every non-test set.
groupsPackage groups: title to package list.
linksExternal documentation URLs.
excludesPatterns to leave undocumented.
windowTitle, docTitleWindow and document titles.

Runnable application distributions

A Jvm.JvmApplication is a runnable tree, like Gradle’s application plugin: runtime JARs in lib/, start scripts in bin/, and optional archives.

artifacts {
  ["dist"] = new Jvm.JvmApplication {
    from { "app" }
    entrypoint = "com.example.Main"
    defaultJvmArgs { "-Xmx512m" }
    contents {
      new { from = "config"; into = "etc" }
    }
    options {
      archives { "zip"; "tar" }
    }
  }
}
PropertyMeaningDefault
fromJAR artifacts with the app’s code; empty means every declared JAR, or a JAR of the project’s classes.none
nameDirectory and start-script name.the artifact key
entrypointMain class.jvm.main
defaultJvmArgsJVM options in the scripts, after jvm.flags.none
executableDirDirectory for the scripts."bin"
contentsExtra files in the root, in the same form as source-set resources.none
options.unixStartScript, options.windowsStartScriptGenerate each script.true
options.archives"zip" and/or "tar" (gzip).none
dependsOnArtifacts to build first.none
OutputPath
Install tree.dev/artifacts/install/<name>/
Archives.dev/artifacts/distributions/
  • elide run launches the installed tree with the scripts’ JVM options.
  • Scripts also read JAVA_OPTS and <NAME>_OPTS (sample-app → SAMPLE_APP_OPTS).
  • The POSIX script follows symlinks to itself; on Windows, run the script directly or via PATH.
  • name, version (when archiving) and each into must be valid file names everywhere: no /, \, :*?"<>|, control characters, trailing dot or space, or Windows device names such as NUL. Otherwise the build fails before writing.

Workspace members use a sibling’s Jvm.Jar with project("core"); see Workspaces.