viernes, 5 de septiembre de 2014

Terracotta Projects with maven


I wanted this to be a SOA blog, but in my free time i do some other stuff.

I had been working for some time with the terracotta server. My idea was to share JAVA objects between several virtual machines.

The thing i want to share was simply some maven instructions to start, stop and create the boot-jar (i have lots of problem trying to use their maven plugin)

I just copy all the pom.xml. The only remark about this pom, is that i needed to run the terracotta server in linux and Windows, so i had to create a profile to distinguish between the two enviroments. (There are some OS specific properties)

** The inputs, are the terracotta home, and the config file for the project. I configure a node inside the config file called "MasterNode".

<?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>testproject.groupId</groupId>
    <artifactId>TestProject</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>TestProject</name>
  
    <profiles>
        <profile>
            <id>Windows</id>
            <activation>
                <os>
                    <family>Windows</family>
                </os>
            </activation>
            <properties>
                <scritp.ext>bat</scritp.ext>
                <tc.home>D:\terracotta-3.7.7</tc.home>
                <tc.conf.file>${basedir}\src\main\resources\Terracotta\tc-config_win.xml</tc.conf.file>
            </properties>
        </profile>
        <profile>
            <id>unix</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <scritp.ext>sh</scritp.ext>
                <tc.home>/Users/user/terracotta-3.7.7</tc.home>
                <tc.conf.file>${basedir}/src/main/resources/Terracotta/tc-config_unix.xml</tc.conf.file>
            </properties>
        </profile>
        <profile>
            <id>tc-start</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>exec-maven-plugin</artifactId>
                        <groupId>org.codehaus.mojo</groupId>
                        <version>1.3.2</version>
                        <executions>
                            <execution>
                                <id>tc-start</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${tc.home}${file.separator}bin${file.separator}start-tc-server.${scritp.ext}</executable>
                                    <arguments>
                                        <argument>-n</argument>
                                        <argument>MasterNode</argument>
                                        <argument>-f</argument>
                                        <argument>${tc.conf.file}</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>              
                </plugins>
            </build>
        </profile>
        <profile>
            <id>tc-stop</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>exec-maven-plugin</artifactId>
                        <groupId>org.codehaus.mojo</groupId>
                        <version>1.3.2</version>
                        <executions>
                            <execution>
                                <id>tc-stop</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${tc.home}${file.separator}bin${file.separator}stop-tc-server.${scritp.ext}</executable>
                                    <arguments>
                                        <argument>-n</argument>
                                        <argument>MasterNode</argument>
                                        <argument>-f</argument>
                                        <argument>${tc.conf.file}</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>              
                </plugins>
            </build>
        </profile>
        <profile>
            <id>tc-boot-jar</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>exec-maven-plugin</artifactId>
                        <groupId>org.codehaus.mojo</groupId>
                        <version>1.3.2</version>
                        <executions>
                            <execution>
                                <id>tc-boot-jar</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${tc.home}${file.separator}platform${file.separator}bin${file.separator}make-boot-jar.${scritp.ext}</executable>
                                    <arguments>
                                        <argument>-f</argument>
                                        <argument>${tc.conf.file}</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>              
                </plugins>
            </build>
        </profile>        
    </profiles>
</project>