11

I have an existing project in Eclipse (let's call it "NotPlayProj") which has a lot of java code still under development. I made a new eclipse project using play 2.1.0 (let's call it "PlayProj"). My goal is to use code from NotPlayProj in PlayProj and have both Eclipse and the Play compiler notice changes in either project.

If I go into the properties for PlayProj and add NotPlayProj via the Project tab, then method completion and inclusion works within eclipse, but the Play compile doesn't see the result. I've looked at Play modules and those don't seem to do what I want.

Is there any way to do this, ideally without modifying the NotPlayProj?

Edit --- I've looked at http://www.playframework.com/documentation/2.0/SBTDependencies which shows how to export a jar from NotPlayProj into the PlayProj/lib directory, but this requires a manual export for each time NotPlayProject changes. I suspect that the Managed dependency section is supposed to cover this, but I've never used SBT before and am therefore probably missing something basic.

adis
  • 5,901
  • 7
  • 51
  • 71
Mel Nicholson
  • 3,225
  • 14
  • 24
  • Did you read this post, perhaps it helps: http://stackoverflow.com/questions/10226919/reload-app-on-custom-file-change-in-playframework – adis Mar 29 '13 at 21:22
  • Thanks for the reference adis. It isn't quite what I need, but it's in the general ballpark. I think I need to learn sbt from scratch. – Mel Nicholson Apr 01 '13 at 22:35
  • Is this what you're looking to do http://stackoverflow.com/questions/10090829/how-to-reference-a-different-java-project-in-eclipse ? – th3byrdm4n Apr 02 '13 at 04:33
  • No. The method described in that question just handles the eclipse side of things, which I already have working. I need to find a way to get the Play compiler to look at the other project without manually exporting the classes after every change. So far it seems that the only way play can handle that is to make the other project into an SBT build. – Mel Nicholson Apr 02 '13 at 04:43

3 Answers3

2

What you need is continuous integration.

Have a look at Jenkins: http://jenkins-ci.org/ You should setup a Continuous integration server and customize the builds you need.

Example: You have your PlayProj running in some server, it needs to be able to use some of the latest classes from the other project called NoPlayProj.

Rebuild is a must, things such as downtime zero are difficult to achieve(At least I don't think this is what you are asking for either). The steps you need to automate with Jenkins are:

1 - Build and deploy the latest version of NoPlayProj which is located in some repositorium

2 - Build and deploy the latest version of PlayProj which is located in some repositorium and also is contains your last commit where you updated the dependency that exist with NoPlayProj

A not very complex build and deployment instructions can be configured in Jenkins. This should speed you up a bit. Also another suggestion would be to mavenize both projects if possible, this will help you manage the dependencies easier.

Just to clarify one thing, you said: My goal is to use code from NotPlayProj in PlayProj and have both Eclipse and the Play compiler notice changes in either project.

Well the order in which you execute the builds will be dependent in what you want to do as long as you update the dependency before you commit the code.

One last thing, if you don't want to deploy you don't have to do so you can create the Jenkins jobs, in such ways that you only build. With Jenkins you can do a lot of stuff, also you could execute some help scripts of your own that can provide you additional functionality.

I hope this was useful.

javing
  • 12,307
  • 35
  • 138
  • 211
1

To let Eclipse see changes in NotPlayProj when working with PlayProj, it's enough to change configuration of PlayProj. Properties-> Java build path -> Projects -> Add NotPlayProj as dependency.

There is no straightforward way to let Play compiler handle dependencies, until you package it as jar. Consider configuration of simple ant task (External tools configuration -> Ant build ), which will copy your jar file. Task can be triggered by pressing the key or button.

With managed dependencies, every time you made change in NotPlayProj, you have to manually rebuild it. To let Ivy/Maven put dependency in your local repository. After that Play will take latest snapshot from your local repository.

Both approaches requires some efforts. Maybe you can take a look at Python scripts, which run Play, maybe it's enough to extend classpath with NotPlayProj when executing play start

Anton
  • 5,831
  • 3
  • 35
  • 45
0

Though I've never used the play framework, I would think that there is a format that both the play framework and eclipse understand and that is Maven. Look at http://www.playframework.com/modules/maven-head/home

Friso
  • 1,080
  • 6
  • 37