Skip to content

Commit 4975da7

Browse files
Added and worked on config for .exe file generation
1 parent 5eb36dc commit 4975da7

9 files changed

Lines changed: 208 additions & 65 deletions

File tree

.fttignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.git
2+
build
3+
.gradle
4+
gradle
5+
Group 6 - EbenLib (Library Management System).*
6+
app\bin
795 KB
Binary file not shown.

README.md

Lines changed: 117 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<p align="center">
2+
<img src="./app/ebenlib.ico" alt="Logo" style="border-radius: 50%; background: white;" width="100" height="100"/>
3+
</p>
4+
5+
<br/>
6+
<br/>
7+
<br/>
8+
19
![Deme](./demo.png)
210

311
# EbenLib Library Management System
@@ -26,42 +34,51 @@ For dev, use the utility psh script to run
2634
2735
```
2836

29-
### Install as a Global Command
37+
---
38+
39+
### Packaging
3040

31-
1. Build your native image or Jar:
41+
#### ⭑ Native Windows EXE (via GraalVM native-image)
3242

33-
```bash
34-
./gradlew build
43+
1. Install GraalVM 21 CE and set `JAVA_HOME`
44+
45+
```powershell
46+
$env:JAVA_HOME = 'C:\graalvm\jdk-21.0.2'
47+
$env:Path = "$env:JAVA_HOME\bin;$env:Path"
3548
```
3649

37-
2. (Optional, for Jar) Create a launcher script named `ebenlib`:
50+
2. Ensure you have **Visual Studio Build Tools** (for `cl.exe`).
51+
3. Build the “fat-jar” + native image:
3852

3953
```bash
40-
#!/usr/bin/env bash
41-
java -jar /full/path/to/ebenlib.jar "$@"
54+
./gradlew clean nativeImage
4255
```
4356

44-
3. Make it executable and move it into your `$PATH`:
57+
4. You’ll end up with `ebenlib.exe`.
58+
To test:
4559

46-
```bash
47-
chmod +x ebenlib
48-
sudo mv ebenlib /usr/local/bin/
60+
```powershell
61+
.\ebenlib.exe --interactive
4962
```
5063

51-
Now you can run:
64+
> _Optional icon injection_ uses Resource Hacker if installed under
65+
> `C:\Program Files (x86)\Resource Hacker\ResourceHacker.exe`.
66+
67+
#### ⭑ Fat-Jar Only
68+
69+
If you prefer a single JAR (no native-image):
5270

5371
```bash
54-
ebenlib --help
55-
ebenlib auth signin
56-
ebenlib --interactive
72+
./gradlew clean jar
73+
java -jar app/build/libs/app.jar --interactive
5774
```
5875

5976
---
6077

6178
## 📚 Command Reference
6279

6380
```text
64-
ebenlib <command> [options]
81+
ebenlib <category> <command>
6582
```
6683

6784
### Core Commands
@@ -104,6 +121,8 @@ ebenlib <command> [options]
104121
| `test` | Run the built‑in console UI tests |
105122
| `--help`, `-h` | Show this help message |
106123

124+
_Use `ebenlib <category> <command> --help` for detailed usage._
125+
107126
---
108127

109128
### 🔧 Examples
@@ -134,38 +153,82 @@ ebenlib --interactive
134153

135154
```java
136155

