Showing posts with label Activator. Show all posts
Showing posts with label Activator. Show all posts

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.

Steps

  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)

    to

    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.





Wednesday, November 02, 2016

IntelliJ Ultimate Debugging JavaScript from the LightBend Activator/Play Framework

Symptom

You tried to debug a {java | type|}script in Chrome browser and it does not fire a breakpoint.

You have already made sure that JetBrain extension is installed in Chrome and configured right.

You've also added the JavaScript debugging configuration, and the web page launches (e.g., http://localhost:9000)

Fix

There is one more missing piece to this puzzle. You need to map the URL for where the scripts come from. This is clearly documented in the IntelliJ documentation, but nevertheless, it is not intuitive enough that it took a while for me to find out.

The key is that you need to type in the Remote URL in the Remote URL list. This is NOT OPTIONAL for Play users. If you are running the "out of the box" configuration of Play framework, and putting in your *.js under the "public" directory somewhere, then all you need to do is to just type in /assets (will become http://assets after you save it without any ill effect) where the public folder is in the list. Save it and any JavaScript or Typescript (with a map) can be debugged.

Enjoy!





Sunday, May 24, 2015

IntelliJ IDEA 14.x How To Resolve "routes" Activator/Play Object

Problem:

You just imported the SBT project of Activator or Play framework app in IntelliJ IDEA (14), and you found that you "routes" among other symbols do not resolve.

Root Cause:

You are lacking the dependency for the auto-generated routing class.

Solution:

You can add Module Dependency to classes_managed. This is located in the target/scala_2.xx/classes_managed

I originally posted a similar solution, but this one is much better and works with Play 2.3 or later. This video shows you exactly what you will need to do.