Skip to content

Commit b7bbef8

Browse files
committed
converted to maven
1 parent edad506 commit b7bbef8

File tree

17 files changed

+162
-58
lines changed

17 files changed

+162
-58
lines changed

.github/workflows/main.yml

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
FILE_NAME: ant-path-finding # Name of the JAR file (All lowercase, no spaces, no underscores)
1111
ICON_NAME: antPathFinding-512
1212
MAIN_CLASS: App
13-
OUT_DIR: out
13+
OUT_DIR: target
1414
VERSION: ${{ github.ref_name }}
1515

1616
jobs:
@@ -21,6 +21,12 @@ jobs:
2121
stripped_version: ${{ steps.get_stripped_version.outputs.version }}
2222

2323
steps:
24+
- name: Setup Java
25+
uses: actions/setup-java@v2
26+
with:
27+
java-version: '17'
28+
distribution: 'temurin'
29+
2430
- name: Get stripped version
2531
id: get_stripped_version
2632
run: |
@@ -40,22 +46,13 @@ jobs:
4046
path: ./CHANGELOG.md
4147

4248
- name: Compile and Build JAR
43-
run: |
44-
mkdir ${{ env.OUT_DIR }}
45-
javac -d ${{ env.OUT_DIR }} -cp "lib/*" src/*.java
46-
# Generate a temporary manifest file using echo
47-
echo "Main-Class: ${{ env.MAIN_CLASS }}" > customManifest.txt
48-
jar cvfm ${{ env.OUT_DIR }}/${{ env.FILE_NAME }}-${{ env.VERSION }}.jar \
49-
customManifest.txt \
50-
-C ${{ env.OUT_DIR }} ./ \
51-
-C ./ assets/ \
52-
-C lib .
49+
run: mvn clean package
5350

5451

5552
- name: Upload JAR as Artifact
5653
uses: actions/upload-artifact@v3
5754
with:
58-
name: ${{ env.FILE_NAME }}-jar-${{ env.VERSION }}
55+
name: ${{ env.FILE_NAME }}-${{ env.VERSION }}.jar
5956
path: ${{ env.OUT_DIR }}/${{ env.FILE_NAME }}-${{ env.VERSION }}.jar
6057

6158
- name: Create GitHub Release
@@ -84,13 +81,19 @@ jobs:
8481
runs-on: macOS-latest
8582

8683
steps:
84+
- name: Setup Java
85+
uses: actions/setup-java@v2
86+
with:
87+
java-version: '17'
88+
distribution: 'temurin'
89+
8790
- name: Checkout code
8891
uses: actions/checkout@v3
8992

9093
- name: Download JAR from artifact
9194
uses: actions/download-artifact@v3
9295
with:
93-
name: ${{ env.FILE_NAME }}-jar-${{ env.VERSION }}
96+
name: ${{ env.FILE_NAME }}-${{ env.VERSION }}.jar
9497
path: ${{ env.OUT_DIR }}
9598

9699
- name: Create Standalone for MacOS
@@ -109,9 +112,6 @@ jobs:
109112
- name: List contents of out directory
110113
run: ls ${{ env.OUT_DIR }}
111114

112-
# - name: Rename MacOS standalone
113-
# run: mv ${{ env.FILE_NAME }}-1.0.dmg ${{ env.FILE_NAME }}-MacOS-${{ env.VERSION }}.dmg
114-
115115
- name: Attach MacOS Standalone to Release
116116
uses: actions/upload-release-asset@v1
117117
env:
@@ -127,13 +127,19 @@ jobs:
127127
runs-on: ubuntu-latest
128128

129129
steps:
130+
- name: Setup Java
131+
uses: actions/setup-java@v2
132+
with:
133+
java-version: '17'
134+
distribution: 'temurin'
135+
130136
- name: Checkout code
131137
uses: actions/checkout@v3
132138

133139
- name: Download JAR from artifact
134140
uses: actions/download-artifact@v3
135141
with:
136-
name: ${{ env.FILE_NAME }}-jar-${{ env.VERSION }}
142+
name: ${{ env.FILE_NAME }}-${{ env.VERSION }}
137143
path: ${{ env.OUT_DIR }}
138144

139145
- name: Create Standalone for Ubuntu
@@ -152,9 +158,6 @@ jobs:
152158
- name: List contents of out directory
153159
run: ls -lh .
154160

155-
# - name: Rename Ubuntu standalone
156-
# run: mv ${{ env.FILE_NAME }}_1.0-1_amd64.deb ${{ env.FILE_NAME }}-Ubuntu-${{ env.VERSION }}_amd64.deb
157-
158161
- name: Attach Ubuntu Standalone to Release
159162
uses: actions/upload-release-asset@v1
160163
env:
@@ -176,13 +179,13 @@ jobs:
176179
- name: Download JAR from artifact
177180
uses: actions/download-artifact@v3
178181
with:
179-
name: ${{ env.FILE_NAME }}-jar-${{ env.VERSION }}
182+
name: ${{ env.FILE_NAME }}-${{ env.VERSION }}
180183
path: ${{ env.OUT_DIR }}
181184

182-
- name: Setup Java 16
185+
- name: Setup Java 17
183186
uses: actions/setup-java@v2
184187
with:
185-
java-version: '16'
188+
java-version: '17'
186189
distribution: 'temurin'
187190

188191
- name: Create Standalone for Windows

.gitignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# build artifacts
22
bin/
3+
# Maven
4+
target/
5+
36

47
# Compiled class file
58
*.class
@@ -37,6 +40,8 @@ Thumbs.db
3740

3841
repush.sh
3942

40-
# include /lib
41-
!lib/*
42-
```
43+
# # include /lib
44+
# !lib/*
45+
# ```
46+
47+
lib/

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"type": "java",
9+
"name": "App",
10+
"request": "launch",
11+
"mainClass": "App",
12+
"projectName": "ant-path-finding"
13+
},
14+
{
15+
"type": "java",
16+
"name": "App",
17+
"request": "launch",
18+
"mainClass": "main.java.App",
19+
"projectName": "ant-path-finding-using-A-Star-algorithm_f97be32f"
20+
},
721
{
822
"type": "java",
923
"name": "App",

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"src",
55
"."
66
],
7-
"java.project.outputPath": "bin"
7+
"java.project.outputPath": "bin",
8+
"java.configuration.updateBuildConfiguration": "interactive"
89
}

dependency-reduced-pom.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>io.github.vmsaif</groupId>
5+
<artifactId>ant-path-finding</artifactId>
6+
<version>2.0.0</version>
7+
<build>
8+
<plugins>
9+
<plugin>
10+
<artifactId>maven-compiler-plugin</artifactId>
11+
<version>3.8.1</version>
12+
<configuration>
13+
<source>17</source>
14+
<target>17</target>
15+
</configuration>
16+
</plugin>
17+
<plugin>
18+
<artifactId>maven-shade-plugin</artifactId>
19+
<version>3.2.4</version>
20+
<executions>
21+
<execution>
22+
<phase>package</phase>
23+
<goals>
24+
<goal>shade</goal>
25+
</goals>
26+
<configuration>
27+
<transformers>
28+
<transformer>
29+
<mainClass>App</mainClass>
30+
</transformer>
31+
</transformers>
32+
</configuration>
33+
</execution>
34+
</executions>
35+
</plugin>
36+
</plugins>
37+
</build>
38+
</project>

lib/flatlaf-3.2.1.jar

-797 KB
Binary file not shown.

pom.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>io.github.vmsaif</groupId>
7+
<artifactId>ant-path-finding</artifactId>
8+
<version>2.0.0</version>
9+
<packaging>jar</packaging>
10+
11+
<dependencies>
12+
<dependency>
13+
<groupId>com.formdev</groupId>
14+
<artifactId>flatlaf</artifactId>
15+
<version>3.2.1</version>
16+
</dependency>
17+
</dependencies>
18+
19+
<build>
20+
21+
<plugins>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<version>3.8.1</version>
26+
<configuration>
27+
<source>17</source>
28+
<target>17</target>
29+
</configuration>
30+
</plugin>
31+
<plugin>
32+
<groupId>org.apache.maven.plugins</groupId>
33+
<artifactId>maven-shade-plugin</artifactId>
34+
<version>3.2.4</version>
35+
<executions>
36+
<execution>
37+
<phase>package</phase>
38+
<goals>
39+
<goal>shade</goal>
40+
</goals>
41+
<configuration>
42+
<transformers>
43+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
44+
<mainClass>App</mainClass>
45+
</transformer>
46+
</transformers>
47+
</configuration>
48+
</execution>
49+
</executions>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
</project>
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/Game.java renamed to src/main/java/Game.java

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ public class Game extends JPanel implements MouseListener, MouseMotionListener {
7676
private boolean noPath;
7777
private Tile lastDraggedTile = null;
7878

79-
private int timerX;
80-
private int timerY;
81-
private int terrainCountX;
82-
private int terrainCountY;
83-
8479
private long startTimeBeforeSearch;
8580
private long elapsedTimeAfterSearch;
8681
private String elapsedTimeStringBeforeSearch;
@@ -181,11 +176,6 @@ private void resizeWindow() {
181176
public void componentResized(ComponentEvent e) {
182177

183178
// the top bar location
184-
terrainCountX = (int)(frame.getWidth()/2.7);
185-
terrainCountY = frame.getHeight()/15;
186-
187-
timerX = frame.getWidth() - 480;
188-
timerY = frame.getHeight() - 47;
189179

190180
// set the grid offset/start point
191181
int xOffset = (int) ((frame.getWidth() - TILE_SIZE * NUM_COLS) / 2);
@@ -201,11 +191,11 @@ public void componentResized(ComponentEvent e) {
201191

202192
private void loadImg() {
203193
try {
204-
obstacleImg = ImageIO.read(getClass().getResource("/assets/images/obstacle.png"));
205-
swamplandImg = ImageIO.read(getClass().getResource("/assets/images/swampland.png"));
206-
grasslandImg = ImageIO.read(getClass().getResource("/assets/images/grassland.png"));
207-
foodImg = ImageIO.read(getClass().getResource("/assets/images/food.png"));
208-
antImage = ImageIO.read(getClass().getResource("/assets/images/ant.png"));
194+
obstacleImg = ImageIO.read(getClass().getResource("/images/obstacle.png"));
195+
swamplandImg = ImageIO.read(getClass().getResource("/images/swampland.png"));
196+
grasslandImg = ImageIO.read(getClass().getResource("/images/grassland.png"));
197+
foodImg = ImageIO.read(getClass().getResource("/images/food.png"));
198+
antImage = ImageIO.read(getClass().getResource("/images/ant.png"));
209199
} catch (IOException e) {
210200
e.printStackTrace();
211201
}
@@ -712,33 +702,33 @@ private void drawTileCount(Graphics g) {
712702
int totalWidth = totalIconWidth + 3 * iconTextSpacing; // The space after each icon for text
713703

714704
// Calculate the starting X-coordinate to make the icons and text centered
715-
int startX = (frame.getWidth() - totalWidth) / 2;
705+
int terrainCountX = (frame.getWidth() - totalWidth) / 2;
716706

717-
terrainCountY = (int) (frame.getHeight() / 15);
707+
int terrainCountY = (int) (frame.getHeight() / 15);
718708

719709
g.setColor(counterDigitColor);
720710

721-
g.drawImage(obstacleImg, startX, terrainCountY, iconSize, iconSize, null);
722-
g.drawString("" + obstacleCount, startX + iconSize + iconTextSpacing, terrainCountY + iconSize - 3);
711+
g.drawImage(obstacleImg, terrainCountX, terrainCountY, iconSize, iconSize, null);
712+
g.drawString("" + obstacleCount, terrainCountX + iconSize + iconTextSpacing, terrainCountY + iconSize - 3);
723713

724-
startX += iconSize + iconTextSpacing + wordSpacing;
714+
terrainCountX += iconSize + iconTextSpacing + wordSpacing;
725715

726-
g.drawImage(grasslandImg, startX, terrainCountY, iconSize, iconSize, null);
727-
g.drawString("" + grasslandCount, startX + iconSize + iconTextSpacing, terrainCountY + iconSize - 3);
716+
g.drawImage(grasslandImg, terrainCountX, terrainCountY, iconSize, iconSize, null);
717+
g.drawString("" + grasslandCount, terrainCountX + iconSize + iconTextSpacing, terrainCountY + iconSize - 3);
728718

729-
startX += iconSize + iconTextSpacing + wordSpacing;
719+
terrainCountX += iconSize + iconTextSpacing + wordSpacing;
730720

731-
g.drawImage(swamplandImg, startX, terrainCountY, iconSize, iconSize, null);
732-
g.drawString("" + swamplandCount, startX + iconSize + iconTextSpacing, terrainCountY + iconSize - 3);
721+
g.drawImage(swamplandImg, terrainCountX, terrainCountY, iconSize, iconSize, null);
722+
g.drawString("" + swamplandCount, terrainCountX + iconSize + iconTextSpacing, terrainCountY + iconSize - 3);
733723

734-
startX += iconSize + iconTextSpacing + wordSpacing;
724+
terrainCountX += iconSize + iconTextSpacing + wordSpacing;
735725

736726
g.setColor(openTerrainColor);
737-
g.fillRect(startX, terrainCountY + 3, (int) (Game.getTileSize() / iconScaling), (int) (Game.getTileSize() / iconScaling));
727+
g.fillRect(terrainCountX, terrainCountY + 3, (int) (Game.getTileSize() / iconScaling), (int) (Game.getTileSize() / iconScaling));
738728
g.setColor(openTerrainBoarderColor);
739-
g.drawRect(startX, terrainCountY + 3, (int) (Game.getTileSize() / iconScaling), (int) (Game.getTileSize() / iconScaling));
729+
g.drawRect(terrainCountX, terrainCountY + 3, (int) (Game.getTileSize() / iconScaling), (int) (Game.getTileSize() / iconScaling));
740730
g.setColor(counterDigitColor);
741-
g.drawString("" + openTerrainCount, startX + iconSize + iconTextSpacing, terrainCountY + iconSize - 2);
731+
g.drawString("" + openTerrainCount, terrainCountX + iconSize + iconTextSpacing, terrainCountY + iconSize - 2);
742732

743733
} catch (NullPointerException e) {
744734
System.out.println("Image not found");
@@ -756,8 +746,8 @@ private void printTimer(Graphics g) {
756746
String timerText = "Creation Time: " + elapsedTimeStringBeforeSearch + " | " + "AI Solving Time: " + elapsedTimeStringAfterAnimation;
757747
int stringWidth = g.getFontMetrics().stringWidth(timerText);
758748
int centeredX = (frame.getWidth() - stringWidth) / 2;
759-
760-
g.drawString(timerText, centeredX, timerY);
749+
int centerY = frame.getHeight() - 47;
750+
g.drawString(timerText, centeredX, centerY);
761751
}
762752

763753
private void printIfNoPath(Graphics g) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)