> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Building and deploying the Solution

## Building the project

### Set up Artifactory access

You can download all Maven dependencies from Artifactory by setting up your Maven settings file:

```xml theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
<settings>
    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <repositories>
                <repository>
                    <id>ActiveViamMvn</id>
                    <name>ActiveViam Maven Repository</name>
                    <url>https://activeviam.jfrog.io/artifactory/mvn/</url>
                </repository>
                <repository>
                    <id>ActiveViamGeneric</id>
                    <name>ActiveViam Generic Repository</name>
                    <url>https://activeviam.jfrog.io/artifactory/generic/</url>
                </repository>
            </repositories>
        </profile>
    </profiles>

    <servers>
        <server>
            <id>ActiveViamMvn</id>
            <username>username</username>
            <password>password</password>
        </server>
        <server>
            <id>ActiveViamGeneric</id>
            <username>username</username>
            <password>password</password>
        </server>
    </servers>
</settings>
```

To download the dependencies for the UI, you need to set up access to Artifactory via npm:

`npm login --scope @activeviam --registry https://activeviam.jfrog.io/artifactory/npm/`

The result is the following message:

`Logged in as username to scope @activeviam on https://activeviam.jfrog.io/artifactory/npm/.`

If the scope isn't mentioned in the message, change the command to the following:

`npm login --scope=@activeviam --registry=https://activeviam.jfrog.io/artifactory/npm/`

### Source

Download and unzip the source zip from the [Artifactory](https://activeviam.jfrog.io/artifactory/generic/simm/) page.

### Build

<Note>
  **Java 17 support**

  The Solution can be run within a Java 17 JVM. Some functionality in the full application and in the regressions tests requires deep reflection access to Java packages. To enable access, please use the following JVM parameters, either through the command line or maven surefire/failsafe configuration.

  ```java theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
  --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
  --add-opens=java.base/java.nio=ALL-UNNAMED
  ```

  Atoti ISDA-SIMM also works in a Java 11 JVM.
</Note>

1. Once you have added all the maven repositories and extracted the
   source code, run `mvn install` on the parent pom file to build the
   entire project.

   This will build the Atoti Server executable JAR file
   (simm-starter/target/simm-starter-exec.jar), ActiveMonitor executable
   JAR file
   (*simm-activemonitor/target/simm-activemonitor-2.0.2-exec.jar*) .

2. When the build is complete, you must deploy it. See
   [Deployment](#Deployment).

3. Build the standalone UI application using npm or yarn.

4. Deploy the UI application.

## Configuration

The only configuration required to start is to edit `simm-starter/src/main/resources/properties/simm.properties`

Set `input.data.root.dir.path` to the directory you want to put your data.

For more details, see [Project configuration](./configuration-project).

### Alternatives

1. If you only want to use the sample data embedded in the project along with the Jetty server, then you don't need to configure the data directory.
2. You can copy the sample data (`simm-starter/src/test/resources/data-samples/data/`) into `simm-starter/src/main/resources/` then the sample data will be included in the .jar file and you won't need to set the data directory.

## <span id="Deployment" />Deployment

### Atoti Server and ActiveMonitor

`simm-starter` and `simm-activemonitor` are Spring Boot applications that build to an executable JAR. To deploy the
executable JAR files, simply use the following commands:

```syntaxhighlighter-pre theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
java -jar simm-starter-exec.jar
```

and

```syntaxhighlighter-pre theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
java -jar simm-activemonitor-2.0.2-exec.jar
```

<Note>
  Each executable JAR will publish the application on a
  different port. The default port for simm-starter is 12000, and for
  simm-activemonitor is 12001.

  Atoti Server will be available at: *http\://\<your
  hostname>:12000/simm-starter/*

  ActiveMonitor will be available at: *http\://\<your
  hostname>:12001/simm-activemonitor/*
</Note>

You can change the port by either of the following:

* Use the argument `server.port`.

  For example:

  ```
  java --add-opens java.base/java.util.concurrent=ALL-UNNAMED -jar simm-starter-exec.jar --server.port=<port>
  ```

* Externalize the properties files (see [Externalizing Properties
  Files](#Externalizing_Properties_Files) )

#### \[Eclipse / IntelliJ]

* Use maven to run an initial build of the Solution `$ mvn clean install`.
* Start the server by running `SimmWebApplication.java` in `simm-starter/src/java/com/activeviam/simm/starter`.
* The server will run at [https://localhost:12000/simm-starter](https://localhost:12000/simm-starter)
* You will need to compile and serve up the ui from the ui source code, as described in the [Atoti UI](#atoti-ui) section below.

### Atoti UI

Atoti UI is a static website that can be deployed in any way you see
fit. All the necessary files are to be found in the *./build* folder of
the standalone application after the project has been built.

As an example, the UI can be deployed on Tomcat using the following
instructions:

1. Build the standalone application:

   1. Set up artifactory access for node dependencies
   2. Download the ui source code from [artifactory](https://activeviam.jfrog.io/artifactory/generic/simm/).
   3. Copy the lockfile for the build tool you use (i.e. package-lock.json for npm, yarn.lock for yarn) into the project's main directory.
   4. Run `npm ci` if using npm, or `yarn install --frozen-lockfile` if using yarn.
   5. Run `npm run build` if using npm, or `yarn build` if using yarn.

2. Place the deployment in the *webapps* folder of your Tomcat:

   1. Find where the *webapps* folder is for your Tomcat.
   2. Create a folder called *simm-activeui* in the Tomcat *webapps*
      folder.
   3. Copy the contents from the build folder into your new folder
      *webapps/simm-activeui/*.

3. Start the Tomcat server. You can now access the UI on the
   address *http\://\<your hostname>:\<port>/simm-activeui/.*

For details on how to configure the UI, see [Configuring the UI](../dev-ui-config).

## How to run all tests

`mvn clean install -P IT`

## <span id="Externalizing_Properties_Files" />Externalizing Properties Files

In the default implementation, all the necessary properties are within
the project. A number of properties files have been externalized and can
be overridden with an external file using JVM variables. You may wish to
use this functionality if you are running the project in different
environments. Below is a list of the files together with their
respective variable names:

There are three options to override default properties:

* OPTION 1: Command line arguments, e.g.`<span class="measure"> --csvSource.dataset=/path/to/folder</span>` .

<Note>We use "--" to set properties with Spring Boot.</Note>

* OPTION 2: Create a properties file (e.g. `<span
  class="measure">application.properties</span>)` and add your property
  overrides. Then pass it to the main using the command line argument `<span class="measure">--spring.config.additional-location=/&lt;path&gt; application.properties</span>`

* OPTION 3: Change the path to the default properties file using the
  appropriate variable specified below:

  | File                 | Variable Name                      |
  | -------------------- | ---------------------------------- |
  | simm.properties      | app.env.properties.file.path       |
  | hibernate.properties | hibernate.env.properties.file.path |

  If any of the above variables are not set, the default properties
  files will be used.

  Example values for these properties files include:

  * classpath:\<filename>

  * file:/home/etc/\<filename>; - Unix Environment

  * file:///C:/Users/john/config/\<filename> - Windows
    environment

<Tip>
  Options 1 and 2 are recommended because they only override the
  properties you specify and use the defaults for other ones.
  Additionally, they can be used to override any property.

  Option 3 only works for specific properties files (i.e. the ones
  specified in the table above), and replaces the default file completely,
  meaning you need to make a copy of the default file and have all
  properties in your external custom file even if they have the same value
  as the default file.
</Tip>
