Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit b050360

Browse files
author
mInTRuns
committed
change bootstrap
added pom extraction to get allocation of pom
1 parent 8801198 commit b050360

File tree

15 files changed

+257
-30
lines changed

15 files changed

+257
-30
lines changed

.idea/SameLogger.iml

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

.idea/artifacts/SameLogger_jar.xml

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

.idea/compiler.xml

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

.idea/jarRepositories.xml

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

.idea/libraries/Maven__org_apache_maven_maven_model_3_6_3.xml

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

.idea/libraries/Maven__org_codehaus_plexus_plexus_utils_3_2_1.xml

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

.idea/misc.xml

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

pom.xml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,35 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>org.example</groupId>
7+
<groupId>de.mint.logger</groupId>
88
<artifactId>SameLogger</artifactId>
9-
<version>1.0-SNAPSHOT</version>
10-
9+
<version>v0.0.2</version>
10+
<organization>
11+
<name>https://github.com/mInT-runs</name>
12+
</organization>
13+
<build>
14+
<plugins>
15+
<plugin>
16+
<groupId>org.apache.maven.plugins</groupId>
17+
<artifactId>maven-compiler-plugin</artifactId>
18+
<configuration>
19+
<source>8</source>
20+
<target>8</target>
21+
</configuration>
22+
</plugin>
23+
</plugins>
24+
</build>
25+
<developers>
26+
<developer>
27+
<id>mint</id>
28+
</developer>
29+
</developers>
30+
<description>SameLogger is an Logger to handle and save (Error/Input) stream of all executable files!</description>
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.apache.maven</groupId>
34+
<artifactId>maven-model</artifactId>
35+
<version>3.6.3</version>
36+
</dependency>
37+
</dependencies>
1138
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package de.mint.logger.handlerservice;
2+
3+
import de.mint.logger.mainservice.SameLogger;
4+
import de.mint.logger.objectservice.SameLoggerObject;
5+
6+
import java.io.File;
7+
import java.io.IOException;
8+
import java.io.InputStream;
9+
import java.net.JarURLConnection;
10+
import java.net.URL;
11+
import java.util.jar.JarEntry;
12+
import java.util.jar.JarFile;
13+
14+
public class JarHandler {
15+
16+
private JarURLConnection getJarUrlConnection(final String path) throws IOException {
17+
final File file = new File(SameLogger.class.getProtectionDomain().getCodeSource().getLocation().getPath()); //get current file location
18+
final String urlPath = "jar:file:" + (System.getProperty("os.name").toLowerCase().contains("windows") ? "/" : "") + file.getAbsolutePath() + "!/" + path;
19+
final URL url = new URL(urlPath); //load url
20+
return (JarURLConnection) url.openConnection(); //return java-url-connection
21+
}
22+
23+
public InputStream getPomFromJar() {
24+
try {
25+
final JarURLConnection jarURLConnection = this.getJarUrlConnection("pom.xml");
26+
final JarFile jarfile = jarURLConnection.getJarFile();
27+
final JarEntry jarEntry = jarURLConnection.getJarEntry();
28+
return jarfile.getInputStream(jarEntry);
29+
} catch (final IOException exception) {
30+
SameLoggerObject.getSameLoggerObject().getLogger().warning(exception.getMessage());
31+
}
32+
return null;
33+
}
34+
}

src/main/java/de/mint/logger/mainservice/SameLoggerBootStrap.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.mint.logger.mainservice;
22

33
import de.mint.logger.objectservice.SameLoggerObject;
4+
import de.mint.logger.utilservice.Logger;
45

56
import java.io.*;
67
import java.util.Arrays;
@@ -12,9 +13,6 @@
1213
public class SameLoggerBootStrap {
1314

1415
private FileWriter fileWriter;
15-
private final String version = "v0.0.1";
16-
private final String developer = "mint (Niklas)";
17-
private final String github = "https://github.com/mInT-runs";
1816
private final UUID uuid = UUID.randomUUID();
1917
private final String fileName = "SameLogger/SameLogger_" + this.uuid + ".log";
2018

@@ -68,7 +66,7 @@ public void run() {
6866
timer.cancel();
6967
}
7068
} catch (final IOException exception) {
71-
exception.printStackTrace();
69+
SameLoggerObject.getSameLoggerObject().getLogger().warning(exception.getMessage());
7270
}
7371
}
7472
}, 0, 1);
@@ -87,7 +85,7 @@ void bootStrap(final String... command) {
8785
try {
8886
this.initializedLoggerRunnable(this.checkIsJarFile(command) ? SameLoggerObject.getSameLoggerObject().getProcessManager().inputStream() : SameLoggerObject.getSameLoggerObject().getProcessManager().errorStream());
8987
} catch (final IOException exception) {
90-
exception.printStackTrace();
88+
SameLoggerObject.getSameLoggerObject().getLogger().warning(exception.getMessage());
9189
}
9290
} else {
9391
System.exit(-1);
@@ -118,19 +116,12 @@ void initializedLogo() {
118116
" ___) | (_| | | | | | | __/ |__| (_) | (_| | (_| | __/ | \n" +
119117
" |____/ \\__,_|_| |_| |_|\\___|_____\\___/ \\__, |\\__, |\\___|_| \n" +
120118
" |___/ |___/ \n");
121-
System.out.println("\nversion: " + this.version + " - developer: " + this.developer + " - github: " + this.github + "\n");
122-
}
123-
124-
public String getVersion() {
125-
return version;
126-
}
127-
128-
public String getDeveloper() {
129-
return developer;
130-
}
131-
132-
public String getGithub() {
133-
return github;
119+
SameLoggerObject.getSameLoggerObject().getLogger().info(SameLoggerObject.getSameLoggerObject().getLogger().getPOMInformation(Logger.PomAllocation.DESCRIPTION).toString()+"\n");
120+
SameLoggerObject.getSameLoggerObject().getLogger().info("Developer: "+SameLoggerObject.getSameLoggerObject().getLogger().getPOMInformation(Logger.PomAllocation.DEVELOPERS).toString());
121+
SameLoggerObject.getSameLoggerObject().getLogger().info("ArtifactID: "+SameLoggerObject.getSameLoggerObject().getLogger().getPOMInformation(Logger.PomAllocation.ARTIFACT_ID).toString());
122+
SameLoggerObject.getSameLoggerObject().getLogger().info("Version: "+SameLoggerObject.getSameLoggerObject().getLogger().getPOMInformation(Logger.PomAllocation.VERSION).toString());
123+
SameLoggerObject.getSameLoggerObject().getLogger().info("GroupID: "+SameLoggerObject.getSameLoggerObject().getLogger().getPOMInformation(Logger.PomAllocation.GROUP_ID).toString());
124+
SameLoggerObject.getSameLoggerObject().getLogger().info("Github: "+SameLoggerObject.getSameLoggerObject().getLogger().getPOMInformation(Logger.PomAllocation.ORGANISATION).toString()+"\n");
134125
}
135126

136127
public UUID getUuid() {

0 commit comments

Comments
 (0)