Introduction

The source code is available on GitHub and is licensed under the Apache-2.0 license.

The Simple-Kotlin template allows you to create a Kotlin project with a main class and a test class.

It provides a build.gradle.kts file that adds support for:

Getting Started

You can generate a project skeleton based on the Simple-Kotlin template by using the BootHub GUI or the BootHub CLI.

After providing the template-independent data, you need to configure the Maven groupId of your project:


Maven groupId: org.myproject


Then you need to configure the artifact ID, the base package and the name of the main class of your application:


Artifact ID [my-project]: ​
Base package [org.myproject]: ​
Application main class name [MyProjectMain]: ​MyApp


The next step is to provide information about the project developers:


Developers
Developer ID [jsmith]:
Developer name [John Smith]:
Developer email (optional):
More developers? (Y/N) [N]:

Then you specify whether the generated Gradle script should include additional tasks such as checking the presence of license headers or uploading artifacts to Bintray.


Check license header? (Y/N) [Y]: ​
Add support for uploading to Bintray? (Y/N) [Y]: ​

Finally, you choose your preferred test framework:


Test Framework:
  1: JUnit 4
  2: JUnit 5
* 3: kotlin.test
  4: Spek
Enter your choice: ​​4

User Guide

After generating the project skeleton and creating a working copy on your computer, you can build the project with:

gradlew build

You can also build an uncompressed distribution by executing:

gradlew installDist

Let us consider that your project is called my-project and your main application class is named MyApp. Then, running the start script found in the build/install/myProject/bin directory, the following text should appear on your terminal:

Hello from MyApp!

IntelliJ Idea

  • start the IntelliJ Idea IDE

  • open build.gradle.kts

Eclipse

  • start the Eclipse IDE

  • install a recent version of Buildship

  • import the project using the Gradle Project wizard

Versioning

The file gradle.properties contains variables that are used to create a version string conforming to the semantic versioning standard. The names of these variables are prefixed by the camelCase representation of the project name, for example: myProjectVersionMajor, myProjectVersionMinor, myProjectVersionPatch.

Additionally, a boolean variable (named for example myProjectReleaseBuild) is used to specify whether the current build represents a release or a snapshot.

By editing the values of these variables you can change the version of your project.

For example, to bump your project version to 1.2.3-SNAPSHOT, your gradle.properties should contain:

myProjectVersionMajor = 1
myProjectVersionMinor = 2
myProjectVersionPatch = 3
myProjectReleaseBuild = false

License header check

The Gradle build script uses the license-gradle-plugin to check if your source files include the header provided in the license-header.txt file.

Publishing to JCenter and Maven Central

The Gradle task bintrayUpload lets you publish your artifacts to Bintray. You can then include your packages in JCenter and synchronize them with Maven Central.

Before being able to execute the bintrayUpload task, you need to configure your credentials.

Credentials

Your Gradle build script uses the gradle-properties-plugin, which allows you to configure additional project properties in the gradle-local.properties file.

This is the file in which you should configure your credentials. Since gradle-local.properties is already listed in your project’s .gitignore file, your credentials will not be committed to git.

To create this file you can simply copy the provided template file gradle-local-template.properties to gradle-local.properties. The content of this file is shown below:

signingKeyId = A0B1C2D3
signingSecretKeyRingFile = /users/jsmith/gpg/jsmith.gpg

bintrayUser = jsmith
bintrayKey = a0b1c2d3e4f5a0b1c2d3e4f5a0b1c2d3e4f5a0b1

You need to configure the appropriate values for the above properties, which are used for signing your artifacts and for granting you access to Bintray.

The signing credentials consist of:

  • the public key ID (an 8 character hexadecimal string)

  • the absolute path to the secret key ring file containing your private key

  • the passphrase used to protect your private key

The passphrase of your private key is a very sesnsitive information, therefore it is not stored in the gradle-local.properties. Instead, Gradle will ask you to enter it each time you execute the bintrayUpload task.

See the GnuPG documentation and the Gradle signing plugin for details on how to create and configure your signatures.

The Bintray credentials consist of your Bintray user name and your Bintray API Key. See the documentation of the gradle-bintray-plugin for more details.

Developer Guide

This section is for developers who want to fix bugs or change the functionality of the Simple-Kotlin template.

Read about writing BootHub templates before starting to change the Simple-Kotlin template.

The Simple-Kotlin template comes with a suite of tests that generate various skeletons and check their validity. You should update these tests and add new ones according to the changes you make.

Command Line Build

The Simple-Kotlin template is built with Gradle and requires JDK 8 or higher. Clone the GitHub repository, cd into the top directory and start the build:

git clone https://github.com/boothub-org/boothub-template-simple-kotlin.git
cd boothub-template-simple-kotlin
./gradlew clean build            (On Windows: gradlew clean build)

IntelliJ Idea

  • start the IntelliJ Idea IDE

  • open build.gradle.kts

Eclipse

  • start the Eclipse IDE

  • install a recent version of Buildship

  • import the project using the Gradle Project wizard