Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,35 @@ dependencies {
}
```

### Quickstart Archetypes

Instead of configuring a project manually, you can generate a ready-to-use
skeleton with Maven Archetypes:

**BOX API quickstart:**
```bash
mvn archetype:generate \
-DarchetypeGroupId=io.tarantool \
-DarchetypeArtifactId=tarantool-box-quickstart \
-DarchetypeVersion=2.0.0
```

**CRUD API quickstart:**
```bash
mvn archetype:generate \
-DarchetypeGroupId=io.tarantool \
-DarchetypeArtifactId=tarantool-crud-quickstart \
-DarchetypeVersion=2.0.0
```

> On Windows PowerShell, quote the version: DarchetypeVersion="2.0.0"

The BOX archetype generates a minimal example of client initialization, idempotent space creation, and basic `insert`/`select` operations.

The CRUD archetype generates a Spring Boot project with a `CrudRepository`, a `@Tuple`-mapped entity, and a `TarantoolCartridgeContainer`-based integration test. Note that the CRUD layer requires a Cartridge cluster with the `crud-router` and `crud-storage` roles enabled — a standalone Tarantool instance is not sufficient.

> **Note:** Until the first release, build and install the archetypes locally with `mvn clean install -pl tarantool-archetypes -am` and pass `-DarchetypeCatalog=local` to `mvn archetype:generate`.

## Documentation

- [Release](RELEASING.md)
Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<shared.dir>${project.parent.basedir}/tarantool-shared-resources/</shared.dir>
<license.header.file>${project.basedir}/LICENSE_HEADER.txt</license.header.file>
<maven-surefire-plugin.version>3.6.1</maven-surefire-plugin.version>
<maven-archetype-plugin.version>3.4.1</maven-archetype-plugin.version>
</properties>

<build>
Expand Down Expand Up @@ -532,5 +533,6 @@
<module>testcontainers-autogen</module>
<module>documentation</module>
<module>tarantool-java-sdk-bom</module>
<module>tarantool-archetypes</module>
</modules>
</project>
54 changes: 54 additions & 0 deletions tarantool-archetypes/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.tarantool</groupId>
<artifactId>tarantool-java-sdk</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>tarantool-archetypes</artifactId>
<packaging>pom</packaging>
<name>Tarantool Java SDK :: Archetypes</name>
<description>Maven Archetype templates for quick project scaffolding</description>

<properties>
<spotless.check.skip>true</spotless.check.skip>
<spotless.apply.skip>true</spotless.apply.skip>
</properties>

<build>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>${maven-archetype-plugin.version}</version>
</extension>
</extensions>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>${maven-archetype-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<mainClass>${package}.BoxApiApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>

<modules>
<module>tarantool-box-quickstart</module>
<module>tarantool-crud-quickstart</module>
</modules>
</project>
28 changes: 28 additions & 0 deletions tarantool-archetypes/tarantool-box-quickstart/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.tarantool</groupId>
<artifactId>tarantool-archetypes</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>tarantool-box-quickstart</artifactId>
<packaging>maven-archetype</packaging>
<name>Tarantool Java SDK :: Archetypes :: Box Quickstart</name>
<description>Quickstart archetype for Tarantool BOX API</description>

<build>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>3.4.1</version>
</extension>
</extensions>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor xmlns="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0
https://maven.apache.org/xsd/archetype-descriptor-1.1.0.xsd"
name="tarantool-box-quickstart">

<fileSets>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>

<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</fileSet>

<fileSet filtered="true" encoding="UTF-8">
<directory/>
<includes>
<include>README.md</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ${artifactId}

Quickstart project for working with the **Tarantool BOX API** via the Tarantool Java SDK.

## Requirements

- Java 17+
- A running Tarantool instance on `localhost:3301`

## Run

```bash
mvn clean package
java -jar target/${artifactId}-${version}.jar
```

## What the example does

1. Connects to Tarantool via `TarantoolFactory.box()`.
2. Idempotently creates the person space and the primary pk index.
3. Inserts the tuple `[1, 'Alice']`.
4. Reads the tuple by key 1 and prints it to the log.

## Important for production
Creating the schema via eval on application startup is an anti-pattern.
In a real project, manage the schema via migrations:

- Flyway with Java migrations
- tarantool/migrations (Lua)
- or an external schema deployment tool

`if_not_exists = true` in the example only exists so that re-running the
quickstart does not fail with "Space 'person' already exists".

## Dependencies

- `io.tarantool:tarantool-client:1.7.3` — Box API
- Logback + SLF4J — logging
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>jar</packaging>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tarantool-client.version>1.7.3</tarantool-client.version>
<slf4j.version>2.0.16</slf4j.version>
<logback.version>1.5.12</logback.version>
</properties>

<dependencies>
<dependency>
<groupId>io.tarantool</groupId>
<artifactId>tarantool-client</artifactId>
<version>${tarantool-client.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package ${package};

import io.tarantool.driver.api.TarantoolBoxClient;
import io.tarantool.driver.api.TarantoolFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

public class BoxApiApplication {
private static final Logger log = LoggerFactory.getLogger(BoxApiApplication.class);

public static void main(String[] args) {
// 1. Initialize the Box API client.
// For local development without authentication:
TarantoolBoxClient client = TarantoolFactory.box()
.withHost("localhost")
.withPort(3301)
// .withCredentials("guest", "") // Uncomment if explicit authentication is required
.build();

try {
// 2. Prepare the schema (idempotent).
// IMPORTANT: in production, manage the schema via migrations
// (Flyway, Tarantool migrations), not via eval on application startup.
client.eval("return box.schema.create_space('person', {if_not_exists = true})").join();
client.eval("return box.space.person:create_index('pk', " +
"{parts = {1, 'unsigned'}, if_not_exists = true})").join();

// 3. Work with data through the low-level Box API
var space = client.space("person");
space.insert(Arrays.asList(1L, "Alice")).join();

var result = space.select(1L).join();
log.info("Retrieved tuple: {}", result.get(0));

} finally {
client.close();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
groupId=com.example.test
artifactId=my-box-app
version=0.0.1-TEST
package=com.example.test.box
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
validate
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def readme = new File(context.projectDir, "README.md")

assert readme.exists() : "README.md not generated at ${readme}"
assert readme.text.contains("# my-box-app") : "artifactId not substituted"
assert !readme.text.contains('${') : "Unresolved variables found"
28 changes: 28 additions & 0 deletions tarantool-archetypes/tarantool-crud-quickstart/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.tarantool</groupId>
<artifactId>tarantool-archetypes</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>tarantool-crud-quickstart</artifactId>
<packaging>maven-archetype</packaging>
<name>Tarantool Java SDK :: Archetypes :: CRUD Quickstart</name>
<description>Quickstart archetype for Tarantool CRUD API</description>

<build>
<extensions>
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>3.4.1</version>
</extension>
</extensions>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor xmlns="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.1.0
https://maven.apache.org/xsd/archetype-descriptor-1.1.0.xsd"
name="tarantool-crud-quickstart">

<fileSets>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/test/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.yaml</include>
<include>**/*.properties</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/test/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.lua</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory></directory>
<includes>
<include>pom.xml</include>
<include>README.md</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>
Loading
Loading