Having Maven Plugins in IntelliJ IDEA without Maven Installation in Computer - maven

I just started to use Maven and IntelliJ IDEA.
I imported a project into IntelliJ IDEA which requires Maven. I didn't install Maven to my computer but I have 2 plugins in IntelliJ IDEA named as "Maven" and "Maven Extension". And the code I have is running without any dependency problem.
In that case, do I still need to install Maven from the web or just the plugins in the IntellJ are enough for projects with Maven?
Can we say that for every project? If someone can explain the logic behind I would be very happy.
Thanks a lot!

Intellij comes with a bundled version of Maven (see File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven; the property 'Maven home directory' on that screen by defaults points to 'Bundled (Maven 3)').
You don't have to, but you can still install your own version of Maven, and point that property to it. It has the advantage of being able to run maven from the command-line, which is a better guarantee of build-stability (i.e. building the same project in different environments with the same result) than building directly inside of your IDE. And often is way more helpful in investigating build problems.

Related

Tycho build Cohabiting with Eclipse RCP

The context: I have embraced Eclipse Tycho to automate the build of my small clutch of plugins. It does a great job. Part of the Tycho migration included removing all Eclipse .project and .classpath files from SCM.
The problem: To work on my plugins in Eclipse I must import my projects using "Import => Existing Maven Project", however the resulting Eclipse project has a very different shape:
It lacks any Eclipse plugins required to compile it
though my sources lie in the usual directory src/main/java the project is not configured use this as a source directory.
My question: How can I build a .project and .classpath combination that will get me back to pre-Tycho IDE productivity.
I have tried mvn eclipse:eclipse which says "eclipse-plugin" no longer supported, but does Tycho have something similar that is?
mvn clean install builds successfully
In retrospect the solution seems obvious, and my many thanks to oberlies for the clue.
To develop Eclipse plugins you must be using the Eclipse RCP/RAP edition or the Maven/Tycho import will not prompt you to install the Tycho configurator that maps the Maven project back into an Eclipse RCP project.
Repeating the steps outlined in my question, using "Eclipse for RCP and RAP Developers" prompts the developer to install the configurator, after which Eclipse requires a restart, and leaves perfectly useful RCP plugins projects.
M.

Has IntelliJ IDEA downloaded the Maven automatically?

My question is a little different from Setup Maven for IntelliJ 13.
My IntelliJ IDEA version is 14.0.3, and I didn't download any Maven in my computer before. I can create Maven project well, but the maven home directory is empty:
and the Maven menu doesn't contain clean, compile, package ...,
If the IntelliJ IDEA has built-in Maven, where is the Maven?
So, it seems that IntelliJ IDEA hasn't downloaded the Maven itself and I should download it and set the M2_HOME manually, right ?
Yes, you have to download and install a Maven distribution manually. As far as I know, IntelliJ doesn't do it automatically. As for the "Maven home directory" field, my preference is to explicitly choose the directory where Maven was installed, rather than setting a global "M2_HOME" environment variable.

run maven project with eclipse

I'm new to maven and eclipse. I added m2e-plugin in eclipse and I imported an example of a maven project that I've found in the net.
My problem is when I try to run the project in eclipse using the Run as item menu, I don't find the maven package menu as I learned in the different tutorials.
Is it a problem of installation?
Ok, lets go through this step by step to make sure you have everything you need to get going.
First of all make sure that you have Maven installed (and lets assume you have Java already). You can download it from http://maven.apache.org/download.cgi and installation instructions for Fedora (which I assume is what you are using from your tag) are further down the page.
To test that Maven is correctly installed and working type mvn --help in to the terminal. Eclipse and m2e pretty much just hop on to the terminal for everything Maven related so make sure this is working before proceeding.
Next download an appropriate version of Eclipse. For the sake of this example I've downloaded the Kepler version of the Java EE IDE. In this version of Eclipse m2e comes bundled and to check this you can go to Help > About Eclipse > Installation Details and on the plug-ins tab you should see the m2e connectors.
Now you can import your Maven project in to Eclipse. To do this go to File > Import and then choose Existing Maven Projects under the Maven section. Choose the directory with the example project that you've downloaded and then Finish.
Now, ensure that you have some file inside your example Maven project opened and when you go to Run As... you should now be able to see the maven options. Go to Run As > Maven build... and all you need to do is place the word package in the Goals field and you're ready to roll.
Convert your project to a maven project if you haven't done yet by right clicking on your project in the Eclipse Project/Package explorer. Then follow:
Configure -> Convert to Maven Project
After that you can just right click again on the project Run as and you will see all Maven possibilities to execute your project build/install/clean etc.

IntelliJ IDEA does not create artifacts from pom.xml

I use the IntelliJ IDEA 12.1.4 under Windows and Linux (Ubuntu). The Maven plugin is installed.
I have a big maven project with many poms. Under Windows the IDEA creates artifacts automatically when I do reimport from maven. But under my Linux system the list of artifacts is empty always.
Is it a bug? How to generate artifacts in the Linux case?
Go to the Maven-Projects-View and click "package" for your aggregator project. IntelliJ will then run Maven which creates all artifacts in the target folder. If you run "install", these artifacts will be copied to the local repository. Maybe you didn't do that under Linux yet, so your repository is empty - under Windows, I suppose that IntelliJ was smart enough to refer to those artifacts while importing the project. I personally do not know of any feature in IntelliJ that would automatically package/install all projects on reimport - I'd consider this rather annyoing.

IntelliJ steps through the wrong lines when debugging remote Java application

I tried to remote debug a maven plugin for a liquibase project with Intellij. IDEA is highlighting the wrong source code line.
I manually built and installed the plugin in my local maven repository from sources in my Intellij project. Intellij version is 11.1.3 and maven version is 3.0.4 running on Ubuntu 12.04.
For debugging the maven plugin I used mvnDebug comand.
If someone has any ideas please give me some advice. I'm not too used to remote debugging (in fact this is the second time I've done this).
For me, whenever IntelliJ is highlighting the wrong line, it was always because the version of the JAR/classes being used to run the application differs from my source files - i.e. different version of the sources were used to build the JAR and/or classes.
You are going to have to be sure that you are working from the exact source that was used to build the classes you are debugging.
You can verify this by looking at the classpath being used to launch the application, locating the JAR file or classes directory that contains the classes you are debugging, and verifying that they were built from the sources you are inspecting.
Note that when you are debugging third-party libraries, you often can download the "sources" jar (see IntelliJ2-IDEA get Maven-2 to download source and documentation).
If you stumbled across this post, and sure that the source and JAR are the same code, then this could be your problem.
http://youtrack.jetbrains.com/issue/IDEA-8021
Instead of doing remote debugging you can run the plugin directly from IntelliJ.
Have the liquibase plugin project loaded in IntelliJ by just pointing at the pom.xml.
Choose Edit Configurations...
Press the + button to Add New Configuration.
Select Maven.
Enter the Working directory to the project you want to run the plugin on.
Enter the Command line. Could be process-sources, compile or liquibase:status depending on what you want to do.
Press OK
Set a breakpoint in the Liquibase Mojo.
Now you can start this configuration by pressing Shift+F9.
Maven will start and finally you will see that your plugin is waiting at the breakpoint!
Make sure that you have defined the plugin in the target pom.xml with correct version and also that you build the plugin before launching it. You can ensure that by enabling Make in the Before Launch pane.

Resources