Thursday, February 02, 2017

Lightbend Activator Play Framework Windows Distribution

Fix "The Input line is too long" Issue with the
SBT Native Packager

The Problem

When you perform "activator stage" on Windows and then try to run the .bat file in ./target/universal/stage/bin, you get "The input line is too long." And they never seem to fix this issue.

The root cause is that Windows BAT file has a limit on the total number of characters that fit into a line and the launcher lists every JAR file that comprises the app.

The Fix

If you use LauncharJarPlugin within SBT Native Packager this problem solves instantly, without needing to muck with the .BAT file.  As you would know modifying the .bat file is a real pain. 

There are already solutions to this issue posted on StackOverflow and such. The answers are adequate for people who already are very familiar with SBT, but I had to do some lookup as to the correct plugin configurations etc, so I will now summarize those below.


  1. Open ./project/plugins.sbt
  2. Add the following line among anywhere in the block other addSbtPlugin() are decleared. Just to be sure make sure there is a blank line above and below it.

    addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M8")

    Note: 1.2.0-M8 is probably been obsolete by the time you read this article. Check with the Github site of SBT Native Packager for the correct version.

    Also in a later version (1.3.12 for example) of activator/sbt this seems to be "built in". You may not need it.

  3. Java Users: Open build.sbt and change the line that looks like

    lazy val root = (project in file(".")).enablePlugins(PlayJava)


    lazy val root = (project in file(".")).enablePlugins(PlayJava, LauncherJarPlugin)
  4. Scala Uses: Where it says PlayJava is PlayScala. Do not change Scala to Java.

A Side Note

I have also discovered that if you have a ./dist directory in your project root, you can stuff anything in there and when you do "activator stage" or "activator dist" it will add the assets in there. I would put additional installation README.MD server specific startup script, and SQL schema creation or update scripts and such in there so these script can make the distribution.