diff --git a/.jenkins/Dockerfile b/.jenkins/Dockerfile new file mode 100644 index 00000000..e0d58564 --- /dev/null +++ b/.jenkins/Dockerfile @@ -0,0 +1,106 @@ +# Base image: Ubuntu 20.04 +FROM ubuntu:20.04 +LABEL maintainer="CPSWT Team" + +# Set it to noninteractive mode +ARG DEBIAN_FRONTEND=noninteractive + +# Install necessary packages +RUN apt-get update && \ + apt-get install -y \ + apt-transport-https \ + bison \ + build-essential \ + ca-certificates \ + clang \ + curl \ + doxygen \ + flex \ + gcc \ + gdb \ + git \ + graphviz \ + libboost1.71-all-dev \ + libcppunit-dev \ + libjsoncpp-dev \ + libosgearth-dev \ + libqt5opengl5-dev \ + libwebkit2gtk-4.0-37 \ + libxml2-dev \ + lld \ + make \ + mongodb \ + mpi-default-dev \ + netcat \ + openjdk-8-jdk \ + openjdk-17-jdk \ + openscenegraph-plugin-osgearth \ + perl \ + python2 \ + python3 \ + python3-pip \ + python-is-python2 \ + qt5-qmake \ + qtbase5-dev \ + qtbase5-dev-tools \ + qtchooser \ + software-properties-common \ + wget \ + xterm \ + zlib1g-dev \ + unzip \ + zip + +#install Gradle +ARG GRADLE_VERSION=7.5 +RUN wget -O gradle.zip https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip && \ + mkdir /opt/gradle && \ + unzip -d /opt/gradle gradle.zip && \ + rm gradle.zip +# Set Gradle in the environment variables +ENV GRADLE_HOME="/opt/gradle/gradle-${GRADLE_VERSION}" +ENV PATH="${GRADLE_HOME}/bin:${PATH}" + +# Install Python packages +RUN python3 -m pip install --system --upgrade \ + jinja2 \ + matplotlib \ + numpy \ + pandas \ + posix_ipc \ + scipy \ + seaborn \ + webgme-bindings + +# Download and extract portico +WORKDIR /home +RUN wget -O portico.tar.gz https://master.dl.sourceforge.net/project/portico/Portico/portico-2.1.0/portico-2.1.0-linux64.tar.gz?viasf=1 && \ + tar xf portico.tar.gz && \ + rm portico.tar.gz +ENV RTI_HOME="/home/portico-2.1.0" + +# Download and set up Apache Archiva +WORKDIR /opt +RUN wget -O archiva.tar.gz https://archive.apache.org/dist/archiva/2.2.5/binaries/apache-archiva-2.2.5-bin.tar.gz && \ + tar xf archiva.tar.gz && \ + rm archiva.tar.gz + +# Expose the Archiva port +EXPOSE 8080/tcp + +# Use SIGINT for stopping +STOPSIGNAL SIGINT + +# Set up Gradle properties +COPY gradle.properties /root/.gradle/ +RUN chmod 600 /root/.gradle/gradle.properties + +# Clone and build CPSWT packages +RUN mkdir /home/cpswt +COPY experiment_wrapper.sh /home/cpswt + +WORKDIR /home/cpswt +# Start Archiva +CMD [ "/usr/bin/bash", "experiment_wrapper.sh" ] +# CMD [ "/usr/bin/bash" ] + diff --git a/.jenkins/Jenkinsfile b/.jenkins/Jenkinsfile new file mode 100644 index 00000000..1afaf90f --- /dev/null +++ b/.jenkins/Jenkinsfile @@ -0,0 +1,74 @@ +// Do NOT place within the pipeline block +properties([ [ $class: 'ThrottleJobProperty', + categories: ['ci_cpswt_build'], + limitOneJobWithMatchingParams: false, + maxConcurrentPerNode: 1, + maxConcurrentTotal: 1, + paramsToUseForLimit: '', + throttleEnabled: true, + throttleOption: 'category' ] ]) + +pipeline { + agent any + triggers { + pollSCM('*/1 * * * *') // poll the SCM every 1 minutes + } + + stages { + stage('Clone repository') { + steps { + echo 'Cloning Forked CPSWT-Core..' + deleteDir() // Delete workspace before cloning + sh 'git clone git@github.com:justinyeh1995/CI_with_Jenkins.git' + } + } + stage('Build image') { + steps { + echo 'Start a Docker Container for this experiment, which should start the experiment and a archiva server, a inet server, and a omnet++ server..' + dir("CI_with_Jenkins/cpswt-core") { + sh 'docker build -t cpswt-core:latest -f Dockerfile .' + } + } + } + stage('Deploy image') { + steps { + echo 'Run the Docker Container inside Jenkins container' + sh 'docker run \ + --name cpswt-core \ + -p 8081:8080 \ + cpswt-core:latest' + } + } + stage('Wait for container to stop') { + options { + timeout(time: 30, unit: 'MINUTES') + } + steps { + echo 'Wait for container to stop' + sh 'docker wait cpswt-core' + } + } + stage('Archive loggings') { + steps { + echo 'Archiving the results...' + sh 'docker logs cpswt-core > cpswt-core.log' + archiveArtifacts artifacts: 'cpswt-core.log', fingerprint: true + } + } + } + + post { + always { + echo 'This will always run' + emailext body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}", + recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']], + subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}", + attachLog: true, + attachmentsPattern: 'cpswt-core.log' + echo 'Tearing Down the image & container....' + sh 'docker rm -f cpswt-core' + sh 'docker rmi cpswt-core:latest' + sh 'rm -rf cpswt-core' + } + } +} diff --git a/.jenkins/experiment_wrapper.sh b/.jenkins/experiment_wrapper.sh new file mode 100644 index 00000000..20dee147 --- /dev/null +++ b/.jenkins/experiment_wrapper.sh @@ -0,0 +1,104 @@ +# this script is used to build cpswt-core and its dependencies in the docker container +ORIGINAL_PATH=$PATH +export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 +export PATH=$JAVA_HOME/bin:$PATH + +/opt/apache-archiva-2.2.5/bin/archiva start + +# wait for archiva to start +# wait for archiva to start +echo "Waiting archiva to launch on 8080..." + +while ! nc -z localhost 8080; do + sleep 0.1 # wait for 1/10 of the second before check again +done + +echo "archiva launched" + +# create admin user +curl --no-progress-meter -X POST -H "Content-Type: application/json" -H "Origin: http://localhost:8080" -d @- \ + http://localhost:8080/restServices/redbackServices/userService/createAdminUser <<'TERMINUS' +{ + "username": "admin", + "password": "adminpass123", + "email": "admin@archiva-test.org", + "fullName": "Admin", + "locked": false, + "passwordChangeRequired": false, + "permanent": false, + "readOnly": false, + "validated": true, + "confirmPassword": "adminpass123" +} +TERMINUS + +# disable rest.csrffilter.enabled in archiva.xml +sed -i '//,/<\/csrffilter>/s/true/false/' /opt/apache-archiva-2.2.5/conf/archiva.xml +# sed -i 's//http:\/\/129.59.107.97\/archiva-core\/<\/baseUrl>/' /opt/apache-archiva-2.2.5/conf/archiva.xml + +# # restart archiva +/opt/apache-archiva-2.2.5/bin/archiva stop +/opt/apache-archiva-2.2.5/bin/archiva start + +echo "Waiting archiva to launch again on 8080..." + +while ! nc -z localhost 8080; do + sleep 0.1 # wait for 1/10 of the second before check again +done + +echo "archiva launched again" + +# switch to java 17 +unset JAVA_HOME +export JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64 +export PATH=$JAVA_HOME/bin:$ORIGINAL_PATH + +# clone cpswt-core and build it +cd /home/cpswt +git clone https://github.com/SimIntToolkit/cpswt-core.git +cd cpswt-core/cpswt-core + +gradle wrapper --gradle-version=8.0 + +ARCHIVA_REPO_URL="http://localhost:8080/repository/snapshots/0.8.0-SNAPSHOT/" + +# sh ./cpswt-redeploy.sh +./gradlew :utils:build --rerun-tasks --refresh-dependencies +./gradlew :utils:publish +echo "utils published" + +./gradlew :root:build --rerun-tasks --refresh-dependencies +./gradlew :root:publish +echo "root published" + +./gradlew :base-events:build --rerun-tasks --refresh-dependencies +./gradlew :base-events:publish +echo "base-events published" + +./gradlew :config:build --rerun-tasks --refresh-dependencies +./gradlew :config:publish +echo "config published" + +./gradlew :federate-base:build --rerun-tasks --refresh-dependencies +./gradlew :federate-base:publish +echo "federate-base published" + +./gradlew :coa:build --rerun-tasks --refresh-dependencies +./gradlew :coa:publish +echo "coa published" + +./gradlew :federation-manager:build --rerun-tasks --refresh-dependencies +./gradlew :federation-manager:publish +echo "federation-manager published" + +./gradlew :fedmanager-host:build --rerun-tasks --refresh-dependencies +./gradlew :fedmanager-host:publish +echo "fedmanager-host published" + +# run the HelloWorldJava example +cd /home/cpswt/cpswt-core/examples/HelloWorldJava +gradle wrapper --gradle-version=8.0 +./gradlew :Source:build +./gradlew :Sink:build +./gradlew :PingCounter:build +./gradlew :runFederationBatch diff --git a/.jenkins/gradle.properties b/.jenkins/gradle.properties new file mode 100644 index 00000000..bbace050 --- /dev/null +++ b/.jenkins/gradle.properties @@ -0,0 +1,9 @@ +archivaUser=admin +archivaPassword=adminpass123 +archivaHostId=localhost +archivaPort=8080 +version=0.8.0-SNAPSHOT + +org.gradle.console=plain + +omnetppHome=/opt/omnetpp-5.6.2 diff --git a/README.md b/README.md index e843274f..84ddb029 100644 --- a/README.md +++ b/README.md @@ -1,81 +1,468 @@ -# CPSWT Java Core +# Project `"cpswt-core"` for CPSWT -The core implementation of the Cyber-Physical Systems Wind Tunnel (CPSWT), including integration of Java federates, -the federation manager, and COA management. +The cpswt-core project contains all software needed to run Java-based federates in CPSWT. -Any Java-based federate will use the classes in this repository in order to execute. +> ##### Table of Contents +> +> * [Project `"cpswt-core"` for CPSWT](#project-cpswt-core-for-cpswt) +> * [Constituent Modules](#constituent-modules) +> * [cpswt-core/root](#cpswt-core-root) +> * [cpswt-core/base-events](#cpswt-core-base-events) +> * [cpswt-core/coa](#cpswt-core-coa) +> * [cpswt-core/config](#cpswt-core-config) +> * [cpswt-core/federate-base](#cpswt-core-federate-base) +> * [cpswt-core/federation-manager](#cpswt-core-federation-manager) +> * [cpswt-core/utils](#cpswt-core-utils) +> * [CPSWT Software Installation and Instructions to Build and Publish cpswt-core Modules on Ubuntu 20.04 LTS (Focal Fossa)](#cpswt-software-installation-and-instructions-to-build-and-publish-cpswt-core-modules-on-ubuntu-20-04-lts-focal-fossa) +> * [General Software Installation](#general-software-installation) +> * [Install Needed Packages](#install-needed-packages) +> * [Install Portico 2.1.0](#install-portico-2-1-0) +> * [Install Apache Archiva version 2.2.5](#install-apache-archiva-version-2-2-5) +> * [Software for Java-based Federates](#software-for-java-based-federates) +> * [Working with Gradle](#working-with-gradle) +> * [Build CPSWT Java Packages and Publish to Archiva](#build-cpswt-java-packages-and-publish-to-archiva) -The primary projects relating to CPSWT functionality are as follows. Any projects not listed are under development -or are not currently being used. +## Constituent Modules -## cpswt-core/root: +`cpswt-core` contains the core modules for the implementation of the Cyber-Physical Systems Wind Tunnel (CPSWT). +In particular, it contains modules to allows Java-based federates to participate in federations, +the federation manager module which is responsible for coordinating federation execution, and a +module for COA management. -This project contains the Java base classes for Java classes that implement HLA interaction and object classes in CPSWT. -These Java base classes, **InteractionRoot** and **ObjectRoot**, actually contain all of the functionality needed to implement *any* HLA interaction or object class. -As such, they allow Java-based federates to use *dynamic messaging*: this enables the federates to manipulate any HLA interaction or object class instance using only -the InteractionRoot or ObjectRoot Java class, respectively. That is, an HLA interaction or object instance can be manipulated *without* an explicit corresponding Java class. +The modules used for CPSWT functionality are as follows. Any modules not listed are under development or are not currently being used. -## cpswt-core/base-events: -CPSWT comes with a set of built-in HLA interaction and object classes that are derived from InteractionRoot and ObjectRoot. These are (indentation shows inheritance): +### cpswt-core/root + +This module contains the Java base classes for Java classes that implement HLA interaction and object classes in +CPSWT. These Java base classes, **InteractionRoot** and **ObjectRoot**, actually contain all of the functionality +needed to implement *any* HLA interaction or object class in Java. Importantly, they allow Java-based federates to use +*dynamic messaging*: this enables the federates to manipulate any HLA interaction or object class instance using only +the InteractionRoot or ObjectRoot Java base classes, respectively. That is, an HLA interaction or object instance +can be manipulated without an explicit corresponding Java class. + +### cpswt-core/base-events + +The modules contains HLA interaction and object classes that are “built-in” to CPSWT. These classes are derived from InteractionRoot and ObjectRoot. + +**Class List (indentation shows inheritance):** HLA Interactions: - InteractionRoot - C2WInteractionRoot - ActionBase - EmbeddedMessaging - FederateJoinInteraction - FederateResignInteraction - OutcomeBase - SimLog - VeryLowPrio - LowPrio - MediumPrio - HighPrio - SimulationControl - SimPause - SimResume - SimEnd +```default +InteractionRoot + C2WInteractionRoot + ActionBase + EmbeddedMessaging + FederateJoinInteraction + FederateResignInteraction + OutcomeBase + SimLog + VeryLowPrio + LowPrio + MediumPrio + HighPrio + SimulationControl + SimPause + SimResume + SimEnd +``` HLA Objects: - ObjectRoot - FederateObject +```default +ObjectRoot + FederateObject +``` + +### cpswt-core/coa + +This module contains the Java classes necessary to implement **Courses of Action (COA)**, +i.e. complex behavior that is designed into a federation via its federation model. + +### cpswt-core/config + +This module contains Java classes that determine the contents of federate configuration files, as well as read them. + +### cpswt-core/federate-base + +This module contain Java classes that implement behavior that all federates must have. Among them are: + +* **SynchronizedFederate** – the base class of all Java federates that are instantiated directly from their representation in a CPSWT model. +* **InteractionMappingBase** and **InteractionMappingManager** – classes that provide base functionality for Mapper federates. + +### cpswt-core/federation-manager + +This module contains the Java classes that implement the FederationManager, which: + +* Must be executed first for any federation +* Coordinates the execution of all federates in the federation so that they all initialize themselves and start + execution simultaneously. + +### cpswt-core/utils + +This module contains various utility classes used by the other modules. + + + +## CPSWT Software Installation and Instructions to Build and Publish cpswt-core Modules on Ubuntu 20.04 LTS (Focal Fossa) + +> ##### Table of Contents +> +> * [General Software Installation](#general-software-installation) +> * [Install Needed Packages](#install-needed-packages) +> * [Install Portico 2.1.0](#install-portico-2-1-0) +> * [Install Apache Archiva version 2.2.5](#install-apache-archiva-version-2-2-5) +> * [Software for Java-based Federates](#software-for-java-based-federates) +> * [Working with Gradle](#working-with-gradle) +> * [Build CPSWT Java Packages and Publish to Archiva](#build-cpswt-java-packages-and-publish-to-archiva) + +The following CPSWT installation instructions were performed on a VirtualBox VM with 128 GB Disk and 12GB RAM. + +Currently, only Ubuntu 20.04 LTS (Focal Fossa) is supported. + +#### NOTE +There are several text boxes in the instructions below that contain commands that you need to execute at the shell command-line. + +To copy any of these commands, hover over the textbox and a small “copy” button will appear at the right of the textbox +(two rounded rectangles, one on top of the other). Press this button, and the command will be copied to your +clipboard. + +Then, to paste the command in your shell, select your shell window and press SHIFT-CTRL-V. + +### General Software Installation + +This sections contains instructions for the installation of 3rd-party software that is needed to run CPSWT federations. + +#### Install Needed Packages + +1. After initial install of Ubuntu 20.04 LTS, be sure to upgrade all of the currently installed packages: + 1. Execute the following command to update the available packages for your Ubuntu installation: + ```bash + sudo apt update + ``` + 2. Execute the following command to upgrade all of the currently installed packages in your Ubuntu installation: + ```bash + sudo apt upgrade -y + ``` + + +1. The following packages must be installed: + * apt-transport-https + * bison + * build-essential + * ca-certificates + * clang + * curl + * doxygen + * flex + * gcc + * gdb + * git + * gradle + * graphviz + * libboost1.71-all-dev + * libcppunit-dev + * libjsoncpp-dev + * libosgearth-dev + * libqt5opengl5-dev + * libwebkit2gtk-4.0-37 + * libxml2-dev + * lld + * make + * mongodb + * mpi-default-dev + * openjdk-8-jdk + * openjdk-17-jdk + * openscenegraph-plugin-osgearth + * perl + * python2 + * python3 + * python3-pip + * python-is-python2 + * qt5-qmake + * qtbase5-dev + * qtbase5-dev-tools + * qtchooser + * software-properties-common + * wget + * xterm + * zlib1g-dev + + They can be installed with the following command: + ```bash + sudo apt install -y apt-transport-https bison build-essential ca-certificates clang curl doxygen flex gcc gdb git gradle graphviz libboost1.71-all-dev libcppunit-dev libjsoncpp-dev libosgearth-dev libqt5opengl5-dev libwebkit2gtk-4.0-37 libxml2-dev lld make mongodb mpi-default-dev openjdk-8-jdk openjdk-17-jdk openscenegraph-plugin-osgearth perl python2 python3 python3-pip python-is-python2 qt5-qmake qtbase5-dev qtbase5-dev-tools qtchooser software-properties-common wget xterm zlib1g-dev + ``` +2. The following python packages (for python3) must also be installed: + * jinja2 + * matplotlib + * numpy + * pandas + * posix_ipc + * python-dateutil + * scipy + * seaborn + * webgme-bindings + + They can be installed with the following command: + ```bash + sudo python3 -m pip install --system --upgrade jinja2 matplotlib numpy pandas posix_ipc python-dateutil scipy seaborn webgme-bindings + ``` +3. Set `java-17-openjdk-amd64` to be the default java used by your system by executing the following command: + ```bash + sudo update-java-alternatives -s java-1.17.0-openjdk-amd64 + ``` + + #### NOTE + Ignore any errors output by the above command. +4. There will be several modifications to your `.bashrc` file in these instructions. The first is set your `JAVA_HOME` to the directory of your + `Java` installation. + + Granted the `openjdk-17-jdk` package was installed in step 1, the following command should be appended to your `.bashrc` file in your home directory: + ```bash + export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 + ``` + + #### NOTE + To see a list of all environment variables that need to be defined or modified in your `.bashrc` file, + see environmentvariablesummary at the end of this document. + + + + #### NOTE + Whenever command is added in your `.bashrc` file, it will only have an effect when you spawn and use a new shell, and this effect is needed **immediately**. + So, whenever a command is added to your `.bashrc` in these instructions either: + * Kill your current shell, spawn a new one, and use this new shell to continue with these installation instructions. + * Type the command directly into your current shell, in this case + + *export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64*. + +#### Install Portico 2.1.0 + +1. As these instructions are being written, a compressed tarball to install Portico version 2.1.0 can be downloaded by typing the following + URL into your Google Chrome web brower. + ```bash + https://master.dl.sourceforge.net/project/portico/Portico/portico-2.1.0/portico-2.1.0-linux64.tar.gz?viasf=1 + ``` + + However, if this link does not work, you should be able to download the Portico version 2.1.0 as follows: + 1. Go to [https://porticoproject.org](https://porticoproject.org) using your Google Chrome web browser + 2. Click on `portico-2.1.0-linux64.tar.gz` at the right side of the resulting page, under `Linux 64-bit` and `May 6th` + 3. On the resulting page, click on `portico-2.1.0-linux64.tar.gz` + 4. The file `portico-2.1.0-linux64.tar.gz` should be downloaded into your `Downloads` directory under your home directory. +2. Execute the following commands to untar the `portico-2.1.0-linux64.tar.gz` tarball into your home directory: + ```bash + cd + tar xf /Downloads/portico-2.1.0-linux64.tar.gz + ``` +3. Append the following command to your `.bashrc` file: + ```bash + export RTI_HOME="/portico-2.1.0" + ``` + + After doing this [remember](#modify-environment) to either kill your current shell and spawn a new one or type this command into your current shell. + + #### NOTE + To see a list of all environment variables that need to be defined or modified in your `.bashrc` file, + see environmentvariablesummary + + + +#### Install Apache Archiva version 2.2.5 + +1. As these instructions are being written, a compressed tarball to install Apache Archiva version 2.2.5 can be downloaded by typing the following + URL into your Google Chrome web brower. + ```bash + https://archive.apache.org/dist/archiva/2.2.5/binaries/apache-archiva-2.2.5-bin.tar.gz + ``` + + However, if this link does not work, you should be able to download the Apache Archiva version 2.2.5 as follows: + 1. Go to [https://archiva.apache.org](https://archiva.apache.org) using your Google Chrome web browser + 2. Click on the `Introduction` menu item at the top of the resulting page + 3. On the resulting dropdown menu, click on `Downloads` + 4. In the `Previous Versions` section of the resulting page, click on `Apache Archiva Archives` + 5. On the resulting page, click on `2.2.5/` + 6. On the resulting page, click on `binaries/` + 7. On the resulting page, click on `apache-archiva-2.2.5-bin.tar.gz` + 8. The file `apache-archiva-2.2.5-bin.tar.gz` should be downloaded into your `Downloads` directory under your home directory. +2. Untar the `apache-archiva-2.2.5-bin.tar.gz` tarball into your `/opt` directory: + 1. Become `root` using the following command: + ```bash + sudo su - + ``` + 2. Change your current directory to the `/opt` directory: + ```bash + cd /opt + ``` + 3. Untar the `apache-archiva-2.2.5-bin.tar.gz` tarball: + ```bash + tar xf /Downloads/apache-archiva-2.2.5-bin.tar.gz + ``` + 4. DON’T EXIT OUT OF THE `root` USER ID YET – GO TO THE NEXT STEP BELOW +3. Start the Archiva server and set up Archiva to execute on boot: + 1. Edit the file `/etc/systemd/system/archiva.service` using your favorite editor *by executing the editor from the command-line, i.e. as root*. + It should not exist yet, and so should be created when you edit it. + 2. Place the following text in this file: + ```bash + [Unit] + Description=Archiva Server + Documentation=https://archiva.apache.org/docs/2.2.5/ + After=network.target + + [Service] + Type=forking + PIDFile=/opt/apache-archiva-2.2.5/logs/archiva.pid + WorkingDirectory=/opt/apache-archiva-2.2.5 + ExecStart=bash -ic "export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH ; exec /opt/apache-archiva-2.2.5/bin/archiva start" + ExecStop=/opt/apache-archiva-2.2.5/bin/archiva stop + + [Install] + WantedBy=multi-user.target + ``` + + > 1. Save the file and exit the editor + > 2. Type the following two commands at the root shell prompt: + > ```bash + > systemctl enable archiva + > systemctl start archiva + > ``` + > 3. Exit out of the `root` userid: + > ```bash + > exit + > ``` + > 4. The Archiva server should now be started and will start automatically on boot. +4. Test and set up the Archiva server: + 1. Using your Google Chrome web browser, go to [http://localhost:8080](http://localhost:8080). The resulting page should be the Archiva home page for your Archiva server. + > #### NOTE + > Archiva can take several seconds to start up. If your browser reports that it cannot load the page, or the page is taking a long time to load, + > wait 60 seconds (ample time) and try again. + 2. In the upper right-hand corner of you Archiva server’s home page, click `Create Admin User` + 3. On the resulting page, enter the following information: + * Username: `admin` + * Full Name: `` + * Password: `adminpass123` + * Confirm Password: `adminpass123` + * Email Address: `` + * Validated: `` + * Locked: `` + * Change password required: `` + 4. Press the `Save` button + 5. Archiva is good to go! + +#### NOTE +It is important that you use `admin` and `adminpass123` as your Archiva administrator username and password, respectively, +as they are used in other parts of these instructions. + +### Software for Java-based Federates + +The following instructions show how to install, build and publish software needed to use Java-based federates in CPSWT. + +#### Working with Gradle + +Gradle is the build tool the CPSWT project uses to build, test, and publish its software to the [installed Archiva repository on your system](#archiva-install). + +For Gradle to work properly in this capacity, the following steps must be performed: +1. Create the `.gradle` directory under your home directory, if it doesn’t already exist, by executing the following commands: + ```bash + cd + mkdir .gradle + ``` +2. Edit the /.gradle/gradle.properties file using your favorite editor and give it the contents below: + ```bash + archivaUser=admin + archivaPassword=adminpass123 + archivaHostId=localhost + archivaPort=8080 + version=0.8.0-SNAPSHOT -base-events contains the explicit corresponding Java class implementations for these HLA classes. + org.gradle.console=plain -**EmbeddedMessaging** is a very important class as it allows the use of embedded messaging. Embedded messaging is a -level of indirection in the sending of interactions and object updates, i.e. the embedded message interaction can -contain another interaction, or an object update, within it. In particular, this allows object-updates to -be propagated through a simulated network in a network federate. + omnetppHome=/opt/omnetpp-5.6.2 + ``` -## cpswt-core/coa + +3. IMPORTANT: to execute gradle to build/test/publish software, we will be using the `gradle wrapper` executable, which will reside in the directories + where we perform the building/testing/publishing. -This project contains the Java classes necessary to implement **Courses of Action (COA)**, i.e. behavior that is designed -into a federation via its federation model. + #### NOTE + DO NOT EXECUTE the following two commands below – they’re only there to show how to set up the `gradle wrapper` -## cpswt-core/config + 1. To set up the `gradle wrapper` executable, change to the given directory (this happens in a few places below) and execute the + following command in your shell: + ```default + gradle wrapper --gradle-version=8.0 + ``` + 2. To execute the gradle-wrapper, use the following command while in the given directory: + ```default + ./gradlew [arguments] + ``` -This project contains Java classes that read federate configuration files +#### Build CPSWT Java Packages and Publish to Archiva -## cpswt-core/federate-base + -This project contain Java classes that implement behavior that all federates must have. Among them are: +#### NOTE +To build CPSWT Packages and publish them to Archiva, we first need to clone the git repositories where they reside. +To do this, it is best to create a directory under your home directory where all needed CPSWT git repositories will be cloned (there 3 total +needed for these instructions). -**SynchronizedFederate** -- the base class of all Java federates that are instantiated directly from their -representation in a CPSWT model. +It is recommended that you call this directory `cpswt`. To create it, enter the following commands: -**InteractionMappingBase** and **InteractionMappingManager** -- classes that provide base functionality for **Mapper** -federates. +```default +cd +mkdir cpswt +``` -## cpswt-core/federation-manager +This directory will be referred to as `` for the remainder of these instructions. -This project contains the Java classes that implement the FederationManager, which: +**IMPORTANT**: `` is an *absolute path* , not a relative path. For instance, if +you made `` the cpswt directory under ``, then `` +represents “`/cpswt`”. -* Is executed first for any federation -* Waits for all federates to join before proceeding with federate execution by using HLA synchronization points. +1. Clone the cpswt-core git repository: + 1. Change your directory to <[CPSWT-HOME](#cpswt-home)>: + ```bash + cd + ``` + 2. Clone the repository: + ```bash + git clone git@github.com:SimIntToolkit/cpswt-core.git + ``` +2. Change to the `/cpswt-core/cpswt-core` directory (*you read that right – cpswt-core appears twice*): + ```bash + cd /cpswt-core/cpswt-core + ``` +3. Install the [gradle wrapper](#gradle-wrapper): + ```bash + gradle wrapper --gradle-version=8.0 + ``` +4. Execute the following sequence of commands **in order**: + ```bash + ./gradlew :utils:publish + ./gradlew :root:publish + ./gradlew :base-events:publish + ./gradlew :coa:publish + ./gradlew :config:publish + ./gradlew :federate-base:publish + ./gradlew :federation-manager:publish + ./gradlew :fedmanager-host:publish + ``` +5. To test if the Java packages have been published to Archiva, do the following: + 1. Go to `http://localhost:8080` using your Google Chrome browser + 2. On the resulting page, click on `Browse` in the upper left-hand corner under `Artifacts` + 3. Under `Browse Repository` in the top-middle-left of the page, click on the small down-arrow on the right side of a small textbox. + 4. In the resulting drop-down menu, click `Archive Managed Snapshot Repository` + 5. Click on `org.cpswt`, which should be a short ways down the page from `Browse Repository` mentioned above. + 6. A list should appear that contains all of the packages you published above using `./gradlew` (in alphabetical order): -## cpswt-core/utils + + * base-events + * coa + * config + * federate-base + * federation-manager + * fedmanager-host + * root + * utils -This project contains various utility classes used by other projects. +**This concludes the setup for CPSWT for the HelloWorldJava example!** diff --git a/cpswt-core/coa/gradle.properties b/cpswt-core/coa/gradle.properties new file mode 100644 index 00000000..65a82a47 --- /dev/null +++ b/cpswt-core/coa/gradle.properties @@ -0,0 +1 @@ +version=0.8.0-SNAPSHOT diff --git a/cpswt-core/gradle.properties b/cpswt-core/gradle.properties index 65a82a47..b742408f 100644 --- a/cpswt-core/gradle.properties +++ b/cpswt-core/gradle.properties @@ -1 +1 @@ -version=0.8.0-SNAPSHOT +version=0.8.0-SNAPSHOT \ No newline at end of file