playframework / play-enhancer

14 stars 9 forks source link

javaagent for Play enhancer #6

Open ahtik opened 9 years ago

ahtik commented 9 years ago

Has there been a discussion or plan to have Play enhancer that works as a javaagent or as a separate build process that works outside the SBT build cycle?

Possibly somewhat how https://github.com/ebean-orm/avaje-ebeanorm-agent works. So one can either provide the agent using VM option or a programmatic invoke like ebean agent is supporting:

if (!AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent","debug=0;packages="+packages)) {
      Logger.error("avaje-ebeanorm-agent not found in classpath - not dynamically loaded");
}

This would hopefully make it possible or at least bring it closer to use IDEs compilers to run play apps and tests.

My use case comes from Intellij IDEA where SBT Make process speed is not acceptable. Basic almost empty SBT playframework project takes >10sec to start building and running the project while not reusing any of the classes generated by the IDE. Enhanced classes seem to be one of the primary factors keeping us to get around SBT.

jroper commented 9 years ago

sbt starts up much faster than IntelliJ does - so that argument doesn't make sense. Just like you don't start IntelliJ and then close it every time you want to compile, you'd be crazy to start sbt and then stop it every time you want to compile. sbt is designed to be started with no arguments, and then used from the console. Once started, sbt tends to compile things very fast, plus you can dynamically interact with your build, updating configuration etc. It may be a different way of doing things compared to what you're used to with other tools, but that's the thing about tools, you're meant to work with it in the way it expects, not try to make it look like other tools.

ahtik commented 9 years ago

SBT starts up reasonably fast. The issue with IntelliJ is not the IntelliJ start up time -- it's the fact that Intellij Scala plugin that includes support for SBT and Playframework is unable to reuse an existing SBT session -- at least I have not found a way to make it work and from the web it looks like the support is waiting for SBT server support coming in SBT 1.0.

SBT in itself works all great with Playframework -- but the way tooling could make use of SBT is a bit complicated. At least looks like SBT session reuse is not coming to IntelliJ Scala plugin very soon.

Running Playframework JUnit tests in IntelliJ is taking >10sec just to start up because of not reusing SBT session and not reusing IntelliJ own scala&java compiler.

But we want to move faster and yes, it sound crazy but enhancing Playframework classes outside SBT as a runtime agent sounded like something that would help if existed. We can already run the Play project Junit tests in IntelliJ without SBT when enhancement is disabled (EBean enhancement is done using the above described agent).

There is also ongoing work to use Gradle for playframework builds, I'd think they might have a similar need for non-SBT enhancement (either a manual task for file enhacement or runtime agent).

But yeah, I do realize the idealistic route right now would be to wait for the SBT 1.0 with SBT server support and hope it gets soon integrated into IntelliJ Scala plugin so JUnit test runs would take <1-2sec. But I have no idea how long this could take. Also not sure if IntelliJ could then start reusing the classes generated by the SBT build.

jroper commented 9 years ago

Ok. I haven't given much thought to supporting this via a javaagent, in fact quite the opposite, I'd rather get rid of the Play enhancer altogether. But if someone does implement support for it, that would be great.