Say I open an Eclipse project in IntelliJ IDEA, and then I add a library dependency in Eclipse.
How can I sync the .iml file with the modified .classpath one? If there is a way...
If you want to keep dependency consistency across IDE's and achieve even more if you want it... You must use Maven.
Maven is awesome about it. You only will have your project's real code and a file called pom.xml.
You are able to add dependencies in the Maven way to that pom.xml and no matter what you are able to run your project in IntelliJ, Netbeans, and Eclipse without a problem, even across multiple developer on different IDEs.
You can learn a good deal about Maven from this tutorial:
https://www.tutorialspoint.com/maven/
It shows you it's usage in Eclipse, IntelliJ and Netbeans in the last chapters of the tutorial.
Related
So I am doing major change in a library(maven) which I have developed, and using it in one of the playframework project.
I have finished refactoring changes in maven artifact, published it to repository with new version.
Now I want to see where all this will give errors in play project, so that I can go and fix 100s of such errors. Ideally I would like to use eclipse or some IDE to report me all the errors, so that I can easily navigate and fix.
But problem is that eclipse doesn't know about new library version. To tell that to eclipse I have to upgrade library version in build.sbt, compile and re-create eclipse project. But since it contains many errors, I can not create eclipse project before fixing those.
Is there a way to visualize all those errors in eclipse or any IDE in such cases?
You did not mentioned, if the play project is a maven project as well. I am working with play as a maven project, which is created like this. But I suppose, that with non-maven project the following works as well.
From the command line run:
activator eclipse
In eclipse do 'refresh' to the project. Now you can see all the errors caused by the changes in your jars.
I am experimenting with a small Scalatra web application, which I have imported as a project into Eclipse.
I have used Eclipse to manage a few Lift applications before. With a Lift project, SBT copies all the dependency JAR's to a /lib_managed directory. I can therefore add those JAR's to Eclipse's build path, and it co-exists with SBT just fine without complaining about missing classes.
With Scalatra, however, the dependency JAR's don't seem to get copied anywhere helpful during the development cycle. If you build a WAR file, then the dependencies get bundled up into that... but there doesn't seem to be anything like Lift's /lib-managed directory.
Assuming that anyone else uses Eclipse in developing Scalatra projects, how might I easily set up Eclipse's build path? I suppose that I could manually create entries that point my local Ivy repository one-by-one, although that seems a bit ugly. Perhaps there's an easy way through SBT to setup something similar to Lift's /lib-managed subdirectory inside the project directory.
It looks like the best approach for this is using the SBT plugin for Eclipse.
This is not an "Eclipse plugin" for managing SBT. Rather, it's an "SBT plugin", for generating the .project and .classpath files used by Eclipse. The Maven world used to deal with Eclipse in a similar manner, before the m2eclipse Eclipse plugin reached maturity over the past couple years.
With this plugin installed (I installed it globally so I wouldn't have to change my project's files), you just type sbt eclipse after any changes to your dependencies. SBT will then update your Eclipse project files to match.
You could also use my Maven prototype, then simply import the maven project into Eclipse. Quite nice and you're not forced to use SBT.
https://github.com/fancellu/scalatra-maven-prototype
I am trying to set up a project, but feel completely overwhelmed with lack of knowledge. In university we used netbeans which resolved project structure gently for us. As community leans towards eclipse I am trying to migrate there, but feel myself like a penguin not able to fly. I can't understand project structure where and what has to be added, do I have to define ANT or MAVEN manually in eclipse can they be integrated? Where to go ? Apache manuals are so complicated, why is that I can program in Java , but don't know the fundamentals, soo depressed, please anyone guide me. I find pieces on web, but seems can't build full picture in my head.
You have a couple of options. Basically, eclipse uses a workspace, which contains one .metadata directory used by the plugins and all of the project folders. Projects can then be things like java projects, PDE projects, PHP projects, etc.
There is maven integration in eclipse which I would use, http://www.eclipse.org/m2e/ It was part of Indigo, which released June 2011.
Set up your java projects in your workspace, and then use m2e to mavenize them, or use m2e to generate the java projects into your workspace.
maven provides a facility to create a new project with the required structure based on the type of project (jar, war, etc.).
You can do this or achieve it directly from Eclipse as suggested by Paul Webster, by installing the m2e plugin.
This structure can then be easily built using maven, as well as developed in Eclipse.
I am using the eclipse plugin for maven to generate eclipse projects from maven pom.xml files.
mvn -Dwtpversion=1.5 eclipse:eclipse
This works fine and, after some experimenting with several of the 400 different archetypes available, I settled on using the webapp-javaee6 archetype, which was the only one which generated a set of dependencies that were both all available and which created a project that was useable by the WTP plugin.
The problem now is that I would like to be able to invoke mvn goals from eclipse. The accepted way to do this I understand is to use the m2eclipse plugin, which I have installed.
However, after playing around a bit and getting nowhere I discovered this comment in my .project file:
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
Further searching (see this lengthy diatribe from October) suggests I'm not (just) being stupid in not being able to get this to work.
The how-to linked in the top answer to this question seems hopelessly out of date.
So, the real question - what is currently the correct way to use maven to generate a WTP-friendly project that can be converted to eclipse and then use eclipse to call the project's goals?
Have you tried File -> Import -> Check out existing Maven Projects from SCM? My understanding is that m2eclipse will then create the eclipse project for you. If the packaging defined in the pom is war, the project should be deployable with WTP. (The latter used to require an the maven-wtp-integration plugin as well, don't know whether that's still the case).
Not sure about WTP or maven archetypes, but have you come across SpringSource Tool Suite (Spring packaged eclipse) and created a Spring Roo project? You can use this to create a data driven maven built web-app in a few mins. You can even remove the spring roo bits if you don't want them, it will give you a good starting point for a web-app with very little pain.
eclipse has the possibility to configure code templates per project. These are stored in /.settings/org.eclipse.jdt.ui.prefs.
when you have a maven project you usually omit all eclipse project stuff and only keep the pom.xml. Then you check it out in eclipse and the m2eclipse plugin generates the project files. Maven even writes the above /.settings/org.eclipse.jdt.ui.prefs.
The problem with this approach is that every developer needs to specify the same templates for the project, since the pom.xml does not know about templates, and so maven does not write them to the prefs file.
I googled for eclipse maven code template and found only that the maven-eclipse plugin is capable of defining a code style in eclipse, but i did not find anything about templates.
Does anybody know of a maven plugin which can solve this?
Any workarounds or other solutions for this?
I use workspacemechanic to share my eclipse settings between different workspaces. Sharing code templates (Window->Preferences->Java->Editor->Templates) seems to work too.
Its an eclipse plugin you have to install, no maven plugin.