From 25cf56c551bc0e2e7d6a1629d109d50aa8f9aa84 Mon Sep 17 00:00:00 2001 From: Jonas Tobias Hopusch Date: Thu, 2 Sep 2021 17:04:56 +0200 Subject: [PATCH] Initialize Gradle project without wrapper and add basic main --- .gitattributes | 6 +++ .gitignore | 15 +++++++ app/build.gradle.kts | 42 +++++++++++++++++++ .../main/kotlin/de/jotoho/waituntil/start.kt | 32 ++++++++++++++ app/src/test/kotlin/waituntil/AppTest.kt | 14 +++++++ gradle.properties | 1 + settings.gradle.kts | 11 +++++ 7 files changed, 121 insertions(+) create mode 100644 .gitattributes create mode 100644 app/build.gradle.kts create mode 100644 app/src/main/kotlin/de/jotoho/waituntil/start.kt create mode 100644 app/src/test/kotlin/waituntil/AppTest.kt create mode 100644 gradle.properties create mode 100644 settings.gradle.kts diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..00a51af --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf + diff --git a/.gitignore b/.gitignore index b065a68..010b909 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,18 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build + +# Ignore gradle wrapper +/gradle +/gradlew +/gradlew.bat + +# Ignore manual compilation results +/de/jotoho/ +/META-INF diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..81f3487 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,42 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This generated file contains a sample Kotlin application project to get you started. + * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle + * User Manual available at https://docs.gradle.org/7.2/userguide/building_java_projects.html + */ + +plugins { + // Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin. + id("org.jetbrains.kotlin.jvm") version "1.5.0" + + // Apply the application plugin to add support for building a CLI application in Java. + application +} + +repositories { + // Use Maven Central for resolving dependencies. + mavenCentral() +} + +dependencies { + // Align versions of all Kotlin components + implementation(platform("org.jetbrains.kotlin:kotlin-bom")) + + // Use the Kotlin JDK 8 standard library. + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + + // This dependency is used by the application. + implementation("com.google.guava:guava:30.1.1-jre") + + // Use the Kotlin test library. + testImplementation("org.jetbrains.kotlin:kotlin-test") + + // Use the Kotlin JUnit integration. + testImplementation("org.jetbrains.kotlin:kotlin-test-junit") +} + +application { + // Define the main class for the application. + mainClass.set("de.jotoho.waituntil.StartKt") +} diff --git a/app/src/main/kotlin/de/jotoho/waituntil/start.kt b/app/src/main/kotlin/de/jotoho/waituntil/start.kt new file mode 100644 index 0000000..3b90fbc --- /dev/null +++ b/app/src/main/kotlin/de/jotoho/waituntil/start.kt @@ -0,0 +1,32 @@ +package de.jotoho.waituntil + +// This file contains the main function and other utility function necessary for interpreting the terminal arguments. +// See README.md and LICENSE.md for license information +// Author: Jonas Tobias Hopusch (@jotoho) + +fun main(args: Array) { + val optionDictionary = mapOf(Pair("-h", "--help")); + + val options = HashSet(); + val words = HashSet(); + + for (arg in args) { + if (arg.startsWith("--")) { + options.add(arg.substring(startIndex=2)) + } + else if (arg.startsWith('-')) { + val translation = optionDictionary.get(arg); + if (translation != null) + options.add(translation.substring(startIndex=2)); + else + System.err.println("Short-hand '$arg' does not exist. Ignoring!"); + } + else + words.add(arg); + } + + println("Content of options:"); + println(options.toString()); + println("Content of words:"); + println(words.toString()); +} diff --git a/app/src/test/kotlin/waituntil/AppTest.kt b/app/src/test/kotlin/waituntil/AppTest.kt new file mode 100644 index 0000000..73edc1c --- /dev/null +++ b/app/src/test/kotlin/waituntil/AppTest.kt @@ -0,0 +1,14 @@ +/* + * This Kotlin source file was generated by the Gradle 'init' task. + */ +package de.jotoho.waituntil + +import kotlin.test.Test +import kotlin.test.assertNotNull + +class AppTest { + @Test fun appHasAGreeting() { + val classUnderTest = App() + assertNotNull(classUnderTest.greeting, "app should have a greeting") + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..6b1823d --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.daemon=false diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..9c984f8 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,11 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/7.2/userguide/multi_project_builds.html + */ + +rootProject.name = "de.jotoho.waituntil" +include("app")