Running ApsctJ in Intellij IDEA with Scala - scala

I am using Intellij IDEA Community Edition 14.0.3 for Scala development. I am having AspectJ in my application. I am using sbt-aspect v0.10.1.
I am able to run everything fine when I run the application from SBT console. However, when I use run from the intellij menu, it is not invoking the aspect.
Because of this, I am not able to run in Debug Mode. How can I make it work with intellij ?

I have the same issue.
My workaround is:
Open project Run/Debug configuration on IntelliJ IDEA
In the VM Options field type: -javaagent:path/to/aspectjweaver.jar
path/to/aspectjweaver.jar in my case is C:\Users\aelkin\.ivy2\cache\org.aspectj\aspectjweaver\jars\aspectjweaver-1.8.13.jar

Actually I do not use Scala in IntelliJ IDEA, but Java. Anyway, a quick web search led me to the SBT Community Plugins page which lists these links:
Plugins for IDEs
IntelliJ IDEA
sbt Plugin to generate IDEA project configuration: https://github.com/mpeltonen/sbt-idea
IDEA Plugin to embed an sbt Console into the IDE: https://github.com/orfjackal/idea-sbt-plugin
At the time of writing this GitHub is down for database maintenance, so I cannot check on the projects mentioned there, but in 15 minutes or you should be able to navigate there by yourself and see if the repos actually contain something useful for you.

Related

Intellij IDEA - Cannot add framework support for Scala

I have sbt 0.13.16 and Scala 2.10.6 running with Intellij 2018.2.1, working with those recommended sbt and Scala settings for Odersky's coursera course on Scala (I'm guessing their automated submission grader depended on old SBT?).
When creating new sbt + scala projects, I choose the above sbt and Scala versions, then after all the dependencies have downloaded, when I right-click New -> ... I see options for Java class but nothing for Scala. I have the Scala plugin already there according to the plugin settings.
So I try to Add Framework Support after right-clicking on the project, I select Scala, but then everything is disabled except Cancel.
I looked through previous forums, found one but that seemed relevant only for git projects.
Anyone else run into this issue? Do I need to update to more recent Scala and SBT? Any help would be very appreciated.
Please check https://plugins.jetbrains.com/plugin/1347-scala/versions for a compatibility table.
You can manage plugins in IntelliJ Preferences. Your versions seem to be too old to still be supported, already. It may help to upgrade IntelliJ and then go to preferences and get the latest Scala and SBT plugins.

Play framework support in IntelliJ IDEA Community Edition

I installed IDEA version 15 with the Scala plugin, but Play projects are enabled only in the Ultimate edition. I'm new to Scala and Play, any issues if I run Play outside of IDEA? Would Play "hot deploy" any changes I make in scala source code?
Just open it as an SBT project and it's fine.
This is how it works: (1) create a project using play/activator, (2) open IntelliJ and import as SBT project (accept all defaults), (3) run the project in a command line (externally to IntelliJ), (4) edit project source files in IntelliJ - when you update a file, it is automatically compiled (you can see that refreshing the url localhost:9000)
Play works great outside of IntelliJ. I have developed play applications using Sublime Text and Atom. You'll get the errors in the console, or in the web application itself.
There's also a NetBeans plugin now (http://nbpleasureplugin.com), and the official ScalaIDE should also support it (although I've never tried using it).

To use play framework, Do I have to pay intellij ultimate edition?

