Skip to content

An example repo to demonstrate Kotlin support in Pants v2

License

Notifications You must be signed in to change notification settings

benjyw/example-kotlin

 
 

Repository files navigation

example-kotlin

This repository demonstrates how to use Kotlin with Pants. (Pants also supports Java and Scala, which are demonstrared in the example-jvm repository.)

There are two examples:

This is only one possible way of laying out your project with Pants. See pantsbuild.org/docs/source-roots#examples for some other example layouts.

Running Pants

You run Pants goals using the ./pants wrapper script, which will bootstrap the configured version of Pants if necessary.

Goals

Pants commands are called goals. You can get a list of goals with

./pants help goals

Most goals take arguments to run on. To run on a single directory, just use the directory name. To recursively run on a directory and all its subdirectories, add :: to the end.

For example:

./pants lint src: 3rdparty::

You can run on all changed files:

./pants --changed-since=HEAD lint

You can run on all changed files, and any of their "dependees":

./pants --changed-since=HEAD --changed-dependees=transitive test

Example Goals

Try these out in this repo!

Run ktlint

./pants fmt ::  # Format all files.
./pants fmt src/jvm  # Format only files in this directory (non-recursively).
./pants lint src/jvm::  # Check that all files under `src/jvm` are formatted (recursively).

Check compilation

./pants check ::  # Compile everything.
./pants check src/jvm/org/pantsbuild/example/json/JsonExample.kt  # Compile a file and its deps.

Create a binary file

Writes the result to the dist/ folder.

./pants package src/jvm/org/pantsbuild/example/json  # Build binaries in this directory.
./pants package ::  # Create all binaries.

Determine dependencies

./pants dependencies src/jvm::
./pants dependencies --transitive src/jvm::

Determine dependees

That is, find what code depends on a particular files.

./pants dependees src/jvm/org/pantsbuild/example/json::
./pants dependees --transitive src/jvm/org/pantsbuild/example/json/JsonExample.kt

Count lines of code

./pants count-loc ::

About

An example repo to demonstrate Kotlin support in Pants v2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 83.8%
  • Kotlin 8.1%
  • Starlark 5.5%
  • Java 2.6%