IntelliJ - Resolve Maven Artifacts - java

With IntelliJ IDEA, is it possible to "Resolve Workspace Artifacts"?
Meaning say I have a project
- root_folder
-->module1
---->pom.xml
-->module2
---->pom.xml
-->module3
---->pom.xml
-->project1
---->pom.xml
-->project2
---->pom.xml
-->project3
---->pom.xml
This is an Eclipse project that I opened in IntelliJ and with Eclipse when I run jetty:run on any of the 3 projects it can resolve the modules that is it dependent on because of the "Resolve Workspace Artifacts" of the Eclipse IDE, however for IntelliJ this is a bit of a challenge.
There is no parent POM, each module are quite stand-alone maven projects.
Using IntelliJ when I run project1 which depends on module1; it is unable to resolve module1 unless I mvn install the module1 which is very cumbersome, I have to mvn install for every changes in the module. Not really productive at all.
Additionally, as mentioned the project is actually an forked Eclipse-based project that is why I cannot modify the maven structure to work-around the project, the only option I have is a solution at IDE level for the projects to be able to do something similar to Resolve Workspace Artifacts.
Similar to m2Eclipse plugin: What does 'Resolve Workspace Artifacts' do?

Related

maven-assembly-plugin and eclipse Workspace resolution

I have a project, which uses the maven-assembly-plugin to compile one JAR out of a number of projects.
I want to run the build with eclipse (Neon 4.6.3). When I run the build, I select the option Resolve Workspace Artifacts.
Resolving workspace artifacts seems to work fine for compiling the classes and testing. However, when it comes to executing the assembly into a JAR, maven does not use the projects from the eclipse workspace but only projects in the local maven repository.
Is there a way to make the maven-assembly-plugin also resolve the projects in the eclipse workspace?
maven-assembly-plugin does resolve workspace artifacts.
I just had configuration issues in the workspace. Specifically, not ALL dependencies for the project were available in the workspace. After I had assured, that ALL dependencies can be resolved from the workspace, the maven-assembly-plugin collected the correct versions.
(You can check this by extending the Maven Dependencies under the project and assert that no *.jar dependencies are left to things which should be resolved from the eclipse projects).
For any maven plugin errors in eclipse IDE, right click on project then select Maven -> Update Project -> select "Force Update of Snapshots/Releases" -> Ok.

IntelliJ Community with 2 maven projects in same window

I have a maven project project-a and project-b wo depends on project-a.
How can I work with this 2 projects in same IntelliJ window?
I want to be able to make changes on project-a and reflect them to project-b without deploy/install the project-a. I already do this on Eclipse using m2e plugin.
EDITIED
After setting the Build, Execution, Deployment | Build Tools | Maven | Importing >> Import Maven projects automatically the IDE was able to build part of my projects.
Now I'm facing another problem. This project-a has a dependency tohibernate-entitymanager who has a dependency to hibernate-core who has a dependency tohibernate-jpa-2.1-api.
My project uses some classes from this hibernate-jpa-2.1-api jar, but seems that the IntelliJ can not resolve sub-dependencies, forcing me to redeclare this dependency (hibernate-jpa-2.1-api) on theproject-a / pom.xml. Is this the expected behavior?
You should add you maven projects as modules to Intellij IDEA as already said CrazyCoder.
And then do 'Add As Maven Project' by right click on the every module's pom.xml in the Project tab.
This way you will be able to use cross-module searches, refactorings etc. Compilation will also be performed against the added Maven Projects without a need to install artifacts into the repository.

IntelliJ IDEA : support both SBT and Maven on a single project

I already have a project in IntelliJ IDEA based on SBT. It works fine, compile and run. Now I want to add the Maven support as well.
How is it possible in IntelliJ IDEA having support for both build managers SBT and Maven in the same project and switch between them ?
In my experience you should have either maven or sbt enabled. Never both.
The solution:
checkout project from repository to project_sbt directory
open project in intellij as sbt project (just open project_sbt/build.sbt from disk)
checkout the same project from repository project to project_maven directory.
open project in intellij as maven project (just open project_maven/pom.xml from disk)
Disadvantages of this solution:
Changes in sbt project are not visible immediately in maven project (and vice versa)
You have to maintenance two build systems (special plugins)

m2eclipse's "Resolve workspace artifacts" non-functional?

Having projects A and B in Eclipse, where A has a dependency on B, everything works fine if I try to "Run As/Java Apparication" A from Eclipse. However, when I try to "Run As/Maven Build...", it complains:
The POM for groupname:projectb:jar:0.0.1-SNAPSHOT is missing, no dependency information available
and then later it attempts to download my local dependency from Nexus and that of course fails.
"Resolve workspace artifacts" is enabled in the Maven run configuration. "Workspace resolution" is enabled for all projects. I have already tried:
disabling/enabling everything
Project/Clean everything
Maven/Update Project everything
Installed an external Maven (3.2.1) and repeated all of the above
Using latest Eclipse Kepler with everything updated.
Ideas ?
when you run app it resolves artifact from workspace and it doesn't look into maven local repository, when you invoke maven command from eclipse (maven build) it invokes native mvn or embedded in both case it looks up for dependency in local maven repository and it doesn't find it
so to fix this, you run maven build on project B first with goal mvn clean install and then invoke your maven build on project A that will work

How to fix m2eclipse plugin?

I have java maven project in Eclipse that depends from other projects and for near 1000 library jar.
But I cannot use m2eclipse at all.
For create Eclipse project is use eclipse maven plugin like:
mvn eclipse:eclipse -Dwtpversion=1.5
It works well. But when I go to Eclipse and click on m2eclipe - update dependencies - all library jars disappear!
So for work I have disabled java projects as maven in Eclipse. I suppose that there is some problem with eclipse internal variables. Does it correct? What have I check? Does exist some log? Or this is common bug of m2eclipse plugin?
Thanks.
maven eclipse plugin (i.e. mvn eclipse:eclipse) no longer works with m2eclipse or its current version, m2e.
Assuming you have the latest Eclipse (Indigo, which comes with m2e), you should have better success opening the maven project directly (Import as Maven project).

Categories

Resources