I am now struggling into specifying workspace for 'play for java'
In the first place, I choose eclipse luna, but it occurs error with twirl template engine.
it seemingly doesn't work in eclipse, but it works.
so, now i decide to use intellij, however intellij community edition can not use play framework with java, some people said to me 'use sublime text' but I don't want to use text editor, cause It doesn't support auto-import,
now, Do I have to pay for intellij ultimate edition for play development?
I am highschool student in korea, I can not pay ultimate edition, because I have no money.
Play can absolutely be used with IntelliJ IDEA Community Edition. I frequently run a Play application with SBT on the command line, then edit my Scala and debug in IntelliJ CE. This won't be as "integrated" of a solution as you would get with Ultimate Edition (for example, the routes file won't have navigation integrated), but it is quite workable. A few tips:
In IntelliJ, make sure that you have the Scala plugin installed.
You can export an IDEA project from your SBT project with this SBT plugin: https://github.com/mpeltonen/sbt-idea
To enable debugging, launch sbt -jvm-debug=9999, as documented here: https://www.playframework.com/documentation/2.3.x/PlayConsole
To debug from IntelliJ, create a remote run target that connects to localhost on port 9999, then click the debug toolbar button with SBT running in debug mode.
JetBrains will give you a one year license to IntelliJ if you can prove you are a student. Having a school email address is proof enough.
https://www.jetbrains.com/student/#faq
JetBrains has an excellent student program. You can use all products for free (including intelliJ Ultimate). https://www.jetbrains.com/student/

How do I run SBT from within Eclipse?

So far I've been running IntelliJ IDEA Community Edition for my Scala projects, but as my projects are expanding in complexity, I stumble upon more and more roadblocks with the IDE.
Like for example the simple fact that IDEA doesn't allow for web-development or Java EE development what so ever, which means using the Play Framework or TomEE in Community Edition leads to nothing but dead ends and frustration.
The only reason I switched to IDEA in the first place, is because of its excellent plugin system, allowing me to run SBT seamlessly as the primary scala compiler and library downloading tool with ease.
Searching around on Google, however I can only seem to find mentions about the eclipse plugin for sbt, that makes an sbt project Eclipse friendly, which is the exact opposite of what I'm really looking for.
I'm not willing to spend €89 per year for a student licence after all the pain it's put me through so far...
So my question is; is there a plugin for Eclipse that allows me to use SBT the same way as in IDEA? Or am I forced to go through the console?
There may be some movement in this direction in the future, but for now there is no such plugin.
Currently there is no Sbt plugin for Eclipse. Depending on your use-case, you could:
use the Eclipse builder
Pros: proper integration (error markers in Problems and editors, cancelation, progress reporting)
Cons: may get out-of-sync with the Sbt build file (when adding a dependency, for example), doesn't handle anything other than Java and Scala (like Play templates or route files)
use Sbt on the command line (make sure to disable auto-building in Eclipse)
Pros: can handle complex builds, classpath is always up to date
Cons: no integration (see above)
use Activator
Same Pros and Cons as Sbt, but with a pretty UI
We are working on an sbt-server plugin for Eclipse, which will delegate the build to an external Sbt process without giving up the convenience of integration. We hope to have something out towards the end of this year.
I think the main problem you are trying to solve for is too have sbt jar dependencies show up and get used natively by your eclipse project. You can do that with the IvyIDE plugin (which is found in the eclipse marketplace).
If you have that installed (and the eclipse plugin for sbt) then this closes the gap between systems.
To enable:
type the {sbt deliver-local} command from your terminal. This adds an ivy xml in your project's target directory
right click on your project. Choose the Ivy -> enable Ivy dependency management option
go into your projects properties. Highlight the Ivy property. Click the new button and navigate to the ivy xml file in your projects target directory.
Now your eclipse compiles off of your sbt managed dependencies and now you are doing everything you want except actually running sbt from within eclipse (which you only have to do now when you are changing dependencies)

a Java code analysis tool for intelliJ and Eclipse is needed

Does anyone has an experience with a code analysis tool that has a working plugin for both eclipse and intelliJ?
Both FindBugs and CheckStyle work well with intelliJ 10 and eclipse. you may have to modify the JVM setting for the plugins to work.
but it works.
have you also tried PMD? http://pmd.sourceforge.net/integrations.html
I'm an intelliJ user but it works for Eclipse. I would prefer FindBugs/PMD to CheckStyle. To be honest I use intelliJ's (9 version) built in Inspection tool as well. You will find this previous thread in SO useful Checkstyle vs. PMD
Found this plugin (multiple integration including PMD/FindBugs) for intelliJ this morning (yet to try) but here's the link http://plugins.intellij.net/plugin/?idea&id=4596