Skip to content

Build Tool Projects

Danny Thomas edited this page Oct 22, 2026 · 1 revision

Build tool projects

jig gradle and jig maven ask the underlying build tool for Java tool arguments. They use its project configuration and dependency resolution rather than introducing another build model. Arguments go to stdout unless --write-argfile is given.

Gradle

Use the root project directory. Jig uses its wrapper, or gradle on PATH.

Discovery

jig gradle --root-project-dir . --list-project-paths
jig gradle --root-project-dir . --project-path :app --list-source-sets

Project paths include composite builds, for example :build-logic:plugin. Included-build discovery and selection require Gradle 4.0 or later. Projects and source sets must exist; jig does not invent defaults.

--list-project-paths --format tsv emits tab-separated rows with these columns:

  1. Absolute directory
  2. Project path
  3. Source set
  4. Classpath (compile or runtime)

Projects without Java source sets have empty source-set and classpath fields. Discovery does not execute source producers.

Runtime arguments

jig gradle --root-project-dir . \
  --project-path :app --source-set main --classpath runtime \
  --resolve-options class-path,module-path,add-modules \
  --write-argfile runtime.args

java @runtime.args com.example.Main

--resolve-options requires --project-path, --source-set and --classpath. The compile and runtime selections use the source set's compileClasspath and runtimeClasspath respectively.

Compiler arguments

jig gradle --root-project-dir . \
  --project-path :app --source-set main \
  --resolve-compiler-options --write-argfile compile.args

javac @compile.args @sources.args

--resolve-compiler-options requires the project and source set and implies the compile classpath. It uses Gradle's compiler argument builder and excludes source filenames and launcher options. Supply source filenames in sources.args, including generated sources and module-info.java where applicable. Use a javac matching the build's configured toolchain.

Choose one operation per invocation: project discovery, source-set discovery, option resolution or compiler-option resolution.

Resolution can run generators and prepare binary outputs. Requesting the corresponding source paths leaves compilation to the caller while retaining producer dependencies. Empty source sets return only configured arguments.

Resolve options

Gradle accepts these option names for --resolve-options:

  • Paths: class-path, module-path, module-source-path, source-path, processor-path, processor-module-path, upgrade-module-path, patch-module, system
  • Modules: module, add-modules, describe-module, main-class, module-version
  • Compilation: release, source, target, encoding, multi-release, enable-preview
  • Runtime access: add-exports, add-opens, add-reads, enable-native-access, enable-final-field-mutation

Unconfigured options and known standard options unsupported by Gradle are omitted. For module output forms such as module=main, see Tool arguments.

Maven

Use the Maven project base directory. Jig uses its mvnw, or mvn on PATH.

Discovery

jig maven --project-base-dir . --list-projects

Discovery includes active modules without executing build goals. Select a project by groupId:artifactId or the shorter :artifactId form. The shorter form must identify a unique project.

--list-projects --format tsv emits tab-separated rows with these columns:

  1. Absolute directory
  2. Project selector
  3. Scope (compile, runtime or test)

Argument resolution

jig maven --project-base-dir . \
  --project :app --scope runtime \
  --resolve-options class-path,module-path,add-modules \
  --write-argfile runtime.args

java @runtime.args com.example.Main

--resolve-options requires --project and --scope. Choose either project discovery or argument resolution per invocation.

Resolving binary paths prepares Maven compile outputs. Requesting source paths leaves the selected sources to the caller; prerequisite projects may still compile.

Maven provides class-path, source-path, module-path, module-source-path, module, add-modules and describe-module. Known standard options unsupported by Maven are omitted. Module options use jig's module identities. See Tool arguments for module output forms such as module=main.

The separate jig maven install, deploy and deploy-central commands publish flat module artifacts, not Maven project builds. See Publishing modules.

Caching

Discovery and argument resolution share a persistent cache. Answers for different build-input contents are retained, allowing reuse after branch switches and across worktrees. Paths within the project are resolved against the current root; external paths remain unchanged. Project-specific values that jig cannot safely relocate keep an answer tied to its original directory.

A cache hit returns the previous answer without invoking Maven or Gradle, including any tasks that would prepare outputs. It does not verify that those outputs exist or are current.

Changes to reported build inputs invalidate an answer. Other changes, such as environment changes or updated dynamic dependencies, require --refresh:

jig gradle --root-project-dir . --list-project-paths --refresh
jig maven --project-base-dir . --list-projects --refresh

--refresh bypasses the cached answer and invokes the underlying tool. Use --verbose to see cache hits and build invocations.

Entries unused for seven days are pruned, with cleanup checked at most once daily. This is a retention policy, not a freshness timeout. Files explicitly written with --write-argfile belong to the caller and are not pruned.

Clone this wiki locally