Today I finally had some time to toy around with the Play! Framework
(
http://www.playframework.org).
Sadly, Lombok and Play! didn't work together out of the box. So I
investigated and came up with a pretty simple solution.
The basic idea is to add Lombok as a JVM-Agent when Play! does it's
wizardry. This makes sense because Play! uses the Eclipse compiler to
compile modified classes and hotswap them into the running system and
Lombok hooks itself into eclipse as a JVM-Agent.
<-- Small How-To-Guide: -->
Tested with Play! 1.2.1 and the Lombok edge-release.
1. Get Play! and Lombok
2. Add the 'lombok.jar' to '${PLAY_HOME}/framework/'
3. Add the 'org.eclipse.equinox.common.jar' to '${PLAY_HOME}/framework/
lib'.
4. Apply the following patch to update the 'application.py':
--- a/framework/pym/play/application.py
+++ b/framework/pym/play/application.py
@@ -139,7 +139,8 @@ class PlayApplication:
# The default
classpath.append(os.path.normpath(os.path.join(self.path,
'conf')))
-
classpath.append(os.path.normpath(os.path.join(self.play_env["basedir"],
'framework/play-%s.jar' % self.play_env['version'])))
+ classpath.append(os.path.normpath(self.play_path()))
+ classpath.append(os.path.normpath(self.lombok_path()))
# The application
if os.path.exists(os.path.join(self.path, 'lib')):
@@ -163,9 +164,12 @@ class PlayApplication:
return classpath
- def agent_path(self):
+ def play_path(self):
return os.path.join(self.play_env["basedir"], 'framework/play-
%s.jar' % self.play_env['version'])
+ def lombok_path(self):
+ return os.path.join(self.play_env["basedir"], 'framework/
lombok.jar')
+
def cp_args(self):
classpath = self.getClasspath()
cp_args = ':'.join(classpath)
@@ -246,7 +250,7 @@ class PlayApplication:
java_args.append('-Xrunjdwp:transport=dt_socket,address=
%s,server=y,suspend=n' % self.jpda_port)
java_args.append('-Dplay.debug=yes')
- java_cmd = [self.java_path(), '-javaagent:%s' %
self.agent_path()] + java_args + ['-classpath', cp_args, '-
Dapplication.path=%s' % self.path, '-Dplay.id=%s' %
self.play_env["id"], className] + args
+ java_cmd = [self.java_path(), '-javaagent:%s' %
self.lombok_path(), '-javaagent:%s' % self.play_path()] + java_args +
['-classpath', cp_args, '-Dapplication.path=%s' % self.path, '-
Dplay.id=%s' % self.play_env["id"], className] + args
return java_cmd
class PlayConfParser:
5. If you use Eclipse, make sure to eclipify your application again.
It would be nice if some of you guys would try it out and tell me how
it went. Feedback is very welcome.
Note:
I haven't tested deployment yet, but when the time comes I let you
know if I stumbled over something.
-Philipp