Prerequisites
To start developing Strolch you need an installed:- Java JDK 8
- Apache Maven 3
Getting Started
Setting up Strolch is just a few lines:
git clone https://github.com/4treesCH/strolch.git cd strolch mvn clean install -DskipTests
Note: To run the tests you will need to configure the PostgreSQL Databases. See the README in the module.
After running the Maven build, you will have a full build of all Strolch projects. Now you can start modifying the projects, and add your own features, or, far more interesting, start developing your projects using the Strolch agent.
Strolch Project Configuration
To use Strolch in your own projects, look at the two tutorial apps on how they are configured. You can also simply copy the projects, modify the Maven POMs and remove what ever you do not need.
The following sections describe the Strolch configuration files and folder structure.
You can also use the minimal project structures:
Project Structure
Strolch requires two main directories under the Strolch root:
- ../config/ → contains the Strolch runtime configuration
- StrolchConfiguration.xml → Main Strolch configuration file. There you configure the different realms, environments etc.
- PrivilegeConfig.xml → Configuration of the Privilege library
- PrivilegeModel.xml → Configuration file with the differen users, roles and privileges
- ../data/ → contains the Strolch model and any other data which is modified at runtime.
- StrolchModel.xml → main model file which is read when Strolch is in TRANSIENT mode.
Maven POM
Strolch is built using Maven, so here we show the minimum Maven POM.
Simple Java App POM
This POM creates a compressed file which contains a runnable Strolch instance. Just unpack and run the startup.sh script.
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <properties> <strolch.version>1.0.0-SNAPSHOT</strolch.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <finalName>strolch_app</finalName> <m2eclipse.wtp.contextRoot>${finalName}</m2eclipse.wtp.contextRoot> <buildTimestamp>${maven.build.timestamp}</buildTimestamp> </properties> <groupId>org.example</groupId> <artifactId>org.example.strolch.app</artifactId> <version>1.2.3</version> <name>org.example.strolch.app</name> <scm> <developerConnection>scm:git:https://git.example.org/strolch_app.git</developerConnection> </scm> <dependencyManagement> <dependencies> <dependency> <groupId>li.strolch</groupId> <artifactId>li.strolch.bom</artifactId> <type>pom</type> <version>${strolch.version}</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- main --> <dependency> <groupId>li.strolch</groupId> <artifactId>li.strolch.model</artifactId> <version>${strolch.version}</version> </dependency> <dependency> <groupId>li.strolch</groupId> <artifactId>li.strolch.agent</artifactId> <version>${strolch.version}</version> </dependency> <dependency> <groupId>li.strolch</groupId> <artifactId>li.strolch.service</artifactId> <version>${strolch.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <scope>runtime</scope> <version>1.7.2</version> </dependency> <!-- test dependencies --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> <version>4.11</version> </dependency> </dependencies> <build> <finalName>${finalName}</finalName> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/componentVersion.properties</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <excludes> <exclude>**/componentVersion.properties</exclude> </excludes> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.7</source> <target>1.7</target> <showDeprecation>true</showDeprecation> <showWarnings>true</showWarnings> <compilerArgument>-Xlint:all</compilerArgument> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>buildnumber-maven-plugin</artifactId> <version>1.2</version> <executions> <execution> <phase>validate</phase> <goals> <goal>create</goal> </goals> </execution> </executions> <configuration> <doCheck>false</doCheck> <doUpdate>false</doUpdate> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> <!-- When creating an executable jar, use copy-dependencies plugin with libs in lib/ dir: --> <mainClass>li.strolch.tutorialapp.main.Main</mainClass> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptor>src/assembly/bin.xml</descriptor> <finalName>tutorial-app-${project.version}</finalName> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
Webapp POM
This creates a simple WAR which starts Strolch after deployed to a servlet container.
<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 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <properties> <strolch.version>1.2.3</strolch.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <warFinalName>strolch_webapp</warFinalName> <m2eclipse.wtp.contextRoot>${warFinalName}</m2eclipse.wtp.contextRoot> <buildTimestamp>${maven.build.timestamp}</buildTimestamp> </properties> <groupId>org.example</groupId> <artifactId>org.example.strolch.webapp</artifactId> <version>1.0.0-SNAPSHOT</version> <name>org.example.strolch.webapp</name> <packaging>war</packaging> <scm> <developerConnection>scm:git:https://git.example.org/strolch_webapp.git</developerConnection> </scm> <dependencyManagement> <dependencies> <dependency> <groupId>li.strolch</groupId> <artifactId>li.strolch.bom</artifactId> <type>pom</type> <version>${strolch.version}</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- main --> <dependency> <groupId>li.strolch</groupId> <artifactId>li.strolch.model</artifactId> <version>${strolch.version}</version> </dependency> <dependency> <groupId>li.strolch</groupId> <artifactId>li.strolch.agent</artifactId> <version>${strolch.version}</version> </dependency> <dependency> <groupId>li.strolch</groupId> <artifactId>li.strolch.service</artifactId> <version>${strolch.version}</version> </dependency> <dependency> <groupId>li.strolch</groupId> <artifactId>li.strolch.rest</artifactId> <version>${strolch.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <scope>runtime</scope> <version>1.7.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency> <!-- test dependencies --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> <version>4.11</version> </dependency> </dependencies> <build> <finalName>${warFinalName}</finalName> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/componentVersion.properties</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <excludes> <exclude>**/componentVersion.properties</exclude> </excludes> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.7</source> <target>1.7</target> <showDeprecation>true</showDeprecation> <showWarnings>true</showWarnings> <compilerArgument>-Xlint:all</compilerArgument> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>buildnumber-maven-plugin</artifactId> <version>1.2</version> <executions> <execution> <phase>validate</phase> <goals> <goal>create</goal> </goals> </execution> </executions> <configuration> <doCheck>false</doCheck> <doUpdate>false</doUpdate> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> <warName>${warFinalName}</warName> <webResources> <resource> <directory>src/main/non-packaged-resources</directory> <targetPath>WEB-INF</targetPath> <filtering>true</filtering> <includes> <include>**/ENV.properties</include> </includes> </resource> </webResources> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>m2e</id> <!-- This profile is only activated when building in Eclipse with m2e --> <activation> <property> <name>m2e.version</name> </property> </activation> <properties> <strolch.env>dev</strolch.env> </properties> </profile> </profiles> </project>
Happy coding =))