Skip to content

Commit

Permalink
Changes for Maven Repository (#1)
Browse files Browse the repository at this point in the history
* Changes

* Added CI tool

* CI test updates

* modified:   pom.xml

* modified:   .github/workflows/java-ci.yml

* Compile and Install Settings

* CI update
  • Loading branch information
NuwanJ authored Jul 29, 2023
1 parent 791e01f commit 87974e5
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 20 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/java-ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
38 changes: 38 additions & 0 deletions .github/workflows/maven-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/Pera-Swarm/java-robot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
<username>${env.USER_NAME}</username>
<password>${env.ACCESS_TOKEN}</password>
</server>
</servers>

</settings>
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ hs_err_pid*
.idea
.target


/target
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
"java.configuration.updateBuildConfiguration": "automatic"
}
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# java-swarm-node
# Java Robot

This is a boilerplate template for java virtual robotst, *Pera-Swarm*

Expand All @@ -22,3 +22,18 @@ username=user
password=pass
channel="v1"
```

## Install the Library

<!-- - You need to setup a GitHub Token with the scope of `read:packages` and save it along with your GitHub UserName as environment variables as follows:
```bash
export USER_NAME="NuwanJ"
export ACCESS_TOKEN="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"
``` -->

- Run the following command to run the `mvn install`

```bash
mvn -s ./settings.xml -B install --file pom.xml
```
22 changes: 15 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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">
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">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>java-robot</artifactId>
<groupId>pera.swarm</groupId>
<artifactId>java-robot-node</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/Pera-Swarm/java-robot</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>swarm.node</groupId>
<artifactId>swarm-node</artifactId>
<version>1.0.0-SNAPSHOT</version>
<groupId>pera.swarm</groupId>
<artifactId>java-robot</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

Expand Down
36 changes: 36 additions & 0 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/Pera-Swarm/java-robot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
</server>
</servers>

</settings>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package robotImplementations;
package Robots;

import swarm.robot.VirtualRobot;

Expand All @@ -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();
}

Expand All @@ -27,4 +27,4 @@ public void communicationInterrupt(String msg) {
System.out.println("communicationInterrupt on " + id + " with msg:" + msg);
}

}
}
8 changes: 3 additions & 5 deletions src/main/java/SwarmRobot.java → src/main/java/Swarm.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@

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;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class SwarmRobot {
public class Swarm {

public static void main(String[] args) {

Expand All @@ -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) {
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 87974e5

Please sign in to comment.