Skip to content

Seedstack Developer Guide

hervestern edited this page Aug 18, 2020 · 6 revisions

Local Developpement and Test

Developments on Seedstack are made on forked copies of main repository.

For example, to work on Seed project, fork https://github.com/seedstack/seed, then clone your forked project.

If required, set upstream in forked project; for example, with distribution project:

git remote add upstream https://github.com/seedstack/distribution.git

First steps are:

  1. update project version in pom.xml files, if required

    Example: mvn versions:set versions:commit -DnewVersion=19.11-SNAPSHOT

  2. update CHANGELOG.md file

  3. update version of component in distribution/pom.xml

One can develop and test directly in seed project (prefer IT tests), and in a test project. To implement current framework developments in a test project, one has two possibilities, as seen below.

Testing using updated test project dependencies (recommended!)

In you test project, override the dependency version to the module you are updating.

For example:

<dependency>
    <groupId>org.seedstack.seed</groupId>
    <artifactId>seed-rest-jersey2</artifactId>
    <version>3.8.1-SNAPSHOT</version>
</dependency>

Or

<dependency>
    <groupId>org.seedstack.seed</groupId>
    <artifactId>seed-web-core</artifactId>
    <version>3.8.1-SNAPSHOT</version>
</dependency> 

Testing using distribution project

Fork, then checkout project https://github.com/seedstack/distribution.

seed/pom.xml

If required:

  • update current version (e.g. 3.8.0-SNAPSHOT)
  • under dependencyManagement, update version for org.seedstack:seedstack-bom (e.g. 18.11-SNAPSHOT)

distribution/pom.xml

If required:

  • update version (e.g. 18.11-SNAPSHOT)
  • update seed.version (e.g. 3.8.0-SNAPSHOT)

distribution/seedstack-bom/pom.xml

If required:

  • update version (ex. 18.11-SNAPSHOT)

Integration tests

Integration tests can be run using:

mvn integration-test

Configuration

Classes can be mapped to configuration objects from application.yaml using @Config annotation.

Warning: Attributes cannot be static to be mappable.

Attributes can be mapped to configuration objects using @Configuration annotation.

Config Tool can find configuration classes (@Config] and their non-static attributes.

It cannot find usages of @Configuration annotation.

EffectiveConfig tool displays user-defined configuration based on application<.override>.(yaml|yml|json|properties) files available in the classpath.

Usage tips

How to populate database

Example with MongoDB for application called hseed, having

domain package:

  • class Client (extends BaseAggregateRoot),
  • class ClientId (extends BaseValueObject),
  • interface ClientRepository (extends Repository<Client, ClientId>)

interface package:

  • class ClientRepositoryImpl (extends BaseMorphiaRepository<Client, ClientId> and implements ClientRepository)

infrastructure package:

  • class ClientDto (POJO) with DataSet annotation, where
    • group = "hseed":
    • name = "client" : associated object
  • class ClientDtoImporter : extends BaseDataImporter

Method importData is overridden, for example with:

dtos.forEach(dto -> repository.add(new Client(new ClientId(dto.getId()), dto.getCode())));

test/resources/META-INF/data/hseed/client.json : file containing data to load.

Configuration properties

In application.yaml or preferably application.override.yaml, properties can be set for DataConfig object. Available properties are

  • importOnStart (default = true)
  • clearBeforeImport (default = true)
  • forceImport (default = true)

For example:

business:
  data:
    forceImport: true

ConfigTool

ConfigTool enables access to various information regarding configuration.

Effective config

Dumps the configuration as scanned, parsed and aggregated by SeedStack

See: http://seedstack.org/docs/maven-plugin/effective-config/

Maven

mvn -q seedstack:effective-config 

Java

java -Dseedstack.tool=effective-config -jar target/hsweb-capsule.jar

Config

Dumps all the configuration options available in the project

See: http://seedstack.org/docs/maven-plugin/config/

Maven

mvn -q seedstack:config

Java

java -Dseedstack.tool=config -jar target/hsweb-capsule.jar

Appendices

Intellij Plugin

Enables developer to link configuration properties (in application.yaml) with associated classes.

See:

Note: not totally functional with Intellij Community Edition 2017.

Clone this wiki locally