156+
137157
./Library-Management-System/*
138158
├─ app/*
139159
| ├─ src/*
140160
| | ├─ main/*
141161
| | | ├─ java/*
142-
| | | | └─ org/*
143-
| | | | └─ ebenlib/*
144-
| | | | ├─ cli/*
145-
| | | | | ├─ AuthHandler.java
146-
| | | | | ├─ CommandRouter.java
147-
| | | | | ├─ ConsoleThemeTest.java
148-
| | | | | ├─ ConsoleUI.java
149-
| | | | | ├─ InteractiveMenus.java
150-
| | | | | ├─ InteractiveShell.java
151-
| | | | | ├─ TablePrinter.java
152-
| | | | | └─ User.java
153-
| | | | └─ App.java
162+
| | | | ├─ org/*
163+
| | | | | └─ ebenlib/*
164+
| | | | | ├─ book/*
165+
| | | | | | ├─ Book.java
166+
| | | | | | ├─ BookHandler.java
167+
| | | | | | ├─ BookService.java
168+
| | | | | | └─ BookStats.java
169+
| | | | | ├─ borrow/*
170+
| | | | | | ├─ BorrowHandler.java
171+
| | | | | | ├─ BorrowRecord.java
172+
| | | | | | ├─ BorrowSettings.java
173+
| | | | | | ├─ BorrowStore.java
174+
| | | | | | └─ Status.java
175+
| | | | | ├─ cli/*
176+
| | | | | | ├─ AuthHandler.java
177+
| | | | | | ├─ CommandRouter.java
178+
| | | | | | ├─ ConsoleThemeTest.java
179+
| | | | | | ├─ ConsoleUI.java
180+
| | | | | | ├─ InteractiveMenus.java
181+
| | | | | | ├─ InteractiveShell.java
182+
| | | | | | └─ TablePrinter.java
183+
| | | | | ├─ ds/*
184+
| | | | | | ├─ EbenLibComparator.java
185+
| | | | | | ├─ EbenLibFunction.java
186+
| | | | | | ├─ EbenLibHashSet.java
187+
| | | | | | ├─ EbenLibList.java
188+
| | | | | | ├─ EbenLibMap.java
189+
| | | | | | ├─ EbenLibMapEntry.java
190+
| | | | | | ├─ EbenLibPriorityQueue.java
191+
| | | | | | ├─ EbenLibSet.java
192+
| | | | | | └─ EbenLibStack.java
193+
| | | | | ├─ profile/*
194+
| | | | | | └─ ProfileHandler.java
195+
| | | | | ├─ report/*
196+
| | | | | | └─ ReportHandler.java
197+
| | | | | ├─ searchsort/*
198+
| | | | | | ├─ Searcher.java
199+
| | | | | | └─ Sorter.java
200+
| | | | | ├─ system/*
201+
| | | | | | └─ SystemHandler.java
202+
| | | | | ├─ user/*
203+
| | | | | | ├─ Role.java
204+
| | | | | | ├─ User.java
205+
| | | | | | ├─ UserHandler.java
206+
| | | | | | └─ UserStore.java
207+
| | | | | ├─ utils/*
208+
| | | | | | └─ FileUtil.java
209+
| | | | | └─ App.java
210+
| | | | └─ module-info.java
154211
| | | └─ resources/*
155-
| | | ├─ session.txt
212+
| | | ├─ books.csv
213+
| | | ├─ borrows.csv
214+
| | | ├─ session.csv
215+
| | | ├─ settings.txt
156216
| | | └─ users.csv
157217
| | └─ test/*
158218
| | ├─ java/*
159219
| | | └─ org/*
160220
| | | └─ ebenlib/*
161221
| | | └─ AppTest.java
162222
| | └─ resources/*
163-
| └─ build.gradle
164-
├─ gradle/*
165-
| ├─ wrapper/*
166-
| | ├─ gradle-wrapper.jar
167-
| | └─ gradle-wrapper.properties
168-
| └─ libs.versions.toml
223+
| ├─ build.gradle
224+
| ├─ ebenlib.exe
225+
| └─ ebenlib.ico
226+
├─ src/*
227+
| └─ main/*
228+
| └─ resources/*
229+
| ├─ books.csv
230+
| └─ borrows.csv
231+
├─ .fttignore
169232
├─ .gitattributes
170233
├─ .gitignore
171234
├─ demo.png
@@ -180,6 +243,25 @@ ebenlib --interactive
180243
181244
---
182245
246+
## 🔧 Data Structures & Algorithms
247+
248+
- **EbenLibList<T>**
249+
_Dynamic array_ with O(1) random access, amortized O(1) append, O(n) remove.
250+
- **EbenLibStack<T>**
251+
LIFO built on `EbenLibList`: `push`, `pop`, `peek` all O(1).
252+
- **EbenLibMap\<K,V>**
253+
Chained-hash table: average O(1) `get`/`put`/`remove`; rehash at load > 0.75.
254+
- **EbenLibPriorityQueue<T>**
255+
Binary-heap: O(log n) insert & remove-max/min.
256+
- **EbenLibHashSet<T>**
257+
Wrapper over `EbenLibMap<T,Boolean>`, O(1) contains/add/remove.
258+
- **Binary Search**
259+
O(log n) on pre-sorted `EbenLibList` via `Searcher.binarySearch`.
260+
- **Merge Sort**
261+
O(n log n) stable sort implemented in `Sorter.mergeSort`.
262+
263+
---
264+
183265
## 🌱 Developer Notes
184266
185267
- **Adding new commands**:
@@ -196,20 +278,10 @@ ebenlib --interactive
196278
197279
---
198280
199-
## ✅ What’s Next
200-
201-
- Implement actual logic behind the **stubs** (`BookHandler`, `BorrowHandler`, etc.)
202-
- Add **JUnit tests** under `/test` to cover each service
203-
- Integrate **fine calculation**, **overdue monitoring**, and **report generation**
204-
205-
---
206-
207281
## 🤝 Contributing
208282
209283
1. Fork this repo
210284
2. Create your feature branch (`git checkout -b feature/xyz`)
211285
3. Commit your changes (`git commit -m "feat: add XYZ"`)
212286
4. Push to your branch (`git push origin feature/xyz`)
213287
5. Open a Pull Request
214-
215-
Happy coding! 🚀

app/bin/main/settings.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
loan_period_days=15
2+
fine_per_day=3.0
3+
fine_block_threshold=10.0
4+
low_stock_threshold=50

app/build.gradle

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,85 @@
1-
/*
2-
* This file was generated by the Gradle 'init' task.
3-
*
4-
* This generated file contains a sample Java application project to get you started.
5-
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.14.2/userguide/building_java_projects.html in the Gradle documentation.
6-
*/
7-
81
plugins {
9-
// Apply the application plugin to add support for building a CLI application in Java.
102
id 'application'
113
}
124

