diff --git a/ext-properties/README.md b/ext-properties/README.md new file mode 100644 index 0000000..f2f30db --- /dev/null +++ b/ext-properties/README.md @@ -0,0 +1,5 @@ +# Overview + +This project can serve as starting point for Maven and Java based projects using externl properties. + +# Links diff --git a/ext-properties/pom.xml b/ext-properties/pom.xml new file mode 100644 index 0000000..de7dab4 --- /dev/null +++ b/ext-properties/pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + ext_prop + description + https://swingbe.de + de.swingbe + ext_prop + 0.0.1 + jar + + + + GNU General Public License + https://www.gnu.org/licenses/gpl-3.0.txt + + + + + https://github.com/Software-Ingenieur-Begerad/sandbox-java + + + + + UTF-8 + src/main/resources/version.properties + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + + + 11 + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + true + + shaded + + + + + de.swingbe.ext_prop.Main + + + + + + + + + + org.codehaus.mojo + properties-maven-plugin + 1.1.0 + + + initialize + + read-project-properties + + + + + + src/main/resources/version.properties + + + + + + + + diff --git a/ext-properties/src/main/java/de/swingbe/ext_prop/Main.java b/ext-properties/src/main/java/de/swingbe/ext_prop/Main.java new file mode 100644 index 0000000..2dd013b --- /dev/null +++ b/ext-properties/src/main/java/de/swingbe/ext_prop/Main.java @@ -0,0 +1,29 @@ +package de.swingbe.ext_prop; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Properties; +import java.util.Set; + +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + Properties properties = new Properties(); + java.net.URL url = ClassLoader.getSystemResource("version.properties"); + + try { + properties.load(url.openStream()); + } catch (FileNotFoundException fie) { + fie.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("version: " + properties.getProperty("version")); + Set keys = properties.stringPropertyNames(); + for (String key : keys) { + System.out.println(key + " - " + properties.getProperty(key)); + } + } + + +} diff --git a/ext-properties/src/main/resources/version.properties b/ext-properties/src/main/resources/version.properties new file mode 100644 index 0000000..410af8c --- /dev/null +++ b/ext-properties/src/main/resources/version.properties @@ -0,0 +1 @@ +version = ${project.version}