Skip to content

Commit

Permalink
Add kotlin template (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehyland committed Feb 6, 2023
1 parent 1691b03 commit 15811d7
Show file tree
Hide file tree
Showing 47 changed files with 248 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kotlin/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

8 changes: 8 additions & 0 deletions kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Intelij files
.idea

# Ignore Gradle build output directory
build
11 changes: 11 additions & 0 deletions kotlin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Template Kotlin App

Requires [Hermit](https://github.com/cashapp/hermit) to be installed.

You'll also want to install the hermit gradle plugin.

```shell
gradle :app:test

gradle :app:run
```
16 changes: 16 additions & 0 deletions kotlin/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
id("example.kotlin-application-conventions")
}

dependencies {
implementation("org.apache.commons:commons-text")
}

application {
// Define the main class for the application.
mainClass.set("example.app.AppKt")
}
5 changes: 5 additions & 0 deletions kotlin/app/src/main/kotlin/example/app/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package example.app

fun main() {
println("Yay!")
}
12 changes: 12 additions & 0 deletions kotlin/app/src/test/kotlin/example/app/AppTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package example.app

import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow

class AppTest {
@Test fun testGetMessage() {
assertDoesNotThrow {
main()
}
}
}
1 change: 1 addition & 0 deletions kotlin/bin/.corretto-17.0.6.10.1.pkg
1 change: 1 addition & 0 deletions kotlin/bin/.gradle-7.6.pkg
7 changes: 7 additions & 0 deletions kotlin/bin/README.hermit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hermit environment

This is a [Hermit](https://github.com/cashapp/hermit) bin directory.

The symlinks in this directory are managed by Hermit and will automatically
download and install Hermit itself as well as packages. These packages are
local to this environment.
21 changes: 21 additions & 0 deletions kotlin/bin/activate-hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# This file must be used with "source bin/activate-hermit" from bash or zsh.
# You cannot run it directly
#
# THIS FILE IS GENERATED; DO NOT MODIFY

if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi

BIN_DIR="$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")"
if "${BIN_DIR}/hermit" noop > /dev/null; then
eval "$("${BIN_DIR}/hermit" activate "${BIN_DIR}/..")"

if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ]; then
hash -r 2>/dev/null
fi

echo "Hermit environment $("${HERMIT_ENV}"/bin/hermit env HERMIT_ENV) activated"
fi
1 change: 1 addition & 0 deletions kotlin/bin/gradle
43 changes: 43 additions & 0 deletions kotlin/bin/hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#
# THIS FILE IS GENERATED; DO NOT MODIFY

set -eo pipefail

export HERMIT_USER_HOME=~

if [ -z "${HERMIT_STATE_DIR}" ]; then
case "$(uname -s)" in
Darwin)
export HERMIT_STATE_DIR="${HERMIT_USER_HOME}/Library/Caches/hermit"
;;
Linux)
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HERMIT_USER_HOME}/.cache}/hermit"
;;
esac
fi

export HERMIT_DIST_URL="${HERMIT_DIST_URL:-https://github.com/cashapp/hermit/releases/download/stable}"
HERMIT_CHANNEL="$(basename "${HERMIT_DIST_URL}")"
export HERMIT_CHANNEL
export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}/hermit}

if [ ! -x "${HERMIT_EXE}" ]; then
echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2
INSTALL_SCRIPT="$(mktemp)"
# This value must match that of the install script
INSTALL_SCRIPT_SHA256="180e997dd837f839a3072a5e2f558619b6d12555cd5452d3ab19d87720704e38"
if [ "${INSTALL_SCRIPT_SHA256}" = "BYPASS" ]; then
curl -fsSL "${HERMIT_DIST_URL}/install.sh" -o "${INSTALL_SCRIPT}"
else
# Install script is versioned by its sha256sum value
curl -fsSL "${HERMIT_DIST_URL}/install-${INSTALL_SCRIPT_SHA256}.sh" -o "${INSTALL_SCRIPT}"
# Verify install script's sha256sum
openssl dgst -sha256 "${INSTALL_SCRIPT}" | \
awk -v EXPECTED="$INSTALL_SCRIPT_SHA256" \
'$2!=EXPECTED {print "Install script sha256 " $2 " does not match " EXPECTED; exit 1}'
fi
/bin/bash "${INSTALL_SCRIPT}" 1>&2
fi

exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@"
Empty file added kotlin/bin/hermit.hcl
Empty file.
1 change: 1 addition & 0 deletions kotlin/bin/jar
1 change: 1 addition & 0 deletions kotlin/bin/jarsigner
1 change: 1 addition & 0 deletions kotlin/bin/java
1 change: 1 addition & 0 deletions kotlin/bin/javac
1 change: 1 addition & 0 deletions kotlin/bin/javadoc
1 change: 1 addition & 0 deletions kotlin/bin/javap
1 change: 1 addition & 0 deletions kotlin/bin/jcmd
1 change: 1 addition & 0 deletions kotlin/bin/jconsole
1 change: 1 addition & 0 deletions kotlin/bin/jdb
1 change: 1 addition & 0 deletions kotlin/bin/jdeprscan
1 change: 1 addition & 0 deletions kotlin/bin/jdeps
1 change: 1 addition & 0 deletions kotlin/bin/jfr
1 change: 1 addition & 0 deletions kotlin/bin/jhsdb
1 change: 1 addition & 0 deletions kotlin/bin/jimage
1 change: 1 addition & 0 deletions kotlin/bin/jinfo
1 change: 1 addition & 0 deletions kotlin/bin/jlink
1 change: 1 addition & 0 deletions kotlin/bin/jmap
1 change: 1 addition & 0 deletions kotlin/bin/jmod
1 change: 1 addition & 0 deletions kotlin/bin/jpackage
1 change: 1 addition & 0 deletions kotlin/bin/jps
1 change: 1 addition & 0 deletions kotlin/bin/jrunscript
1 change: 1 addition & 0 deletions kotlin/bin/jshell
1 change: 1 addition & 0 deletions kotlin/bin/jstack
1 change: 1 addition & 0 deletions kotlin/bin/jstat
1 change: 1 addition & 0 deletions kotlin/bin/jstatd
1 change: 1 addition & 0 deletions kotlin/bin/keytool
1 change: 1 addition & 0 deletions kotlin/bin/rmiregistry
1 change: 1 addition & 0 deletions kotlin/bin/serialver
17 changes: 17 additions & 0 deletions kotlin/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build.
`kotlin-dsl`
}

repositories {
// Use the plugin portal to apply community plugins in convention plugins.
gradlePluginPortal()
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
}
7 changes: 7 additions & 0 deletions kotlin/buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This settings file is used to specify which projects to include in your build-logic build.
*/

rootProject.name = "buildSrc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
// Apply the common convention plugin for shared build configuration between library and application projects.
id("example.kotlin-common-conventions")

// Apply the application plugin to add support for building a CLI application in Java.
application
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
id("org.jetbrains.kotlin.jvm")
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
constraints {
// Define dependency versions as constraints
implementation("org.apache.commons:commons-text:1.9")
}

// Use JUnit Jupiter for testing.
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
}

tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
// Apply the common convention plugin for shared build configuration between library and application projects.
id("example.kotlin-common-conventions")

// Apply the java-library plugin for API and implementation separation.
`java-library`
}
11 changes: 11 additions & 0 deletions kotlin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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.6/userguide/multi_project_builds.html
*/

rootProject.name = "example"
include("app")

0 comments on commit 15811d7

Please sign in to comment.