Autocompletion in Eclipse for Roo project - java

I've got a Roo project where I've made a couple of entities, and when I load up the project in Eclipse it loads up fine, but if I i.e. make an instance MyEntity entity and then write entity. I don't get any of my properties (i.e. getMyField) in the autocompletion list. If I write entity.getMyField() it compiles fine, that is taken care of by the aspects. How do I enable autocompletion for functions generated by the aspects?
Cheers
Nik

Which "type" of eclipse are you using? Do you have AJDT intstalled within your eclipse? If so there is still an option to disable weaving of JDT. The note below (taken from the Roo documentation) should help you to turn on JDT weaving (Window -> Preferences > JDT Weaving.
When using AJDT you may be prompted
whether to enable weaving of the JDT.
You should select to enable weaving so
as to ensure the Java Editor in
Eclipse (or STS) gives the best
AspectJ-based experience. You can also
verify this setting is active by
loading Eclipse (or STS) and selecting
Window > Preferences > JDT Weaving.
By the way have you considered trying the Spring Source Tool Suite? There you find all the plugins (AJDT support...) already installed. And it fits very well for Roo as it offers Roo functionality from within eclipse.

I have experienced the same problem as niklassaers: Roo AspectJ methods not showing in eclipse autocompletion while compiling fine. I'm using the latest version of STS, with AJDT installed by default, and verified that JDT Weaving is active, but the problem persists.
On the other hand, I've found out that executing Maven > Update project... (Alt-F5) makes the ROO AJ methods visible to auto completion.
This solution might be related on how I structured my project (I have two eclipse Maven projects in my workspace, myproject.data containing roo classes with aj methods, and myproject.services acting as a client for those classes); besides, I have to repeat Alt-F5 every time I open my workspace, but this seems to work.
I'd like to understand better the reasons of this code completion problem, and maybe find some way to solve the problem permanently, without having to update maven projects every time. Could it be related to interactions between the AJDT plugin and m2eclipse Maven plugin?

Related

Hibernate configuration in Eclipse Luna

I installed the Hibernate plug-in on Eclipse from here.
Installation is successful-- I'm now seeing Hibernate as an option in Window > Open Perspective.
I've set the properties on the project itself-- Enable Hibernate support is now checked in Properties > Hibernate Settings.
Also, Hibernate Builder is checked (was automatically) in Properties Builders.
However, Java is not seeing Hibernate-- I'm getting errors to all Hibernate imports in my source code.
When I attempt to "Fix project setup..." in the editor, I get "No proposals found ... click for manual configuration."
What am i missing?
I downloaded Hibernate plug-in to get around this manual fix for one thing. The same code is working all fine when I manually add the jars to the project build path.
I'm using Eclipse Luna 4.4.2
TIA.
//-------------------------
EDIT:
While autocreating persistence.xml, Eclipse is (must be) looking at the version of Hibernate plug-in, not the jars on the project's build-path.
And that's causing a version conflict in between JPA and ORM. See the accepted answer here for reference.
Burned me half a day.
The plug-ins make Eclipse Hibernate-aware, not necessarily your project. Your project still must be configured (either manually or via a dependency management tool like Maven or Gradle) with the appropriate Hibernate JARs. It's the difference between development-time (the Eclipse plug-ins), compile-time (JARs on the build path) and runtime (JARs on the runtime classpath).
It would be nice if the plug-in provided a Quick Fix (à la Fix project setup...) that offered to download and/or add Hibernate JARs to your project, but as far as I know that's not something they implemented.

My m2eclipse seems to be missing the automatic dependency resolution in Eclipse "fix it" menu

I've been trying to get more out of m2eclipse, learning what's possible, etc. Recently I watched this tutorial video on how the Eclipse auto-fix will automatically search maven repositories for dependencies. In the video, the presenter begins typing in Java code:
RestClient restClient = ...
They can right click on the unrecognized "RestClient" and have m2eclipse search for possible dependencies. I don't appear to have this option. Instead I get the standard fixes -- Create a class, interface, etc or fix the project setup.
I created my project by doing "Import Existing Maven Project" in Eclipse. It appears to otherwise work as an existing/normal maven project
(I am using Eclipse Juno with m2eclipse 1.4.)
This option was removed from m2e a few years back (right before m2e 1.0 IIRC, when the project was contributed to the Eclipse Foundation), because it required downloading a very large nexus index (known as full index, containing class lists for each known dependencies) of remote repositories. This was slow and very space consuming, the gain was not deemed significant enough to justify maintaining the feature.

Using Eclipse with Subversion and Maven

I am trying to use Eclipse, Subversion and Maven for my projects and everyone is telling me never to check in the following files:
target/
.classpath
.project
.settings
But if I dont check them in and some other project checkouts the project from within Eclipse, Eclipse does not know what type of project it is.. Are we doing something wroung?
How do you work?
Eclipse has a plug-in for Maven; I believe it is called m2eclipse. After having it installed you can select Import from Maven project and select the pom.xml which will import your project to eclipse even if .project and .settings are not present. So there is no need for you to commit them to svn. This comes with the advantage of IDE neutrality; other members of your team may use Intellij IDEA or NetBeans without any concern.
Also Maven has a plug-in for eclipse; you can go where pom.xml is located, open a terminal and type mvn eclipse:eclipse and it will automatically generate .project and .settings.. However the first option is more recommended.
I had the same issue with eclipse, maven and git, so maybe it is helpful for you:
Try to setup your repo in svn and check it out, but don't import it.
You have to import the project over File -> Import -> Existing Maven Project into your workspace.
The last step is to share the project. Rightclick -> Team -> Share -> SVN -> and set the existing one as repo.
That's the way I handle this in Eclipse. Hope it's clear enough?
Btw you should not check in these file, because classpath and so on could be different on other machines.
I check in .classpath and .project but not very often. You do have to make sure that everyone who is working on the project has versions of eclipse that are close enough (including the particular plugins and eclipse features included). Sometimes you can get by with very different versions of eclipse if you make sure almost nobody checks those files in and everybody just mostly compares and manually updates those files from the version control when they are updated.
If you don't check them in, everybody has to create an empty project and then load the source files (and all the version control files or folders) into the project. If you are careful you can copy in those two files and then fool with the options settings to make them match.
Note that Maven helps a lot with this as it takes care of most of the content of the .classpath file.
The main reason not to check in those files are that the IDE's will very likely make changes to those files to suit your local dev environment. Which will probably cause conflicts and thus "broken" projects if everybody is committing their versions all the time.
That said, eclipse should have decent maven integration via the m2eclipse plugin (which I believe might be baked in by default these days).
Part of the idea behind Maven is exactly this - reproducible builds cross platform, cross IDE etc etc - so IDE specific files like that should not be required to build the project.
Importing the project with the m2eclipse plugin should sort things out nicely.
If you mean the other members check out the project and it doesn't work for them, they can check out the maven project separately without using eclipse and then import it into eclipse as an existing maven project using the m2eclipse plugin. This works cleanly without any problems (for me at least).
if everyone in your team is using Eclipse and it is agreed that the project will never use anything else, you may as weel check those files in. but it will make things kind of irritating if someone uses IntelliJ, Netbeans of other tooling or has his Eclipse very customized.
It depends.
Maven documentation explicitly says something like "Do not check in .project/.classpath/.settings/ because they can be regenerated from pom.xml". The later part of the sentence ("they can be regenerated") is not true, so the first part of the sentence (the advice) may or may not be OK, depending on the circunstances. Not every bit of the Eclipse configuration can be regenerated from the pom.xml, so my opinion is that the decission is based on a tradeoff between how much gain you get from it and being tied to the particular IDE.
So it depends.
For "community projects", where usually each developer will use different IDEs and different versions of the IDE, I would recommend not to check in those files. Otherwise, it would be a pain for developers not using your IDE and your version of the IDE.
For large "corporate project", IDE and IDE version are not free to be choosen by the developer but firmly dictated by the project management. So are dictated things such as compiler(1), code formatting, validating rules, warnings-and-errors configuration, custom in-house plugins configuration and many others. Many of those things cannot be set in pom.xml (nor should they because Maven is not and IDE, but a building tool). So in this case I would recomend to check in those files and blame the developer who complies, because he is trying not to follow the dictates.
(Notice that in this case I intentionally used words such as "dictate" and "blame" because the project management of a corporate project has not only the right but also de duty to "dictate" and "blame")
In the opposite side, for one-person projects, you do not have to worry about your colleages, so go check them in.
But the key is that you have to know your circunstances and the consecuences and decide yourself.
(1) No, "maven.compiler.source" is not the compiler to be used.

How to make a custom Eclipse build?

I've run in trouble building and packaging our Eclipse-based application. Here is an 'Our Application' consists of 4 Eclipse plug-ins. It's RCP based now (but it's easy to migrate to IDE platform, AFAIK?). It's building and packaging fine, with a simple .product build descriptor.
But now I've faced a problem, as there is a requirement to run that application, with the other plug-ins 'under the same roof'. The plugins are: Papyrus UML, BPMN Designer and (possibly) and XML editor from WTP.
The question is - is it better to 'integrate' this plug-ins in RCP, or to use our plug-ins in an Eclipse IDE? And more specifically - how to create Eclipse IDE build with that and only that plug-ins (features), without JDT and other need-less stuff? What approach should we use, to create such a packaging?
Using plug-ins in an Eclipse IDE may take you lots of time filtering the unused menu items or something else.
If you want to disable the entire unused plugin, the extension point "org.eclipse.ui.activities" may help you. http://www.vogella.de/blog/2009/07/13/eclipse-activities/

Is Developing Maven war apps in MyEclipse worth it?

My organization has made an upper level decision to move to maven as the standard build tool for Java projects. I have been tasked with helping our local teams migrate projects over to maven.
One of the core tools that is in play is the MyEclipse IDE. MyEclipse seems to have had a "fun" history with the maven team as evidenced in various places, especially when dealing with war projects. I haven't encountered problems with simple jar projects...yet.
After fighting with MyEclipse and failing to make it recognize a war project easily, the question becomes, is MyEclipse worth it for developing maven war apps?
If so, is there a way to get MyEclipse to play nicely with a war project that I've not found? Or, am I simply better off suggesting its time to use Eclipse Java EE edition with m2eclipse?
No. MyEclipse does not support projects that were created outside of it. It is by design only working with projects created using its wizards.
From the Using Maven in MyEclipse Overview
NOTE: Maven is only supported for new projects. Migration of existing
projects to Maven-enabled projects is not supported at this time, but
may be considered for a later release. Right now the MyEclipse team is
focused on providing as fluid a new-Maven-project experience as
possible
I am working as a tech lead, and we recently started moving to maven. I had a couple of issues getting maven to work with myeclipse. First, even when I "Enabled all m2eclipse features" checkbox, I still couldn't check out a project as a maven project, from subversion. That option (that you get from m2eclipse) just wasn't available.
Also, some of the preferences you get with m2eclipse are not available with maven4myeclipse.
Finally, I couldn't just uninstall the maven4eclipse plugin and install m2eclipse. That would have been an acceptable workaround.
I think Genutec tried to make Maven more accesible to newbies, but there are some problems in the impementation, and I don't see them being fixed soon. For us, that will likely delegate MyEclipse to being just a fancy jsp editor.
Mike,
Sorry to hear you are fighting MyEclipse and Maven, in the past the most common problem I've seen causing people pain in this area is when they don't have the Web Root, Java source dirs or resource dirs set correctly.
Using this webpage as reference for a standard Maven2 web project layout, you can easily create a Maven-enabled MyEclipse Web Project. The steps you would want to take are as follows:
File > New > Web Project
Give your project a name, use the Java source dir of "src/main/java" and a Web Root of "src/main/webapp", check the Java EE spec level you want, check "Add Maven support" checkbox and hit Finish (unless you want to setup the artifact/group IDs).
Now, if this is the first time using Maven4MyEclipse, a lot of initialization will take place preparing your local repository and grabbing all the Java EE resources to build your project, but after that's done you should be all set.
You can execute the Maven targets off the Right-click Run As or Debug As menu and even manage custom goal execution using the "Maven build..." shortcut -- this is all similar to m2eclipse.
If you decide you want to use m2eclipse complete, you can navigate to Window > Preferences > MyEclipse > Maven4MyEclipse and check the "Enable all m2eclipse features" checkbox.
Out of the box we only hide the bits that can make Maven confusing for first-time folks, if you enable all the m2 bits, you can do whatever you want with Maven and MyEclipse. If you keep having trouble stop by our forums and let us know and we'll help out as best we can.
Mike,
think the issue is that the project has already been created outside of MyEclipse and >worked thru maven using the command line. Importing it is not successful.
I saw this post when looking for other Maven resources so I'll chime in.
Why not import your existing project using File > Import and turn on all the m2eclipse features and continue to develop it as you did before using maven commandline tools? I've done this and it works well for legacy projects, once m2eclipse features are enabled as mentioned in Riyad's #5.
Personally, I've always thought the maven war format was a bust, but we still have some old projects that use it around. Maven's format is just a default (and a poor one), not some sort of standard. However, we currently leave those old projects "as is" (using the above technique) just because it's easy. But for new work we use the MyEclipse web projects then just enable Maven support on them. The benefit is that you get all the Maven support and it's super easy to use and manage but no more commandline (although that still works too) and all the MyEclipse tools work perfectly on them as well. It's a "best of both" approach, well, at least for us. YMMV.
Hope that helps,
Dave
Mike,
Interesting, what happens when you have developers who are not using MyEclipse?
Not an issue here; I work for a very large company that has been standardized on it for quite some time (happily, I might add as we used to be a WSAD shop -- shudder.)
Anyway, if you have some that use MyEclipse and some that don't I see two options. First, if you create MyEclipse web projects and then "Add Maven capabilities" (or whatever it's called) to them, they'll work in MyEclipse and from the Maven commandline as well. So even if you're not using MyEclipse you can still use the commandline Maven tools. Also, since the MyEclipse structure is the more standard "exploded war" layout, it should work with whatever else you use as well.
Other thing to consider is that Maven's web layout is simply a default and Maven can easily support any project structure, including the one MyEclipse uses, so you should be able to use the MyEclipse project with Maven in any tool with just a little additional config. That's likely why the Maven commandline tools still work on the MyEclipse Web projects -- the MyEclipse guys just automatically configure Maven to recognize the format.
You also could just import the externally created Maven web projects as I said in my last post. We don't like to do that because that structure is unique to Maven and just doesn't work with any tools except Maven. As a result, it basically defeats the the tool support you get automatically in MyEclipse, Eclipse Java EE, or pretty much any other tool. It's just a poor default. Exploded WAR format, that's used by MyEclipse, Eclipse Java EE, WSAD, RAD, and everyone else is simply a better solution. Especially when it still works with Maven just fine as well.
Maven was made to be flexible to project structure. We've just found by using that flexibility a little you can get Maven support and great tool support too.
Dave

Categories