Skip to content

Commit 6872ab4

Browse files
committed
Add logging functionality with Logger and Logs classes
1 parent e55671a commit 6872ab4

9 files changed

Lines changed: 500 additions & 0 deletions

File tree

.github/workflows/packager-jar.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Publish JAR to GitHub Pages
2+
on:
3+
push:
4+
branches:
5+
- main
6+
permissions:
7+
contents: write
8+
pages: write
9+
id-token: write
10+
jobs:
11+
publish-jar:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
fetch-depth: 0
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '17'
23+
distribution: 'temurin'
24+
- name: Grant execute permission for gradlew
25+
run: chmod +x gradlew
26+
- name: Extract version from build.gradle
27+
id: extract_version
28+
run: |
29+
VERSION=$(./gradlew -q printVersion)
30+
echo "version=$VERSION" >> $GITHUB_OUTPUT
31+
echo "Extracted version: $VERSION"
32+
- name: Check if tag already exists
33+
id: check_tag
34+
run: |
35+
if git tag -l "${{ steps.extract_version.outputs.version }}" | grep -q "${{ steps.extract_version.outputs.version }}"; then
36+
echo "tag_exists=true" >> $GITHUB_OUTPUT
37+
echo "Tag ${{ steps.extract_version.outputs.version }} already exists and will be overwritten"
38+
else
39+
echo "tag_exists=false" >> $GITHUB_OUTPUT
40+
echo "Tag ${{ steps.extract_version.outputs.version }} does not exist"
41+
fi
42+
- name: Publish Maven artifacts to local repo
43+
run: ./gradlew publish
44+
env:
45+
GROUP_ID: io.nodelink.client
46+
ARTIFACT_ID: NodeLink-Client
47+
VERSION: ${{ steps.extract_version.outputs.version }}
48+
- name: Checkout target repository
49+
uses: actions/checkout@v4
50+
with:
51+
repository: nodelink-project/nodelink-project.github.io
52+
token: ${{ secrets.GH_TOKEN }}
53+
path: target-repo
54+
- name: Clean existing version folder
55+
run: |
56+
if [ -d "target-repo/NodeLink-Client/jar" ]; then
57+
echo "Cleaning existing NodeLink-Client/jar folder..."
58+
rm -rf target-repo/nodelink-client/jar
59+
fi
60+
mkdir -p target-repo/nodelink-client/jar
61+
- name: Copy new artifacts
62+
run: |
63+
cp -r build/repo/* target-repo/nodelink-client/jar/
64+
- name: Deploy to GitHub Pages
65+
run: |
66+
cd target-repo
67+
git config --local user.email "action@github.com"
68+
git config --local user.name "GitHub Action"
69+
git add .
70+
if git diff --staged --quiet; then
71+
echo "No changes to commit"
72+
else
73+
git commit -m "Update Orbit artifacts for version ${{ steps.extract_version.outputs.version }}"
74+
git push
75+
fi
76+
- name: Create and push Git tag (with override)
77+
run: |
78+
git config --local user.email "action@github.com"
79+
git config --local user.name "GitHub Action"
80+
81+
# S'assurer qu'on pousse vers le bon repository
82+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
83+
84+
# Supprimer le tag localement s'il existe
85+
git tag -d "${{ steps.extract_version.outputs.version }}" || true
86+
87+
# Supprimer le tag distant s'il existe
88+
git push origin --delete "${{ steps.extract_version.outputs.version }}" || true
89+
90+
# Créer et pousser le nouveau tag
91+
git tag -a "${{ steps.extract_version.outputs.version }}" -m "Release version ${{ steps.extract_version.outputs.version }}"
92+
git push origin "${{ steps.extract_version.outputs.version }}"
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.gradle
2+
build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
!**/src/main/**/build/
5+
!**/src/test/**/build/
6+
.kotlin
7+
8+
### IntelliJ IDEA ###
9+
.idea/modules.xml
10+
.idea/jarRepositories.xml
11+
.idea/compiler.xml
12+
.idea/libraries/
13+
*.iws
14+
*.iml
15+
*.ipr
16+
out/
17+
!**/src/main/**/out/
18+
!**/src/test/**/out/
19+
20+
### Eclipse ###
21+
.apt_generated
22+
.classpath
23+
.factorypath
24+
.project
25+
.settings
26+
.springBeans
27+
.sts4-cache
28+
bin/
29+
!**/src/main/**/bin/
30+
!**/src/test/**/bin/
31+
32+
### NetBeans ###
33+
/nbproject/private/
34+
/nbbuild/
35+
/dist/
36+
/nbdist/
37+
/.nb-gradle/
38+
39+
### VS Code ###
40+
.vscode/
41+
42+
### Mac OS ###
43+
.DS_Store

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
plugins {
2+
id 'java'
3+
id 'application'
4+
id 'com.gradleup.shadow' version '8.3.0'
5+
id 'maven-publish'
6+
}
7+
8+
application {
9+
mainClass = 'io.nodelink.client.NodeLink'
10+
}
11+
12+
task generateVersionClass {
13+
doLast {
14+
def versionFile = file("$buildDir/generated/source/version/io/nodelink/client/update/Version.java")
15+
versionFile.parentFile.mkdirs()
16+
versionFile.text = """
17+
package io.nodelink.client.update;
18+
19+
public class Version {
20+
public static final String VERSION = "${project.version}";
21+
}
22+
"""
23+
}
24+
}
25+
26+
compileJava.dependsOn generateVersionClass
27+
sourceSets.main.java.srcDir "$buildDir/generated/source/version"
28+
29+
tasks.register('printVersion') {
30+
doLast {
31+
println project.version
32+
}
33+
}
34+
35+
shadowJar {
36+
archiveClassifier.set('fat')
37+
38+
39+
manifest {
40+
attributes 'Main-Class': 'io.nodelink.client.NodeLink'
41+
}
42+
}
43+
44+
group = 'io.nodelink.client'
45+
version = '0.1.0'
46+
47+
repositories {
48+
mavenCentral()
49+
}
50+
51+
dependencies {
52+
testImplementation platform('org.junit:junit-bom:5.10.0')
53+
testImplementation 'org.junit.jupiter:junit-jupiter'
54+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
55+
56+
implementation 'org.jline:jline:3.30.0'
57+
implementation 'io.projectreactor:reactor-core:3.8.1'
58+
}
59+
60+
tasks.jar {
61+
manifest {
62+
attributes 'Main-Class': 'io.nodelink.client.NodeLink'
63+
}
64+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
65+
}
66+
67+
tasks.test {
68+
useJUnitPlatform()
69+
}
70+
71+
test {
72+
useJUnitPlatform()
73+
}
74+
75+
java {
76+
withSourcesJar()
77+
}
78+
79+
publishing {
80+
publications {
81+
mavenJava(MavenPublication) {
82+
from components.java
83+
84+
groupId = project.group.toString()
85+
artifactId = 'NodeLink-Client'
86+
version = project.version.toString()
87+
pom {
88+
name = 'NodeLink-Client'
89+
description = 'Change later'
90+
url = 'https://nodelink-project.github.io/NodeLink-Client/'
91+
licenses {
92+
license {
93+
name = 'GPL-3.0'
94+
url = 'https://raw.githubusercontent.com/NodeLink-Project/NodeLink-Client/refs/heads/main/LICENSE'
95+
}
96+
}
97+
developers {
98+
developer {
99+
id = 'sandro642'
100+
name = 'Sandro'
101+
email = 'sandro33810@gmail.com'
102+
}
103+
}
104+
scm {
105+
connection = 'scm:git:git://github.com/NodeLink-Project/NodeLink-Client.git'
106+
developerConnection = 'scm:git:ssh://github.com/NodeLink-Project/NodeLink-Client.git'
107+
url = 'https://github.com/NodeLink-Project/NodeLink-Client'
108+
}
109+
}
110+
}
111+
}
112+
repositories {
113+
maven {
114+
name = 'LocalRepo'
115+
url = uri(layout.buildDirectory.dir('repo'))
116+
}
117+
}
118+
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'NodeLink-Client'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package io.nodelink.client;
2+
3+
import io.nodelink.client.log.Logger;
4+
5+
public class NodeLink extends NodeLinkHelper {
6+
7+
private static NodeLink INSTANCE = new NodeLink();
8+
9+
public static void main(String[] args) {
10+
getHelper().initTerminal();
11+
12+
}
13+
14+
15+
/// Getters ///
16+
17+
public static NodeLink getInstance() {
18+
return INSTANCE;
19+
}
20+
21+
public Logger getLogger() {
22+
return Logger.getLoggerSingleton();
23+
}
24+
25+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.nodelink.client;
2+
3+
import org.jline.reader.LineReader;
4+
import org.jline.reader.LineReaderBuilder;
5+
import org.jline.terminal.Terminal;
6+
import org.jline.terminal.TerminalBuilder;
7+
8+
import java.nio.charset.StandardCharsets;
9+
import java.nio.file.Paths;
10+
11+
public class NodeLinkHelper {
12+
13+
private static NodeLinkHelper INSTANCE = new NodeLinkHelper();
14+
15+
protected void initTerminal() {
16+
try {
17+
Terminal TERMINAL = TerminalBuilder.builder()
18+
.name("NodeLink Client")
19+
.system(true)
20+
.build();
21+
22+
LineReader READER = LineReaderBuilder.builder()
23+
.terminal(TERMINAL)
24+
.variable(LineReader.HISTORY_FILE, Paths.get("bin/history.txt"))
25+
.option(LineReader.Option.AUTO_FRESH_LINE, true)
26+
.option(LineReader.Option.HISTORY_BEEP, true)
27+
.build();
28+
29+
} catch (Exception e) {
30+
NodeLink.getInstance().getLogger().ERROR(e.getMessage());
31+
}
32+
}
33+
34+
/// Getters ///
35+
36+
public static NodeLinkHelper getHelper() {
37+
return INSTANCE;
38+
}
39+
}

0 commit comments

Comments
 (0)