Warnings
Some project states are valid, so Kargo builds them, yet they are almost always mistakes: a project with no sources, a script that is never compiled, a task you can’t run by its name. Kargo prints a warning: for each one on stderr and carries on.
$ kargo buildwarning: package version `not.a.version.x` does not look like a version (expected something like `1.0.0`); it becomes part of the jar's file name and of its Maven coordinateswarning: task `build` is hidden by the built-in `kargo build` command; run the task with `kargo task build` or rename itwarning: no Kotlin or Java sources found in src/ or src-jvm/ for the jvm targetwarning: `src/script.kts` is ignored: Kargo does not compile or run Kotlin scripts (.kts); put the code in a .kt file, or run it with `kargo script <file>` Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17sWarnings never change the exit code, and -q hides them. In a workspace each one starts with package `name`: so you can tell which member it is about.
| Warning | Printed by |
|---|---|
| No sources | build, check, run, package |
| Ignored Kotlin scripts | build, check, run, package, test |
| Tasks hidden by built-in commands | every command that works on a package: build, check, run, test, package, doc, fmt, lint, fetch, tree |
| Odd package versions | the same commands |
.env file tracked by git |
run, test, task, env |
| Generator inputs that match nothing | build, check, run, test, package, generate |
No sources
Section titled “No sources”warning: no Kotlin or Java sources found in src/ or src-jvm/ for the jvm targetA target with nothing to compile still “builds”: there is nothing to fail, so kargo build prints Finished. The mistake shows up later, for example as could not determine the main class from kargo run. Kargo checks each target the command builds. It needs a .kt file in src/ or src-<target>/ (a .kt or .java file on the JVM).
- The check runs after the
pre-buildhooks, so sources a hook generates count. - A JVM project with files in
resources/and no sources is a valid resources-only jar and gets no warning. - Android is not checked here; Gradle reports an Android project without sources itself.
kargo testdoesn’t warn: a project can test code that lives elsewhere.
Ignored Kotlin scripts
Section titled “Ignored Kotlin scripts”warning: `src/script.kts` is ignored: Kargo does not compile or run Kotlin scripts (.kts); put the code in a .kt file, or run it with `kargo script <file>`Kargo compiles .kt and .java files. A .kts file in src/, src-<target>/, tests/, tests-<target>/ or examples/ is not compiled and not run, so its code silently does nothing. Move the code into a .kt file (a program needs a fun main), or delete the file if it is a Gradle build script left over from a migration. To run a script on its own, without a project, use kargo script.
Kargo names the first five scripts and counts the rest. A .kts file under resources/ or test-resources/ is data and is not reported.
Tasks hidden by built-in commands
Section titled “Tasks hidden by built-in commands”warning: task `build` is hidden by the built-in `kargo build` command; run the task with `kargo task build` or rename itkargo <name> runs a task only when <name> is not a built-in command, so kargo build always compiles the project, whatever [tasks] says. The task itself still works: run it with kargo task build, or let it run as a hook. Aliases count too, so a task named b, c, r or t is hidden by kargo build, check, run or test.
kargo task and kargo --help mark hidden tasks:
$ kargo taskAvailable tasks: build echo custom build [hidden by `kargo build`; run it with `kargo task build`] ci echo ciRename the task to make kargo <name> work as a shorthand again.
.env file tracked by git
Section titled “.env file tracked by git”warning: `.env` is tracked by git but sets API_TOKEN; keep secrets in a git-ignored `.local` file or in your shellA .env file that git tracks is shared with everyone who clones the repository. Kargo warns when such a file sets a variable whose name looks like a secret (it contains SECRET, TOKEN, PASSWORD, PASSWD or CREDENTIAL, or it is KEY or ends in _KEY) with a value. Move the secret into .env.local or .env.<profile>.local, which kargo new git-ignores, or into your shell, and remove the file from git with git rm --cached .env. Empty values don’t count. Without git, or for files git doesn’t track, there is no warning.
Generator inputs that match nothing
Section titled “Generator inputs that match nothing”warning: no file matches the `inputs` of [[generate]] `protos`: proto/**/*.protoA [[generate]] step with inputs runs when those files change, and none of the globs matches a file. Usually the glob has a typo or the files are somewhere else. Globs are relative to the project root, use gitignore syntax, and never match inside target/ or a directory whose name starts with a dot. A protobuf step with no .proto file generates nothing; any other step still runs.
Odd package versions
Section titled “Odd package versions”warning: package version `not.a.version.x` does not look like a version (expected something like `1.0.0`); it becomes part of the jar's file name and of its Maven coordinates[package] version names the jar (app-1.0.0.jar) and is the version in its Maven coordinates. Maven accepts almost any string, so Kargo does too, apart from ranges, wildcards and spaces, which are errors. But a version that doesn’t start with a digit, or uses anything but letters, digits and ., -, _ and +, is rarely intended. 0.1.0, 1.0-SNAPSHOT, 2.1.0-rc.1 and 2024.03 are fine; v1.0, latest and 1/2 are not.
Warnings as errors
Section titled “Warnings as errors”With [kotlin] warnings-as-errors = true the Kotlin compiler reports its warnings as errors. It prints a summary of that, error: warnings found and -Werror specified, ahead of the diagnostics it counts. Kargo holds the line back and prints it after them, as the last line of the compiler’s output, so the diagnostics are never announced before you can see them:
$ kargo build Compiling app v0.1.0 (jvm)src/Main.kt:9:12: error: 'fun old(): Int' is deprecated. use other. return old() ^^^error: warnings found and -Werror specifiederror: could not compile `app` due to previous errorsWith --message-format json it is the last compiler-message. See Machine-readable output.