How to properly setup a maven project in Eclipse/IntelliJ - java

I'm struggling a bit, trying to properly setup my maven projects in an IDE.
I don't particularly care between Eclipse and IntelliJ, but it seems that IntelliJ handles much better when it comes to import my projects, so I think I will stick with this one.
I'm having other problems now when trying to run the install goal through IntelliJ.
The first error :
The svn command failed. Command output: 'svn' is not recognized as
an internal or external command, operable
program or batch file.
How do I configure IntelliJ in order to let him see svn ? This error sounds weird to me, as I have installed Subversion as my Version Control System in IntelliJ.
Also, and this is related, I have a setenv.cmd that I usually run from the commandLine before calling mvn install. It only sets some variable like :
PROJECT_HOME=d:\Project\xxx\xxx\Trunk
PROJECT_VERSION=0.4.3-SNAPSHOT
M2_HOME=d:\Java\apache-maven-2.0.11
JAVA_HOME=d:\Java\jdk1.5.0_11
PYTHON_HOME=d:\Python26
XOOOF_HOME=d:\Project\xxx\xxx\XOOOF-BIN-1.0.3
XOOOF_URL=file:///d:/Project/xxx/xxx/XOOOF-BIN-1.0.3
SVNCLIENT_HOME=d:\Java\svn-win32-1.6.3
CATALINA_HOME=d:\Java\apache-tomcat
PATH=C:\WINDOWS;C:\WINDOWS\system32
How could I improve this step, and find a way to make it work from my IDE ?
Thanks !

If you want to do maven builds in eclipse I would strongly suggest installing m2eclipse by Sonatype.
It has an excellent reference on how to use it -> http://www.sonatype.com/books/m2eclipse-book/reference/

Regarding the first error it seems to be not Idea fault. AFAIK Idea doesn't need/use external SVN binaries. What happens when you click "9: Changes" tab at the bottom in Idea? If you make your project/module as managed by SVN there should be Repository subtab.
You run Maven from Idea to perform install goal and that error seems to come from it. Do you use SCM/SVN plugin in pom.xml? If yes or you would like to have an ability to run SVN from command line add directory with svn.exe (d:\Java\svn-win32-1.6.3? d:\Java\svn-win32-1.6.3\bin?) to PATH (not only to SVNCLIENT_HOME). After that operation svn command from new "run window" should be recognized.

Related

How to checkout a project from GitHub and build it through command line and use it in eclipse workspace for edit?

As an initial step, checking out a project from GitHub and building it through eclipse taking too much time in my case, I decided to automate that initial process through command line. And I'm able to do that successfully.
But I wanted use that imported project in Eclipse for further edits. This I don't know how to do. Can you please help me in achieving it

Unsupported import

I try to search this error across the web but I cannot find the solution. Any idea?
Regards,
Jimmy
It is a common problem, because IntelIJ is caching a lot of stuff. Your application may run with success in terminal, but IntelIJ may be stubborn to show you these errors.
This is common especially when you change between git branches with different versions of code.
What I usually do :
I run maven clean command : mvn clean - to remove target folders
after I press build and after again build Ctrl + F9. Important you must run build from IntelIJ twice
This is the fast solution and usually it works.
If the problem persists, I restart IntelIJ with Invalidate Cache and Restart.
Sometimes I delete .idea folder and reimport the project.
If this does not work as well I go for the longest solution:
mvn clean package
Usually it may have problems if you installed the project with mvn install, so I run the mentioned command to clear the installed version.
If this does not work as well I go and press reimport maven projects (the first button from the picture)
Hope it helps. It happens to me a lot as well. If you find another solution please let me know as well.

Google App Engine + Maven + JSP compilation

How do I get .jsp/.xhtml/.html files to trigger a compile/package goal in a Google App Engine + Maven + Eclipse setup? (actually it's the same for IntelliJ & Netbeans)
The .java files cause a compile goal just fine, which causes the target directory to update, which is then picked up by appengine:devserver, but nothing else works.
I've seen lots of people asking this, but no solution.
I'm using the simple GuestBook Maven archetype:
mvn archetype:generate -Dappengine-version=1.9.15
-Dapplication-id=your-app-id -Dfilter=com.google.appengine.archetypes:guestbook-archetype
Followed by:
mvn appengine:devserver
Eclipse Juno is setup to "build automatically", so touching a java file triggers the goal, just nothing else.
Frustrated!
UPDATE: I'm using the GPE for Juno EE.
-- shane
If you install the GPE, you can run from within the eclipse IDE. When running in debug mode, jsp and java file changes will get hot-loaded. You can also use the JRebel plugin for eclipse to save time on redeploys/restarts.
EDIT:
If you're still having trouble, ensure that you have the m2e-wtp plugin installed into your eclipse, it enables a bunch of secret sauce. m2e is now intrinsic, i'm not sure about m2e-wtp. If I look in 'About' for eclipse, I can see a button for wtp. m2e-wtp
For the record, this is actually unnecessarily hard. But once it works, it works.
I feel there should be a better way, but this is a workaround:
Project -> Properties -> Builders
Click "New…" to create a builder that will invoke the mvn binary.
Here's my settings for it.
Location: /usr/local/bin/mvn
Working directory: ${workspace_loc:/} (use browse workspace to populate this)
Arguments: -Dmaven.test.skip=true prepare-package war:exploded (these arguments seem to be the fastest way to produce the exploded war, ~1 second in my case)
In Build Options, deselect "Allocate Console" and select "Launch in background".
Except the 1 second delay, this works flawlessly for me.

Program in Eclipse not Running

I've just installed Eclipse 4.2.0 and also imported all my old programs into it, except that when I run my programs, it pops up with a message saying:
Select what to run:
Ant Build: Launches an Ant Build with default
Ant Build...: Launches an Ant Build and allows it to be configured
This message has never appeared to me before. I wonder if it is because I imported my files incorrectly or something that I forgot to install. Please tell me how I can make it work properly again. Thanks in advance.
Ah! this is an issue I've experienced earlier. This tip solved the issue. Here's How to do it.
Make sure that you've built it. Or you can enable Project --> Build Automatically.
After the above option is set, try cleaning the workspace. Project --> Clean and clean all the projects you've imported.
Now restart eclipse and you can launch your program.

Maven options in Eclipse disappeared

I restarted my computer, and rebooted my VM with Ubuntu 12.04 on it and, I restarted Eclipse. Then I noticed that there were errors regarding the build, so I did a 'mvn clean install' on the repo in the terminal, and after that I re-imported the Maven project in Eclipse (when the option was still available). After the import finished I noticed that it said that mvn is missing the 'unpack' command in m2e. So I thought, that I needed to update the software so I went into Help > Check for Updates, and then I guess it found a better version of m2e, but now the 'Import Existing Maven Project' is gone now. I tried importing it regularly, however the 'src/java/main' and 'src/java/test' aren't distinguished as different special folders.
Has anyone else encountered this issue? If so, what did you do to solve the problem.
Thanks in advance,
ejay
If you right cliok the project and select Configure, does it offer to convert the project to Maven nature?
Generally, using the "clean" option on any tool will delete files and folders that are considered "secondary", i.e. they can be recreated easily. That might include some config files in this case.

Categories