Installation
Spider Silk requires Java 25 or later.
Releases are published to Maven Central, so a build needs no repository beyond the default one.
The current version is 1.1.0.
CHANGELOG.md lists what changed in each release.
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation 'net.benelog.spidersilk:spider-silk-core:1.1.0'
testImplementation 'net.benelog.spidersilk:spider-silk-test:1.1.0'
}
Maven
Maven resolves from Central by default, so pom.xml declares the dependencies and nothing else:
<dependencies>
<dependency>
<groupId>net.benelog.spidersilk</groupId>
<artifactId>spider-silk-core</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>net.benelog.spidersilk</groupId>
<artifactId>spider-silk-test</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Hello, world
import net.benelog.spidersilk.App;
import net.benelog.spidersilk.WebResponse;
public class Main {
public static void main(String[] args) {
App app = new App();
app.get("/hello/{name}", req -> WebResponse.text("Hello, " + req.pathParam("name")));
app.start(8080);
}
}
$ curl localhost:8080/hello/silk
Hello, silk
spider-silk-core brings embedded Jetty with it, so nothing else is needed to serve a request.
See Deployment to deploy on an external servlet container instead.
Modules
The modules fall into four groups. Only the core group is needed, and the others are added one at a time, the same way as core.
Core
Every application uses these two.
| Module | Contents |
|---|---|
|
The framework, with jte templates, embedded Jetty, and silk-json, the JSON library it is built on |
|
|
Extensions
An extension is optional. Add one only when you want what it names instead of, or beside, the core default.
| Module | Use it when you want |
|---|---|
Servers: core’s default is Jetty, and Choosing a server covers the choice |
|
|
|
|
|
Templates: core’s default is jte |
|
|
|
|
|
|
|
Features |
|
|
|
|
|
|
|
|
An OpenTelemetry Java agent extension: spans named after the matched route, with the jar handed to the agent rather than added as a dependency |
Build
The build modules carry optional packaging conventions, precompiled jte, a Jib image, and a native build, and the generator of JSON codecs.
| Module | Build tool |
|---|---|
|
Gradle, applied as the plugin |
|
Maven, used as the parent POM |
|
javac on either build tool, as an annotation processor: Generated JSON Codecs for the types annotated |
Coordinates, packages, and module names
net.benelog.spidersilk is one string, used three ways on purpose.
| Where | What it is |
|---|---|
Group id |
|
Package root |
|
|
The package root the jar carries, so |
The Gradle plugin is applied by that same id, net.benelog.spidersilk, and the Maven parent is net.benelog.spidersilk:spider-silk-maven-parent.
silk-json, a library of its own, follows the same rule under a string of its own, net.benelog.silkjson: the artifacts net.benelog.silkjson:silk-json and net.benelog.silkjson:silk-json-processor, the package root net.benelog.silkjson, and net.benelog.silkjson.processor for the processor.
Decision 32 gives the reasoning.