Recommended configuration

Recommended configuration is used for creating new projects by JCS JLupin Platform IntelliJ Pluing. This configuration is used for multi module Maven project. We assume that standard application building flow is same as for Maven phases. In shortcut that means:

  • compile
  • test (unit testing)
  • package
  • test (integration testing)
  • share

Below default configuration is presented. Description is added as a comments inside listings.

main project pom.xml

Main project pom.xml is responsible for gathering all project modules and to handle common configuration.

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>docs</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <!--
        This two entries (<repository> and <pluginRepository>) tells Maven
        where it can find JLupin Platform dependecies and plugins. Without
        it you won't be able to download artifacts. Of course you can
        configure this in any other place (like global repository file).
    -->

    <repositories>
        <!-- Repository is also accessible using https connection: -->
        <!-- https://support.jlupin.com/maven2/ -->
        <repository>
            <id>jlupin-central</id>
            <name>jlupin</name>
            <url>http://support.jlupin.com/maven2/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <!-- Repository is also accessible using https connection: -->
        <!-- https://support.jlupin.com/maven2/ -->
        <pluginRepository>
            <id>jlupin-central</id>
            <name>jlupin</name>
            <url>http://support.jlupin.com/maven2/</url>
        </pluginRepository>
    </pluginRepositories>

    <!--
        Section <modules> is important for multi module projects. Entries are
        relative paths to directories where pom.xml files are located.
        Remember to add here every new microservice you are adding to your
        project.
    -->

    <modules>
        <module>common-util</module>
        <module>common-pojo</module>
        <module>example-native/interfaces</module>
        <module>example-native/implementation</module>
        <module>example-servlet/implementation</module>
        <module>integration-test</module>
    </modules>

    <!--
        Some settings are moved to properties for simple usage inside child
        pom.xml files.
    -->

    <properties>
        <jlupin.platfrom.version>1.5.0.0</jlupin.platfrom.version>
        <jlupin.skipDeploy>true</jlupin.skipDeploy>
        <maven.surefire.skipTests>false</maven.surefire.skipTests>

        <spring.context.version>4.3.9.RELEASE</spring.context.version>
        <maven.failsafe.plugin.version>2.20</maven.failsafe.plugin.version>
        <maven.surefire.plugin.version>2.20</maven.surefire.plugin.version>
        <jlupin.platform.maven.plugin.version>1.5.0.0</jlupin.platform.maven.plugin.version>
        <slf4j.version>1.8.0-alpha2</slf4j.version>
        <log4j.slf4j.bridge.version>2.10.0</log4j.slf4j.bridge.version>

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <!--
                Surefire plugin is configured to use property as a
                configuration variable. Used to disable surefire for
                integration tests (they are using failsafe plugin).
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <skipTests>${maven.surefire.skipTests}</skipTests>
                </configuration>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <!--
                    JCS JLupin Platform Maven Plugin configuration for
                    microservices.
                -->
                <plugin>
                    <groupId>com.jlupin</groupId>
                    <artifactId>jlupin-platform-maven-plugin</artifactId>
                    <version>${jlupin.platform.maven.plugin.version}</version>
                    <executions>
                        <!--
                            By default zip goal is bind to package phase. But
                            it is not configured with any additional files
                            directory. It is recommended to create such a
                            directory. Path provided here is relative to
                            pom.xml file for specific project (the one where
                            plugin is added to execute).
                        -->
                        <execution>
                            <id>jlupin-zip</id>
                            <goals>
                                <goal>zip</goal>
                            </goals>
                            <configuration>
                                <additionalFilesDirectories>
                                    <param>../additional-files</param>
                                </additionalFilesDirectories>
                            </configuration>
                        </execution>
                        <!--
                            By default deploy goal is not bind to any phase.
                            It is useful to execute it in a pre-integration-test
                            phase to deploy microservices to server where they
                            will be tested. By default they are deployed to
                            127.0.0.1 server with transmission port 9096.
                        -->
                        <execution>
                            <id>jlupin-deploy</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!--
                    Failsafe plugin is configured to use same class naming
                    as a surefire plugin. This way it is easy to move test
                    from one to the other when some calls becomes remote ones.
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven.failsafe.plugin.version}</version>
                    <executions>
                        <execution>
                            <id>integration-test</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <includes>
                            <include>**/Test*.java</include>
                            <include>**/*Test.java</include>
                            <include>**/*Tests.java</include>
                            <include>**/*TestCase.java</include>
                        </includes>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

common-util and common-pojo

These are modules for common functionalities and objects for all microservices. Their pom.xml configuration is almost same - only name differs. Also nothing happens in configuration. They are just holders for common classes.

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>docs</artifactId>
        <groupId>com.example</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>./../pom.xml</relativePath>
    </parent>

    <artifactId>common-util</artifactId>
</project>
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>docs</artifactId>
        <groupId>com.example</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>./../pom.xml</relativePath>
    </parent>

    <artifactId>common-pojo</artifactId>
</project>

integration-test

This module is designed to contain integration tests. They are runned as a remote client on running environment similar as a proudction. That means that server with deployed microservices should be running while tests are executed.

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>docs</artifactId>
        <groupId>com.example</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>./../pom.xml</relativePath>
    </parent>

    <artifactId>integration-test</artifactId>

    <!--
        Disable unit tests for this module (same file names but unit tests are
        executed during wrong phase).
    -->
    <properties>
        <maven.surefire.skipTests>true</maven.surefire.skipTests>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>common-util</artifactId>
            <version>1.0-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>common-pojo</artifactId>
            <version>1.0-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>

        <!-- JLupin dependencies -->
        <dependency>
            <groupId>com.jlupin</groupId>
            <artifactId>jlupin-client-assembly</artifactId>
            <version>${jlupin.platform.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>${log4j.slf4j.bridge.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!--
                Enable failsafe plugin for this module (it is configured in
                main project pom.xml).
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

native microservice

It is recommended to have native microservice splited into two modules. One for interfaces and objects used by external users and one for implementation. They will packed into single zip (using JLupin Platform Maven Plugin) for deploying to server but all your clients should receive only interfaces module. We also recommend to create 'additional-files' directory on the same level as the interfaces and implementation modules (see main project pom.xml file configuration for JCS JLupin Platform Maven Plugin). So inside directory named as microservice create 3 directories: additional-files, interfaces, implementation. And put pom.xml files it two of them:

interfaces

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>docs</artifactId>
        <groupId>com.example</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>./../../pom.xml</relativePath>
    </parent>

    <artifactId>example-native-interfaces</artifactId>

    <dependencies>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>common-pojo</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

implementation

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>docs</artifactId>
        <groupId>com.example</groupId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>./../../pom.xml</relativePath>
    </parent>

    <!--
        Name is used as a microservice name.
    -->
    <name>example-native</name>
    <artifactId>example-native-implementation</artifactId>

    <!--
        Deploy should be enabled only for implementation modules.
    -->
    <properties>
        <jlupin.skipDeploy>false</jlupin.skipDeploy>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.context.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>example-native-interfaces</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>common-util</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>common-pojo</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <!-- JLupin dependencies -->
        <dependency>
            <groupId>com.jlupin</groupId>
            <artifactId>jlupin-client-assembly</artifactId>
            <version>${jlupin.platform.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>${log4j.slf4j.bridge.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <!--
        Enable JLupin Platform Maven Plugin for this module.
        They are configured in main project pom.xml file.
    -->
    <build>
        <plugins>
            <plugin>
                <groupId>com.jlupin</groupId>
                <artifactId>jlupin-platform-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

servlet microservice

For servlet microservice only implementation module should be created. They will packed into single zip (using JLupin Platform Maven Plugin) for deploying to server. But inside only one jar will be located, becuasue by default spring will pack all your dependencies into you jar/war. We also recommend to create 'additional-files' directory on the same level as the implementation module (see main project pom.xml file configuration for JLupin Platform Maven Plugin). So inside directory named as microservice create 2 directories: additional-files, implementation. And put pom.xml files it two of them:

implementation

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.7.RELEASE</version>
    </parent>

    <name>example-servlet</name>
    <groupId>com.example</groupId>
    <artifactId>example-servlet-implementation</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>

    <!--
        This two entries (<repository> and <pluginRepository>) tells Maven
        where it can find JLupin Platform dependecies and plugins. Without
        it you won't be able to download artifacts. Of course you can
        configure this in any other place (like global repository file).
    -->

    <repositories>
        <!-- Repository is also accessible using https connection: -->
        <!-- https://support.jlupin.com/maven2/ -->
        <repository>
            <id>jlupin-central</id>
            <name>jlupin</name>
            <url>http://support.jlupin.com/maven2/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <!-- Repository is also accessible using https connection: -->
        <!-- https://support.jlupin.com/maven2/ -->
        <pluginRepository>
            <id>jlupin-central</id>
            <name>jlupin</name>
            <url>http://support.jlupin.com/maven2/</url>
        </pluginRepository>
    </pluginRepositories>

    <!--
        Some settings are moved to properties for simple usage inside child
        pom.xml files.
    -->

    <properties>
        <jlupin.platform.version>1.5.0.0</jlupin.platform.version>
        <jlupin.platform.maven.plugin.version>1.5.0.0</jlupin.platform.maven.plugin.version>
        <jlupin.servlet.monitor.version>1.5.0.0</jlupin.servlet.monitor.version>

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <!-- JLupin dependencies -->
        <dependency>
            <groupId>com.jlupin</groupId>
            <artifactId>jlupin-client-assembly</artifactId>
            <version>${jlupin.platform.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.jlupin</groupId>
            <artifactId>jlupin-spring-boot-1-servlet-monitor</artifactId>
            <version>${jlupin.servlet.monitor.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.name}</finalName>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                JCS JLupin Platform Maven Plugin configuration for
                microservices.
            -->
            <plugin>
                <groupId>com.jlupin</groupId>
                <artifactId>jlupin-platform-maven-plugin</artifactId>
                <version>${jlupin.platform.maven.plugin.version}</version>
                <executions>
                    <!--
                        By default zip goal is bind to package phase. But
                        it is not configured with any additional files
                        directory. It is recommended to create such a
                        directory. Path provided here is relative to
                        pom.xml file for specific project (the one where
                        plugin is added to execute).
                    -->
                    <execution>
                        <id>jlupin-zip</id>
                        <goals>
                            <goal>zip</goal>
                        </goals>
                        <configuration>
                            <additionalFilesDirectories>
                                <param>../additional-files</param>
                            </additionalFilesDirectories>
                            <!-- including dependencies is handled by Spring BOOT itself -->
                            <includeDependenciesInZip>false</includeDependenciesInZip>
                        </configuration>
                    </execution>
                    <!--
                        By default deploy goal is not bind to any phase.
                        It is useful to execute it in a pre-integration-test
                        phase to deploy microservices to server where they
                        will be tested. By default they are deployed to
                        127.0.0.1 server with transmission port 9096.
                    -->
                    <execution>
                        <id>jlupin-deploy</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>