configuration

How to use the Lightbend Config library in a Scala or Java application alvin December 10, 2019 - 11:47am

Table of Contents

  1. Solution
  2. Discussion
Table of Contents1 - Solution2 - Discussion

Scala problem: You want to be able to read configuration files that are written in the Lightbend “Config” file format.

Back to top

Solution

Lightbend — initially named Typesafe — created a configuration file format named HOCON, which stands for, “Human-Optimized Config Object Notation.” As an example, a small HOCON configuration file looks like this:

How to control/configure vim colors

vim colors FAQ: Can you provide details on how to control/configure colors in the vim editor (vim color settings)?

When using vim syntax highlighting, a common complaint is that the default color scheme is a little too bold. In this article I'll try to demonstrate how you can change the colors in vim to be a little more pleasing, or at least be more in your control.

How to configure an Android project to use Java 8

As a quick note today, if you need to configure an Android project to use Java 8, I found that adding this setting to the app-level build.gradle file worked:

compileOptions {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}

You can also use this syntax:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

That setting goes inside the android setting in the build.gradle file, as shown here:

Using Jenkins with Scala, ScalaTest, SBT, and Git

I’ve used Jenkins before, but hadn’t used it in a while, so when I got it running with Scala, SBT, ScalaTest, and Git, I made some notes about how to configure it. You can get Jenkins going with Docker, but I just got Jenkins running by starting its WAR file like this:

java -jar jenkins.war

Jenkins with Scala, SBT, ScalaTest, and Git

My notes on getting everything up and running are a little cryptic, but if you have a little experience with Jenkins I hope they’ll make sense. Here they are:

How to manually specify the custom location of a Typesafe Config configuration file alvin May 12, 2018 - 6:19pm

If you need to manually specify the custom location of a Lightbend Config configuration file when running a Scala or Java application, I can confirm that this java command setting works:

java -Dconfig.file=my_app.conf [the rest of your app parameters]
     -------------------------

In my case I read the Lightbend Config file like this in my Scala application:

How do I set the Play Framework 2.6 port in production mode?

Play Framework FAQ: How do I set the Play Framework 2.6 port in production mode?

You set the port that your Play Framework application listens on by passing the http.port parameter to the “run” script for your application:

-Dhttp.port=5150

Here’s an example of a command I use to execute the run script for a Play Framework application named myapp:

How do I generate a secret key (application key) with Play Framework 2.6?

Play Framework FAQ: How do I generate a secret key (application key) with Play Framework 2.6?

Answer: Use the playGenerateSecret command in the SBT shell. Here’s an example:

$ sbt

[Scrupal6] $ playGenerateSecret
[info] Generated new secret: TozWYjreCna1QlVBGqfK4D/C6wZyQOm9gm<9;D_KO@]n
[success] Total time: 0 s, completed Apr 4, 2018 2:21:57 PM

How to use a Maven repository library with SBT

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 18.17, “Using a Maven Repository Library with SBT.”

Problem

When working on a Scala project built with SBT, you want to use a Java library that’s in a Maven repository, but the library doesn’t include information about how to use it with Scala and SBT.

SBT: How to get started using the Build.scala file (instead of build.sbt)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 18.16, “Using Build.scala Instead of build.sbt.”

Problem

In an SBT project, you want to use the project/Build.scala file instead of build.sbt to define your Scala project, or you need some examples of how to use Build.scala to solve build problems that can’t be handled in build.sbt.