maven-assembly-plugin and eclipse Workspace resolution - java

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.

Related

IntelliJ - Resolve Maven Artifacts

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?

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.

Maven dependencies not visible under Build path in Eclipse Luna

I'm using Eclipse Luna for my project. I've imported a Maven project into it. Right click->import->import existing maven projects. I made mvn clean package install under run configurations. It ran successfully till mid of project, and in the sub modules, it got failed due to some issue in Java file. But whatever the JAR's that have been fetched should be displayed under Maven dependencies under Build path right?
Here is the screenshot
Do I require to make any steps here?
Right click the project and Configure as Maven project

Unable to force Eclipse to use the Project instead of the jar

I'm facing a problem with Eclipse and Maven.
I have 2 Maven projects in my Eclipse's workspace :
Project A : uses Maven but is not declared as Maven project in Eclipse
Project B : declared as Maven project in Eclipse and has a dependency with Project A
=> Project B has the jar of Project A in the "Maven Dependencies" of Maven plugin for Eclipse.
My problem is that when I build Project B in Eclipse, it uses the jar of Project A (which is in M2_REPO) instead of the Eclipse project directly, although I have the property "Resolve dependencies from workspace projects" enabled in the Maven plugin settings.
Does anyone have an idea for my problem ?
Thanks in advance :)

What do I do with the pom.xml file?

I have just downloaded a project from github, it has a pom.xml and is missing many dependencies.
I installed m2e Maven integration in Eclipse plugin but now what do I do? It's installed and seems to be working but how do I download the dependencies now?
You checkout the git files to a location different from your Eclipse workspace.
Start Eclipse on a clean workspace and install m2e. (I usually install m2e-wtp to get web projects)
Use File -> Import -> Existing Maven projects.
Point to the pom.xml you want to use in the files checked out above.
Wait while Eclipse downloads half the Internet.
Ready.
Right click on your project, run as -> maven install.
If you can't see these, you either incorrectly installed m2e, or you need to import the project as a maven project.
In that case, delete the project from your workspace (do not check the "delete contents on disk"). Right click in the project explorer and click on import... From that dialog, you can select existing maven projects, where you need to navigate to the highest directory containing a pom.xml file.
Also, if you have maven installed on your computer (not m2e in eclipse), you can open the directory that contains the pom.xml and just type mvn clean install. This will build your project.
If you get a "Build success" message, you'll know that the dependencies have been fetched correctly.
In eclipse, You have to convert your project to a maven project. right click on your project -> maven (or configure) -> convert to maven project (or enable dependencies management).
This should update your dependencies automatically, if it is not the case then right click your project -> maven -> update project (or update dependencies, it depends on the verion of m2e you are using).
It should be enough to build the project. The dependencies should be downloaded during the build.
Pom.xml files are used for Maven projects.
Depending on your Eclipse version, maybe it's not compatible with Maven out of the box. If not, you can install a Maven plugin (like m2e) so that the project can be viewed as a Maven project.
Maven will do the dependency management (if pom.xml file is configured properly)
When you right click on your project->Run As-> Maven install it will download all the dependencies that it does not have already in your local repository.

Categories

Resources