Play Framework 2.1 application mounted as an IntelliJ Module - intellij-idea

Known is the command to create IntelliJ files needed for a Play application:
play idea with-sources=yes
This generates two folders:
.idea (containing libraries.xml)
.idea_modules
Most of tutorials or simple article on the net explain how to mount the app as an IntelliJ Project.
However, I want to mount it as a Module (as part of an existing project so), thus I've just used the .idea_modules file.
I can't imagine me setting ALL dependencies (more than 100...) manually...
How to deal with the libraries (dependencies)? Indeed, libraries.xml is used in .idea file and typically used when someone want to mount the app as an entire Project.
To put in a nutshell, is there an efficient way to set up a Play app in IntelliJ as a simple Module including automatically all needed dependencies?
It would be great if IntelliJ could implement an SBT feature like the one for Maven in order to import dependencies automatically.

Related

Problems with libgdx libraries using intellij on a git project with a friend

So I am fairly new to programming, and new to git, LibGDX and Intellij.
My friend and I started with a programming project a few days ago, where we generated a project using libGDX. We opened the project in IntellIj IDEA and sat up the run command. It worked on my friends laptop, but when he pushed it to git and I cloned it, it didn't work. So I dived into settings and looked at differences between my own project and this shared project.
What I found out was that all the external libraries was gone for me. So I checked the project structure and found that all the paths were specified to his computer.
For example:
/home/"name"/.gradle/caches/modules-2/files-2.1/com.badlogicgames.gdx/gdx/1.9.3/1a3775429980a6c8da0cdefb656ad1dabf91d629/gdx-1.9.3.jar
So I tried changing the paths to ~/.gradle (...).jar but it automatically expanded the path to the full path of my computer instead. So the question is:
Is it possible to set the project structure settings for modules to an universal path that works for everyone cloning the project, or do I have to add every path individually for each person working on the project?
Thanks,
Jon
While it is safe to add the .iml files and most of the .idea directory to your git repository, you should avoid adding the following files:
.idea/workspace.xml
.idea/libraries/*
See this documentation for more details.
Since it's a gradle project, IntelliJ should reimport the gradle model automatically and create these files with paths that depend on your own environment.

How to properly import a Play 2+ project in IntelliJ 14+ with all integrated features (run, debug, test)?

I work on a Java based Play! project for severals months now and I'd like to import it completely in IntelliJ, meaning being able to run, compile, test and debug from IntelliJ, without the need to use the command line.
According to this post from Jetbrain, it seems to be possible, if I quote the article it says clearly : "Now you don’t need to switch between IntelliJ IDEA and Play console anymore. Everything is available right from your favorite IDE.", but I can't figure out a way to achieve this for now, even if I follow the tutorial provided by Jetbrains.
Here are the steps I've been throught :
Open my fav IDE IntelliJ ;)
Go to the project list window.
Import project
Import from external model and choose SBT as suggested in Jetbrains tutorial.
option "Use auto import" checked, option "create directories for empty content roots automatically" checked. Project SDK Java 1.7
Global sbt settings : JVM From project JDK.
Finish
By now, if I try to make the project and launch it from IntelliJ, I'll get scala compiling errors related to routes object. Thanks to this post, we can understand that this happens because scala routes are located to specific folders that needs to be included in IntelliJ sources settings for this project. So next step was :
File -> Project Structure -> Modules
Add target/scala-2.10/classes:target/scala-2.10/resources_managed:target/scala-2.10/src_managed as sources folders.
But my problem remains the same, routes object being unrecognized.
Notes : I have no scala facets in my project structure configuration nor can add one.
IntelliJ provides integrated support for the Play Framework for Scala and Java. Support is currently only available in IntelliJ Ultimate Edition (see the Frameworks and Technology section).
Assuming Ultimate Edition, the setup for Play is incredibly easy. Simply create a new project by importing build.sbt, then choose Add Framework Support and choose Play 2.
Once complete, you can start and stop Play using the Play 2 Run/Debug configuration. No command line necessary.
Here is a more in depth look at IntelliJ's Play project configuration.
You could try the command play idea if you are using play or activator idea if you are using activator. That will do the magic.

How do you link an eclipse project to an eclipse plug-in project?

I am building an eclipse plug-in project that acts as a front end. I also have a separate eclipse project that runs as a backend. Right now I can run each of them separately and they communicate just fine using sockets.
I would like the plug-in to create the major components of the back end when it starts but also keep the two projects separate so that I can use other editors to communicate with the back end. So, I added the back end eclipse project to the build properties of the plug-in project and I added some code from the back end driver to the plug-in activator's start(). However, when I run the plug-in project I am getting class not found exceptions for all back end references. It appears to compile fine, but I can't run it. I do not do anything to the MANIFEST.MF file in the plug-in project.
How does one add a second java project to an eclipse plug-in project?
There are several ways you can do this, going from best and most difficult to worst and easiest:
(1) Use a build tool (such as the built-in ANT, or tycho, or (as I'm sure there are) some other). This is by far the best solution, but is quite a bit more involved than the next 2.
(2) Convert your non-plugin project to a plugin project and add it as a plugin dependency in your plugin settings file's dependencies tab
(3) Export your non-plugin to a new .jar in your plugin project directory (e.g. $project_loc/lib/something.jar); go into plugin settings (plugin.xml) and include it in: The Build tab under binary build, and the Runtime tab under Classpath. (Or edit the corresponding entries in manifest.mf and build.properties)
For most cases I'd recommend approach (1); look up a few tutorials online, there are plenty. (3) is the quick-and-dirty non-flexible workaround to your particular situation, good for nothing other than seeing if it actually can run. (2) is somewhere in between -- obviously not ideal, but not as bad as 3.

Setup IntelliJ IDEA 12 with Play2 and framework sources (java)

I'm using IntelliJ IDEA 12, its Play2.0 plugin for a Java project.
Unfortunately Play 2 (2.1.4 at this time) does not ship with the sources for its dependencies, and running idea with-sources=yes only downloads the project's dependencies sources.
So far I've had to manually download the source jars and attach them whenever I needed them.
Of course I have to redo this every time the Play framework is updated.
Is there any better way, either within play, which I would prefer, or with an external solution?
Unfortunately IDEA's "Search in internet..." button usually doesn't work, most likely because it's looking on the wrong respositories. I suspect it is trying to use the Maven settings with the configured Nexus repos, but AFAIK Maven central is not in there.
It is as simple as running update-classifiers in the Play console and then regenerating the project files.
I wish this would be done automatically, but apparently it is too obvious to sbt users.

intelliJ 11.1.4 - adding a jar to project only works 50%

I have an Android project that uses some external libraries. The problem is that within intelliJ I can build the project and it runs fine, but the editor marks classes that come from the jars as unknown.
I've added the jars to the correct module (project structure -> module -> dependency) independently, from the libs directory, as classes, jar directory, etc. I've also tried to add them using project settings -> add libs, attach them to the module. But to no avail. I also tried to add them within the project explorer with right-click -> add library. Nothing works.
It was all fine before but now after a horrible IntelliJ crash it no longer works. This has happened to me twice now. And I loose a lot of time trying to fix this. Am I fighting an intelliJ bug here?
File | Invalidate Caches is the first thing to try in similar cases.