Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using multiple projects in Eclipse with Play framework 2.1.x

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.

like image 284
Mel Nicholson Avatar asked Mar 27 '13 18:03

Mel Nicholson


People also ask

How do I import a play framework project into Eclipse?

You then need to import the application into your Workspace with the File/Import/General/Existing project… menu (compile your project first). To debug, start your application with sbt -jvm-debug 9999 run and in Eclipse right-click on the project and select Debug As, Debug Configurations.

Which IDES can be used for play applications?

Play supports the NetBeans, IntelliJ IDEA and Eclipse platforms.

How do you set content type explicitly on play?

Changing the default Content-Type Will automatically set the Content-Type header to text/plain , while: JsonNode json = Json. toJson(object); Result jsonResult = ok(json); will set the Content-Type header to application/json .


2 Answers

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.

like image 167
javing Avatar answered Oct 21 '22 20:10

javing


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

like image 1
Anton Avatar answered Oct 21 '22 21:10

Anton