<commit_before># Maven Package Type For FSMs [![Build Status](https://travis-ci.org/zaplatynski/fsm-packagetype.svg?branch=master)](https://travis-ci.org/zaplatynski/fsm-packagetype) [![Coverage Status](https://coveralls.io/repos/github/zaplatynski/fsm-packagetype/badge.svg)](https://coveralls.io/github/zaplatynski/fsm-packagetype) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.zaplatynski/fsm-packagetype/badge.svg?style=flat)](http://mvnrepository.com/artifact/com.github.zaplatynski/fsm-packagetype)

This is a basic approach to create a Maven package type for FirstSpirit modules (FSM) with a 
fully working Maven lifecycle inclung install and deploy. Additionally there is support to crate 
the FSM deployment descriptor called module.xml. For information please consult the official 
documentations.

## How to use

In your `pom.xml` add this:
```xml
<project>

    <groupId>my-group</groupId>
    <artifactId>my-fsm-artifact</artifactId>
    <version>1.2.3</version>
    
    <!-- NEW: make a FSM file -->
    <packaging>fsm</packaging>

    ...
    <build>
    
        <plugins>
            
            <!-- make new FSM package type available to Maven -->
            <plugin>
                <groupId>com.github.zaplatynski</groupId>
                <artifactId>fsm-packagetype</artifactId>
                <version>2.2.1</version>
                <!-- this is important when extending core Maven functionality: -->
                <extensions>true</extensions>
            </plugin>
            
            <!-- define how the FSM file look like -->
             <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <attach>false</attach>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/assembly/fsm.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
            
        </plugins>    
        ...
    </build>
</project>
```
To create the `module.xml` (FirstSpirit module deployment descriptor) you must provide a `module
.vm` ([Apache Velocity macro](http://velocity.apache.org/engine/devel/user-guide.html)) in the path `src/main/fsm` with content:
```
#defaultModuleXml($project)
```
The example (see [macros.vm](src/main/resources/macros.vm)) above will add the common tags for 
name, version etc. (sub macro #addHeader) and collect module fragment xml if avaiable
(sub macro #addModuleXmlFragments). Besides those three macros the variable $project give access 
to the whole
[Maven project](https://maven.apache.org/ref/3.2.3/apidocs/org/apache/maven/project/MavenProject.html).
In addition all user defined Maven properties are available too. Since Velocity can not deal with dots in variable names please name them accordingly.

### FirstSpirit Mode Isolated

To enable FirstSpirit upcoming mode insolated inside the module deployment descriptor simply add 
this property to your pom.xml:

```xml
<project>
    ...
    <properties>
        ...
        <fsmode>isolated</fsmode>
        ...
    </properties>
    ...
</project>
```
The default Velocity macros will recognized it and create the the following xml inside resource 
tags:
```xml
<module>
    ...
    <components>
    ...
    <resources>
        ...
        <resource mode="isolated" ... />
        ...
    </resources>
    ...
    </components>
    ...
</module>
```

### Module Deployment Descriptor Fragment

To create an module fragment xml in any other jar Maven module just this to the `pom.xml`:
```xml
</project>
...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>com.github.zaplatynski</groupId>
                <artifactId>fsm-packagetype</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>fragmentModuleXml</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...
        </plugins>
    </build>
...
</project>
```
Again in the `src/main/fsm` there must be an in the path `module-fragment.vm` in which you can 
define e.g. an FirstSpirit Executable or Service.

### FSM Layout

Inside the above mentioned `fsm.xml` you need to specify the [Maven assembly plugin](http://maven.apache.org/plugins/maven-assembly-plugin/) descriptor to create a typical FSM file layout:
```xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
    <id>fsm</id>
    <formats>
        <format>zip</format>
    </formats><commit_msg>Update Readme (fix some smaller bugs)<commit_after># Maven Package Type For FSMs [![Build Status](https://travis-ci.org/zaplatynski/fsm-packagetype.svg?branch=master)](https://travis-ci.org/zaplatynski/fsm-packagetype) [![Coverage Status](https://coveralls.io/repos/github/zaplatynski/fsm-packagetype/badge.svg)](https://coveralls.io/github/zaplatynski/fsm-packagetype) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.zaplatynski/fsm-packagetype/badge.svg?style=flat)](http://mvnrepository.com/artifact/com.github.zaplatynski/fsm-packagetype)

This is a basic approach to create a Maven package type for FirstSpirit modules (FSM) with a 
fully working Maven lifecycle inclung install and deploy. Additionally there is support to crate 
the FSM deployment descriptor called module.xml. For information please consult the official 
documentations.

## How to use

In your `pom.xml` add this:
```xml
<project>

    <groupId>my-group</groupId>
    <artifactId>my-fsm-artifact</artifactId>
    <version>1.2.3</version>
    
    <!-- NEW: make a FSM file -->
    <packaging>fsm</packaging>

    ...
    <build>
    
        <plugins>
            
            <!-- make new FSM package type available to Maven -->
            <plugin>
                <groupId>com.github.zaplatynski</groupId>
                <artifactId>fsm-packagetype</artifactId>
                <version>2.2.1</version>
                <!-- this is important when extending core Maven functionality: -->
                <extensions>true</extensions>
            </plugin>
            
            <!-- define how the FSM file look like -->
             <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <attach>false</attach>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/assembly/fsm.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
            
        </plugins>    
        ...
    </build>
</project>
```
To create the `module.xml` (FirstSpirit module deployment descriptor) you must provide a `module
.vm` ([Apache Velocity macro](http://velocity.apache.org/engine/devel/user-guide.html)) in the path `src/main/fsm` with content:
```
#defaultModuleXml($project)
```
The example (see [macros.vm](src/main/resources/macros.vm)) above will add the common tags for 
name, version etc. (sub macro #addHeader) and collect module fragment xml if avaiable
(sub macro #addModuleXmlFragments). Besides those three macros the variable $project give access 
to the whole
[Maven project](https://maven.apache.org/ref/3.2.3/apidocs/org/apache/maven/project/MavenProject.html).
In addition all user defined Maven properties are available too. Since Velocity can not deal with dots in variable names please name them accordingly.

### FirstSpirit Mode Isolated

To enable FirstSpirit upcoming mode insolated inside the module deployment descriptor simply add 
this property to your pom.xml:

```xml
<project>
    ...
    <properties>
        ...
        <fsmode>isolated</fsmode>
        ...
    </properties>
    ...
</project>
```
The default Velocity macros will recognized it and create the the following attribute inside resource 
tags:
```xml
<module>
    ...
    <components>
    ...
    <resources>
        ...
        <resource mode="isolated" ... />
        ...
    </resources>
    ...
    </components>
    ...
</module>
```

### Module Deployment Descriptor Fragment

To create an module fragment xml in any other jar Maven module just this to the `pom.xml`:
```xml
</project>
...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>com.github.zaplatynski</groupId>
                <artifactId>fsm-packagetype</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>fragmentModuleXml</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...
        </plugins>
    </build>
...
</project>
```
Again in the `src/main/fsm` there must be an in the path `module-fragment.vm` in which you can 
define e.g. an FirstSpirit Executable or Service.

### FSM Layout

Inside the above mentioned `fsm.xml` you need to specify the [Maven assembly plugin](http://maven.apache.org/plugins/maven-assembly-plugin/) descriptor to create a typical FSM file layout:
```xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
    <id>fsm</id>
    <formats>
        <format>zip</format>
    </formats>
{'fraction_non_alphanumeric': 0.12643910321147242, 'fraction_numerical': 0.005655423146839022, 'mean_word_length': 2.2511490479317136, 'pattern_counts': {'":': 0, '<': 175, '<?xml version=': 0, '>': 175, 'https://': 12, 'lorem ipsum': 0, 'www.': 2, 'xml': 33}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '433311', 'n_tokens_mistral': 3030, 'n_tokens_neox': 2816, 'n_words': 718}