135
repositories {
14-
// Use Maven Central for resolving dependencies.
156
mavenCentral()
167
}
178

189
dependencies {
19-
// Use JUnit Jupiter for testing.
10+
implementation libs.guava
2011
testImplementation libs.junit.jupiter
21-
2212
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
23-
24-
// This dependency is used by the application.
25-
implementation libs.guava
2613
}
2714

28-
// Apply a specific Java toolchain to ease working on different environments.
2915
java {
3016
toolchain {
3117
languageVersion = JavaLanguageVersion.of(21)
3218
}
3319
}
3420

3521
application {
36-
// Define the main class for the application.
3722
mainClass = 'org.ebenlib.App'
3823
}
3924

40-
tasks.named('test') {
41-
// Use JUnit Platform for unit tests.
42-
useJUnitPlatform()
25+
// === Fat JAR w/ Main-Class ===
26+
jar {
27+
manifest {
28+
attributes 'Main-Class': application.mainClass
29+
}
30+
from {
31+
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
32+
}
33+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
34+
}
35+
36+
// —————————————————————————————————————————————————————————————————————————————————————
37+
// Precompute all file paths *outside* any task action so config cache is happy:
38+
def jarFile = "$buildDir/libs/${project.name}.jar"
39+
def exeName = "ebenlib.exe"
40+
def exePath = "$projectDir/$exeName"
41+
def iconFile = "$projectDir/ebenlib.ico"
42+
def resHackExe = "C:/Program Files (x86)/Resource Hacker/ResourceHacker.exe"
43+
def nativeImageCmd = "C:/graalvm/jdk-21.0.2/bin/native-image.cmd"
44+
45+
// 1) Compile native image
46+
tasks.register('nativeImage', Exec) {
47+
group = 'build'
48+
description = 'Compile a native exe via GraalVM'
49+
50+
dependsOn tasks.named('jar')
51+
inputs.file file(jarFile)
52+
outputs.file file(exePath)
53+
54+
commandLine nativeImageCmd,
55+
'--no-fallback',
56+
'-jar', jarFile,
57+
'ebenlib'
58+
}
59+
60+
// 2) Inject icon (only if RH is installed)
61+
tasks.register('injectIcon', Exec) {
62+
group = 'build'
63+
description = 'Add icon to the .exe via Resource Hacker'
64+
65+
dependsOn tasks.named('nativeImage')
66+
inputs.file file(exePath)
67+
outputs.file file(exePath) // overwrites same file
68+
69+
// only run if RH is present
70+
onlyIf { file(resHackExe).exists() }
71+
72+
commandLine resHackExe,
73+
'-open', exePath,
74+
'-save', exePath,
75+
'-action', 'addoverwrite',
76+
'-res', iconFile,
77+
'-mask', 'ICONGROUP,MAINICON,'
78+
}
79+
80+
// 3) Top-level task
81+
tasks.register('nativeImageAll') {
82+
group = 'build'
83+
description = 'Build native exe and inject icon'
84+
dependsOn tasks.named('injectIcon')
4385
}

app/ebenlib.exe

15.1 MB
Binary file not shown.

app/ebenlib.ico

52.6 KB
Binary file not shown.

app/src/main/java/module-info.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module org.ebenlib {
2+
// Required by most Java CLI apps
3+
requires java.base;
4+
5+
// Required if you're using any AWT/Swing features (even for colors or fonts)
6+
requires java.desktop;
7+
8+
// Export only your public-facing packages
9+
exports org.ebenlib.cli;
10+
exports org.ebenlib.book;
11+
exports org.ebenlib.borrow;
12+
exports org.ebenlib.user;
13+
exports org.ebenlib.profile;
14+
exports org.ebenlib.report;
15+
exports org.ebenlib.system;
16+
exports org.ebenlib.searchsort;
17+
exports org.ebenlib.utils;
18+
exports org.ebenlib.ds;
19+
}

run.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# .\gradlew installDist
1+
.\gradlew clean installDist
22

33

44
$script = Join-Path $PSScriptRoot "app\build\install\app\bin\app.bat"

0 commit comments

Comments
 (0)