Running KSP from the command line
Most projects use KSP through the Gradle plugin, which runs KSP automatically during compilation. You can use KSP from the command line but it's normally only used when you're integrating with other build systems, developing processors, testing, or debugging.
Since KSP is a JVM application, use the java command to launch KSP from the command line. Provide the classpath and any necessary arguments:
Argument | Description |
|---|---|
| Path to KSP runtime JARs and their dependencies. |
| One of the platform-specific KSP entry points. |
| Command-line options for KSP. |
| Path to the processor JAR. |
Classpath
Unlike the Gradle plugin, the java command doesn't resolve dependencies automatically. You must provide the KSP runtime JARs and their dependencies on the classpath.
Download artifacts.zip from the KSP release page. The archive contains the required KSP JAR files:
symbol-processing-aa-2.3.10.jarsymbol-processing-common-deps-2.3.10.jarsymbol-processing-api-2.3.10.jar
You must also include the following runtime dependencies from the Maven Repository:
Main class
Because KSP is a JVM application, you must specify the main class to launch. KSP provides a different entry point for each supported platform:
Entry point | Platforms |
|---|---|
| Kotlin/JVM and Android |
| Kotlin/JS |
| Kotlin/Native targets, such as iOS, macOS, Linux, and Windows. |
| Common compilations in Kotlin Multiplatform projects. |
When launching KSP with java, specify the fully qualified class name. For example:
The following example uses KSPJvmMain to run KSP for a JVM target:
Options
KSP requires the following options when running from the command line:
Option | Description |
|---|---|
| The Kotlin language version used in the project. |
| The Kotlin API version. |
| The target JVM version. |
| The module name. |
| The source root directories. Use a colon-separated list for multiple directories. |
| The project root directory. |
| The base directory for KSP output. |
| The directory for KSP caches. |
| The directory for generated Java files. |
| The directory for generated class files. |
| The directory for generated Kotlin files. |
| The directory for generated resources. |
| The processor classpath. |
Other useful options
-libraries=<path>: The classpath used to resolve dependencies referenced by the source files. Typically the module's compile classpath.-jdk-home=<path>: The JDK home directory. Use when the processor resolves Java symbols and requires access to the Java standard library.-friends=<path>: The classpath of the current module's friend modules. This is typically the module's friend classpath. For more information, see Friend modules.
To see the full list of options, run the following command: