Unable to run eclipse goal using mvn-ant-task - maven

I am trying to run eclipse:eclipse on a maven project from an ant build file.
But its failing with error:
Eclipsify:
[echo] Converting Maven Project to Eclipse Project
[artifact:mvn] -Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.org.apache.tools.ant.ExitExceptio
n: Permission ("java.lang.RuntimePermission" "exitVM") was not granted.
[artifact:mvn] at org.apache.tools.ant.types.Permissions$MySM.checkExit(Permissions.java:194)
[artifact:mvn] at java.lang.Runtime.exit(Runtime.java:107)
[artifact:mvn] at java.lang.System.exit(System.java:962)
Below are the configurations in my build.xml
<project name="ConnectAll"
default="default"
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
And in the ant target I have added eclipse goal as given below
<artifact:mvn pom="${pom}" mavenhome="${MVN_HOME}">
<arg value="eclipse:eclipse" />
<arg value="-Dmaven.multiModuleProjectDirectory=true"/>
</artifact:mvn>
Also i have verified that the ${MVN_HOME} property and the actual M2_HOME are same.
Can someone help me figure out what am I missing here.

Since Eclipse Juno (v4.2) it contains Maven integration.
Maven projects should be imported using the import wizard:
Eclipse Menu: File -> Import...
The dialog Import, on the page Select opens
Select from tree select Maven -> Existing Maven Projects
Press the button Next
The page Maven Projects opens
Fill in the field Root Directory, with the location where the Maven project(s) are located (Use the button Browse... to easliy select the location (This will show a selection window, when pressing OK, or seleecting a directory, it can take a while, before all the Maven projects are fuond, as all underlaying directories are scanned))
From the Projects view select the project you like to import (project which already have been imported, are shown in gray (not selectable). This can also happen if different Maven project / modules do have the same artifactid. As the Maven artifactid, is used as the Eclipse project name).
Press the button Finish, to start importing the selected Maven projects
Warning This will take a while, as many times, lost of dependencies need to be downloaded as well.
Remark Never use the mvn eclipse:eclipse, when using Eclipse with integrated Maven support, as these conflict with each other.

Related

Maven Build Scripts Found - IntelliJ - What are the build scripts, where are they cached?

So basically, as the title of the post states, I'm wondering what IntelliJ is referring to when it says that Maven build scripts were found? Are these scripts that Maven keeps cached or are they IntelliJ specific? If they are generated by Maven, where are they stored/ how can I view them if that is possible?
Thanks!
This notification is to inform you that you are working with IntelliJ IDEA project that is not linked to the external build system (Maven or Gradle).
When you open a project in IntelliJ IDEA that was not initially imported from Maven/Gradle and IDE detects pom.xml or build.gradle files in the project, it will display a notification so that you can properly import the project from the build script.
Build script in your specific case is a pom.xml file stored inside a project directory. It's recommended that you open Maven projects by importing the root pom.xml file.
When a project is not imported from the external build system, your source roots configuration may be incomplete and you may be missing the dependencies.

Why intelliJ doesn't show maven dependency as External dependencies and also shows red symbols even though the dependencies are downloaded

I'm cloning my maven project from GIT and then doing mvn clean install. My dependencies are downloaded successfully, but I'm not able to see it in External Libraries. Also my code shows red colored as if dependencies are not available. I did Invalidate cache/restart, did re-cloning, removed .idea folder, but no luck.
Any solution to this?
THanks!
Make sure you have opened the Project as Maven project and that it has been imported successfully from Maven pom.xml build file. In an existing project you can import Maven from Maven tool window. See Link a Maven project
steps:
Open the Maven tool window.
In the Maven tool window, click the + icon to attach a Maven project.
In the dialog that opens, select the desired pom.xml file, and click OK.

No maven in intellij idea

I have one project open in IntelliJ. In that I am able to see maven tab in its left sidebar:
Also, I am able to see Maven in View > Tool Windows > Maven:
I tried to open another project in another IntelliJ window, but it does not have both of the above:
It may be not required to have that maven tool window for the project that you have opened in the second Idea instance.
If the opened project is a maven project (at least if you have a pom.xml associated with that project) you will have this option available in View -> Tool Windows -> maven
If it's a maven project, try importing the project as a maven project as well

Building maven project with IntelliJ doesn't create JAR

When running the following command in the terminal, I can see in the target directory the JAR file, whereas when building with IntelliJ I only see the compiled classes.
Why?
To get the jar built by IDE you need to configure the jar Artifact to build:
If you want to build your project and execute run actions through Maven, you need to delegate all those actions to Maven with the Delegate IDE build/run actions to maven option located in the Maven settings.
Build a project with Maven #
Click icons general settings svg in the Maven tool window. Alternatively, from the main menu select File | Settings/Preferences | Build, Execution, Deployment |Build Tools | Maven.
Click Maven and from the list, select Runner.
On the Runner page, select Delegate IDE build/run actions to maven.
more detail see here

Error package does not exist in Intellij but working in Spring Tool Suite STS

Alright, this is driving me nuts... I am working on a Maven project and I have 3rd Party JAR dependencies that are giving me compilation errors on IntelliJ but not in STS.
My simplified project structure is like this:
FERPAPortlet
-src
--main
---java
----edu.sandiego.parent
-----FERPAPortlet
---resources
---webapp
----META-INF
----WEB-INF
-----jsp
-----lib <----- 3rd Party JARS are here
-----liferay-display.xml
-----liferay-plugin-package.xml
-----liferay-portlet.xml
-----portlet.xml
-----web.xml
--test
-pom.xml
In SpringSource Tool Suite, if I run compile/package, everything runs fine! In fact, if I run it first in STS and then reopen with IntelliJ, the issue is solved. Nonetheless, I prefer IntelliJ over STS...
A sample error I get would be something like this when I run maven compile:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] C:\Users\rico.r-10\Documents\GitHub\github.sandiego.edu\FERPAPortlet\src\main\java\edu\sandiego\parent\FERPAPortlet.java:[3,35] error: package com.sghe.luminis.core.spring does not exist
However, when I navigate to that line, IntelliJ does not highlight it red as an error and I can actually Ctrl+click and IntelliJ will navigate to the library.
I already added the libraries via
Project Structure > Project Settings > Modules > MyModule > Dependencies tab.
What is STS doing that I'm missing in IntelliJ?
EDIT: Got it working! This is what I did.
I deleted the lib folder with the 3rd Party Jars.
I then manually added those Jar files through the command line, like so:
mvn install:install-file "-Dfile=C:\luminis5libs\luminis-dal.jar" "-DgroupId=com.sghe.luminis" "-DartifactId=luminis-dal" "-Dversion=1.6.0" "-Dpackaging=jar"
Finally, I modified the POM to include those dependencies, like so:
<dependency>
<groupId>com.sghe.luminis</groupId>
<artifactId>luminis-dal</artifactId>
<version>1.6.0</version>
</dependency>
You shouldn't have a lib directory. With maven, all the jars come from your local repository, and are copied into the lib directory under the target (build) directory. Check your maven dependencies, and delete lib and everything under it. Your errors are because intellij doesn't see the jars in your defined path.
Click on Maven Projects at the right border of intellij, after click on the 'Reimport all Maven projects' (the blue circular arrow)

Resources