A source set is a named group of sources and resources. Elide derives compile, test and packaging tasks from them.
Conventional layout
main is in src/main, test in src/test, any other set in src/<name>:
| Path | Meaning |
|---|---|
src/<set>/java, /kotlin, /js, /ts, /python | Sources, one directory per language |
src/<set>/resources | Resources |
- Every language directory that exists is compiled. With none,
src/<set>itself is the source root. srcis used assrc/main;testortestsassrc/test.mainandtestexist when their directories do. Other sets must be declared.
This layout needs no sources block:
src/main/kotlin/sample/Main.kt
src/main/resources/app.properties
src/test/kotlin/sample/MainTest.ktelide project info prints the resolved sets; (by convention) marks paths from the layout.
Declaring source sets
sources {
// A glob, for a set that only moves its sources.
["main"] = "lib/**/*.kt"
// An entry with more to say.
["integrationTest"] {
type = "test"
paths { "it/**/*.kt" }
}
}new Sources.SourceSetSpec { … } (with import "elide:Sources.pkl" as Sources) is the long form of the entry.
Paths are project-relative globs or directories; a directory is walked recursively.
Precedence
Each declared property replaces the convention for that property only.
| Property | Left out | Declared |
|---|---|---|
type | Inferred from the name | Always used |
paths | The conventional layout for the name | Used verbatim |
resources | src/<name>/resources, when present | Used verbatim |
dependsOn | Test and example sets see main | Used verbatim; empty means nothing |
type | Inferred from | Behavior |
|---|---|---|
test | test, tests | Run by elide test; resolves testPackages. |
example | example, examples | Production set. |
source | any other name | Production set. |
other | — | Production set. |
Production sets are packaged by artifacts that name no sources. A declared set whose paths cover src/main or
src/test replaces that conventional set, so files never compile twice.
Dependencies and classpaths
Production sets resolve packages, modules, compileOnly, runtimeOnly and processors. Test sets add
testPackages and the set they depend on. See Dependencies.
elide classpath # main:compile
elide classpath runtime # main:runtime
elide classpath test:runtime # [<source-set>:]<usage>Prints the classpath from the last elide install, one entry per line. Usages: compile, runtime, processor,
modules, toolchain, provided; anything else is a usage error. Install also writes
.dev/dependencies/m2/{compile,runtime,test,processors}.classpath.
Resources
On the JVM, resources are on the classpath for runs and tests and are copied into JARs.
sources {
["main"] {
resources {
"assets/banner.txt"
new {
from = "config/services"
into = "META-INF"
}
}
}
}A plain path is copied to the output root. from (a directory or file) is copied under into:
config/services/app.Service becomes META-INF/services/app.Service. into defaults to the root.
Artifacts
artifacts {
["app"] = new Jvm.Jar {} // every non-test source set
["lib"] = new Jvm.Jar { sources { "api" } }
}Source and Javadoc JARs follow the same rule. A JAR’s resources add to its sets’. See
JAR Assembly.
Languages
The file extension determines the language: .java, .kt/.kts, .js/.mjs/.cjs/.jsx,
.ts/.mts/.cts/.tsx, .py. A set with Java and Kotlin runs both compilers; a set with neither runs no JVM compilation.