<commit_before># Building

Waltz is built using maven.

## Prerequisites

- Git
- Maven 3
- JDK 8
- Liquibase (recommended but not essential)
- Node
- Sass
- Database - either
  - MariaDB
  - Microsoft SQL Server
- _jOOQ Pro_ (if using Microsoft SQL Server) 

## Obtaining the code

It is recommended that you clone the repository on GitHub to maintain your own fork and pull in changes as required.

## Preparing the database

For Mariadb create a new database:
```
mysql -u root -e "create database IF NOT EXISTS waltz CHARACTER SET='utf8';"
```

When you run the first build (using `mvn package`) the schema will be generated using the liquibase maven task (ref: `waltz-schema/pom.xml`).  

## Setting up maven profiles

Waltz uses maven profiles to target the build against the correct database.  Generic db vendor settings are located in  
the profiles section of `<REPO>/waltz-schema/pom.xml` and should not need to be changed.

Specific database connection details should be configure in the 
`~/.m2/settings.xml` file.  An example (for both MariaDB and Microsoft 
SQL Server) would look like:

```xml
<settings>
    <profiles>
        <!--
        these profile are used to provide db connection details
        so that the jOOQ code generator can run.
        -->

        <profile>
            <id>dev-maria</id>
            <properties>
                <database.url>jdbc:mysql://dbhost:3306/waltzdb</database.url>
                <database.user>dbuser</database.user>
                <database.password><PASSWORD></database.password>
                <database.schema>waltz</database.schema>
            </properties>
        </profile>
        <profile>
            <id>dev-mssql</id>
            <properties>
                <database.url>jdbc:sqlserver://dbhost:1433;databaseName=waltzdb</database.url>
                <database.user>dbuser</database.user>
                <database.password><PASSWORD></database.password>
                <database.schema>dbschema</database.schema>
            </properties>
        </profile>
    </profiles>
</settings>
```


## Running the build

Typically one of two maven targets is executed.  For the first run (and whenever schema updates are required) then a full `package` build should be executed.  For code only change then the quicker `compile` target can be used.

When running either variant you must provide the names of two profiles, firstly the generic database profile (either `waltz-mariadb` or `waltz-mssql`) and the specific profile created in your `~.m2/settings.xml` file (in the example above either `dev-maria` or `dev-mssql`).

### Examples (using aliases)

Below are some example maven command lines.  We typically register the command as an alias to save time.

```
alias compile-maria='mvn clean compile -P waltz-mariadb,dev-maria'<commit_msg>Update build.md<commit_after># Building

Waltz is built using maven.

## Prerequisites

- Git
- Maven 3
- JDK 8
- Liquibase (recommended but not essential)
- Node
- Sass
- Database - either
  - MariaDB
  - Microsoft SQL Server
- _jOOQ Pro_ (if using Microsoft SQL Server) 

## Obtaining the code

It is recommended that you clone the repository on GitHub to maintain your own fork and pull in changes as required.

## Preparing the database

For Mariadb create a new database:
```
mysql -u root -e "create database IF NOT EXISTS waltz CHARACTER SET='utf8';"
```

When you run the first build (using `mvn package`) the schema will be generated using the liquibase maven task (ref: `waltz-schema/pom.xml`).  

## Setting up maven profiles

Waltz uses maven profiles to target the build against the correct database.  Generic db vendor settings are located in  
the profiles section of `<REPO>/waltz-schema/pom.xml` and should not need to be changed.

Specific database connection details should be configure in the 
`~/.m2/settings.xml` file.  An example (for both MariaDB and Microsoft 
SQL Server) would look like:

```xml
<settings>
    <profiles>
        <!--
        these profile are used to provide db connection details
        so that the jOOQ code generator can run.
        -->

        <profile>
            <id>dev-maria</id>
            <properties>
                <database.url>jdbc:mysql://dbhost:3306/waltzdb</database.url>
                <database.user>dbuser</database.user>
                <database.password><PASSWORD></database.password>
                <database.schema>waltz</database.schema>
            </properties>
        </profile>
        <profile>
            <id>dev-mssql</id>
            <properties>
                <database.url>jdbc:sqlserver://dbhost:1433;databaseName=waltzdb</database.url>
                <database.user>dbuser</database.user>
                <database.password><PASSWORD>>
                <database.schema>dbschema</database.schema>
                <database.catalog>watlzdb</database.catalog> <!-- only req'd for code gen w/ mssql -->
            </properties>
        </profile>
    </profiles>
</settings>
```


## Running the build

Typically one of two maven targets is executed.  For the first run (and whenever schema updates are required) then a full `package` build should be executed.  For code only change then the quicker `compile` target can be used.

When running either variant you must provide the names of two profiles, firstly the generic database profile (either `waltz-mariadb` or `waltz-mssql`) and the specific profile created in your `~.m2/settings.xml` file (in the example above either `dev-maria` or `dev-mssql`).

### Examples (using aliases)

Below are some example maven command lines.  We typically register the command as an alias to save time.

```
alias compile-maria='mvn clean compile -P waltz-mariadb,dev-maria'
{'fraction_non_alphanumeric': 0.09325881942018861, 'fraction_numerical': 0.0045406915822563745, 'mean_word_length': 2.8617666891436278, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '6761951', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1600, 'n_words': 614}