From 87974e5cbe2a25a3631ae551f89b5380c3208855 Mon Sep 17 00:00:00 2001 From: Nuwan Jaliyagoda Date: Sat, 29 Jul 2023 10:48:44 +0530 Subject: [PATCH] Changes for Maven Repository (#1) * Changes * Added CI tool * CI test updates * modified: pom.xml * modified: .github/workflows/java-ci.yml * Compile and Install Settings * CI update --- .github/workflows/java-ci.yml | 32 ++++++++++++++++ .github/workflows/maven-settings.xml | 38 +++++++++++++++++++ .gitignore | 1 - .vscode/settings.json | 2 +- README.md | 17 ++++++++- pom.xml | 22 +++++++---- settings.xml | 36 ++++++++++++++++++ .../MyTestRobot.java | 6 +-- src/main/java/{SwarmRobot.java => Swarm.java} | 8 ++-- .../compile/default-cli/createdFiles.lst | 1 - .../compile/default-cli/inputFiles.lst | 1 - 11 files changed, 144 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/java-ci.yml create mode 100644 .github/workflows/maven-settings.xml create mode 100644 settings.xml rename src/main/java/{robotImplementations => Robots}/MyTestRobot.java (87%) rename src/main/java/{SwarmRobot.java => Swarm.java} (87%) delete mode 100644 target/maven-status/maven-compiler-plugin/compile/default-cli/createdFiles.lst delete mode 100644 target/maven-status/maven-compiler-plugin/compile/default-cli/inputFiles.lst diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml new file mode 100644 index 0000000..a69e413 --- /dev/null +++ b/.github/workflows/java-ci.yml @@ -0,0 +1,32 @@ +name: Java CI with Maven + +on: + push: + branches: [ "main" ] + + pull_request: + branches: [ "main" ] + + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Build with Maven + run: mvn -s $GITHUB_WORKSPACE/.github/workflows/maven-settings.xml -B package --file pom.xml + env: + USER_NAME: ${{ secrets.USER_NAME }} + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/maven-settings.xml b/.github/workflows/maven-settings.xml new file mode 100644 index 0000000..be0ea48 --- /dev/null +++ b/.github/workflows/maven-settings.xml @@ -0,0 +1,38 @@ + + + + github + + + + github + + + central + https://repo1.maven.org/maven2 + + + github + https://maven.pkg.github.com/Pera-Swarm/java-robot + + true + + + true + + + + + + + + + github + ${env.USER_NAME} + ${env.ACCESS_TOKEN} + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 099547f..9aaf1f0 100644 --- a/.gitignore +++ b/.gitignore @@ -28,5 +28,4 @@ hs_err_pid* .idea .target - /target \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index c5f3f6b..e0f15db 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "java.configuration.updateBuildConfiguration": "interactive" + "java.configuration.updateBuildConfiguration": "automatic" } \ No newline at end of file diff --git a/README.md b/README.md index fb505ad..4e7420e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# java-swarm-node +# Java Robot This is a boilerplate template for java virtual robotst, *Pera-Swarm* @@ -22,3 +22,18 @@ username=user password=pass channel="v1" ``` + +## Install the Library + + + +- Run the following command to run the `mvn install` + +```bash +mvn -s ./settings.xml -B install --file pom.xml +``` \ No newline at end of file diff --git a/pom.xml b/pom.xml index 52334e9..411f2f8 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,11 @@ + 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"> 4.0.0 - org.example - java-robot + pera.swarm + java-robot-node 1.0-SNAPSHOT @@ -13,11 +13,19 @@ 8 + + + github + GitHub OWNER Apache Maven Packages + https://maven.pkg.github.com/Pera-Swarm/java-robot + + + - swarm.node - swarm-node - 1.0.0-SNAPSHOT + pera.swarm + java-robot + 1.0.0 diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000..7c35951 --- /dev/null +++ b/settings.xml @@ -0,0 +1,36 @@ + + + + github + + + + github + + + central + https://repo1.maven.org/maven2 + + + github + https://maven.pkg.github.com/Pera-Swarm/java-robot + + true + + + true + + + + + + + + + github + + + + \ No newline at end of file diff --git a/src/main/java/robotImplementations/MyTestRobot.java b/src/main/java/Robots/MyTestRobot.java similarity index 87% rename from src/main/java/robotImplementations/MyTestRobot.java rename to src/main/java/Robots/MyTestRobot.java index 060ae24..b273efa 100644 --- a/src/main/java/robotImplementations/MyTestRobot.java +++ b/src/main/java/Robots/MyTestRobot.java @@ -1,4 +1,4 @@ -package robotImplementations; +package Robots; import swarm.robot.VirtualRobot; @@ -9,7 +9,7 @@ public MyTestRobot(int id, double x, double y, double heading) { } public void setup() { - System.out.println("My Test Robot Started"); + System.out.println("My Test Robot"); super.setup(); } @@ -27,4 +27,4 @@ public void communicationInterrupt(String msg) { System.out.println("communicationInterrupt on " + id + " with msg:" + msg); } -} +} \ No newline at end of file diff --git a/src/main/java/SwarmRobot.java b/src/main/java/Swarm.java similarity index 87% rename from src/main/java/SwarmRobot.java rename to src/main/java/Swarm.java index 5fb354e..9518ae8 100644 --- a/src/main/java/SwarmRobot.java +++ b/src/main/java/Swarm.java @@ -1,9 +1,7 @@ import swarm.configs.MQTTSettings; -import swarm.robot.Robot; import swarm.robot.VirtualRobot; -import robotImplementations.MyTestRobot; -import robotImplementations.ObstacleAvoidRobot; +import Robots.*; import java.io.File; import java.io.FileNotFoundException; @@ -11,7 +9,7 @@ import java.io.IOException; import java.util.Properties; -public class SwarmRobot { +public class Swarm { public static void main(String[] args) { @@ -33,7 +31,7 @@ public static void main(String[] args) { MQTTSettings.channel = props.getProperty("channel", "v1"); reader.close(); - Robot robot = new MyTestRobot(10, -52, 32, 45); + VirtualRobot robot = new MyTestRobot(10, -52, 32, 45); new Thread(robot).start(); } catch (FileNotFoundException ex) { diff --git a/target/maven-status/maven-compiler-plugin/compile/default-cli/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-cli/createdFiles.lst deleted file mode 100644 index a5a72bf..0000000 --- a/target/maven-status/maven-compiler-plugin/compile/default-cli/createdFiles.lst +++ /dev/null @@ -1 +0,0 @@ -SwarmRobot.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-cli/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-cli/inputFiles.lst deleted file mode 100644 index 319f668..0000000 --- a/target/maven-status/maven-compiler-plugin/compile/default-cli/inputFiles.lst +++ /dev/null @@ -1 +0,0 @@ -E:\University\Semester 7\CO421 - Final Year Project I\FYP_GitRepos\_other\java-robot\src\main\java\SwarmRobot.java