Problems with Maven default folder - maven

I'm Mohave Mac User.
I installed Maven and created project in Eclipse. Name of the project is "Mavenjava".
When I try to clean, compile, test command from Eclipse it doesn't work because it looking for a POM file in /User/Max/, not from /User/Max/Mavenjava
When I copy my POM file into /User/Max/ - "clean" command works but I can't do "compile" and "test" commands in terminal, because I see mistake like "skip non existing resourceDirectory".
It is still looking this files here /Users/Max/src/main/resources, but not in /User/Max/Mavenjava/src/main/resoursces/
How I could change default folders for Maven?
I spent 3 hours and don't know how to solve this problem.

Related

Vscode with custom settings.xml Maven file per project in a workspace

I have a Vscode workspace with a bunch of Maven projects, and which one has its own Maven settings.xml file.
As each project has its own settings file with the same name but in its own root folder I got success configuring both the workspace as each of the projects with such an option: {"maven.executable.options": "-s my_settings.xml"}.
Although, I can run successfully any of Maven commands for all projects, Vscode reports problems in the pom.xml files about missing artifacts and the same errors are reported when I run tests from the "Testing" in the Side Bar.
When I copy one of the project's settings file to the ~/.m2/settings.xml that given project works fine, no errors at all.
So, I conclude Vscode doesn't respect the "maven.executable.options" for all of project operations inside IDE, like tests and maybe others operations but only for directly launched Maven commands.
I don't want to merge all those settings.xml files into a big one in my local ~/.m2/settgins.xml each time I have to open a given set of projects.
Is there a way to teach Vscode to use different settings.xml for each project and make it work properly in all Vscode operations (not only Maven commands)?
VSCode setting ID: java.configuration.maven.userSettings
In VSCode, go to Preferences > Settings > Workspace
Search 'maven'
Set 'Java > Configuration > Maven: User Settings' to ./settings.xml to make VSCode use the local settings.xml of the project
Restart VSCode if needed
Screenshot
you can use
mvn --settings settings.xml clean install
to individually point respective settings.xml for each java app
First, check whether the terminal executes the command "mvn ... -s my_settings.xml", which indicates the correctness of vscode-maven plugin. If so, the problem comes from the command itself.
A workaround is to delete the global maven settings.xml, typically in $MAVEN_HOME\conf\settings.xml. Then mvn ... -s my_settings.xml should work. It works fine for me.
The reason may be that when global maven settings file is found, mvn CLI may ignore the settings file in mvn option.

Share Maven run configurations with other developers using Intellij IDEA

We have the following project setup: Maven, Eclipse, Subversion. Eclipse Launch configurations are in a separate docs folder next to the pom.xml. The launch configurations run something like mvn clean install -Pdev or mvn tomee:run -pl something-ear
The good thing is that a shared run configuration is picked up by the IDE and shown in the External Tools run commands. This way, every developer that checks out this project immediately has access to run the build.
We would like to have something similar using IntelliJ IDEA, but I haven't found a good equivalent. What I have considered so far:
Share run scripts
My first idea was to replace the launch configurations with run scripts. I just could not figure out how to have those run scripts run inside IntelliJ IDEA just the way a Maven goal would be executed.
Share IDEA project configuration
The IDEA project configuration (specifically .idea/runConfigurations) inside the checked out directory is not a good solution. We have (speaking one IDEA project with different IDEA modules depending on the task at hand: as a developer you might need multiple IDEA modules (and sub-modules) in the same IDEA project
An IDEA project consisting of the following modules is not something unusal
projectA/trunk
projectB/tags/1.2
projectC/branches/some-change
My preferred solution would remove all IDE-specific configuration from the repository and have some kind of run definitions either in the project folder or a folder next to the pom.xml that a developer can run from the command line or from her IDE of choice.
The optimal solution would let me define something like this in the pom:
<runConfigs>
<default>clean install</default>
<container>tomee:run -pl something-ear</container>
</runConfigs>
This configuration would then be picked up by the IDE and provided as a run or launch configuration to the developer.
Any ideas or suggestions?
Thank you very much!
My current approach is a hybrid solution:
No configuration in the separate modules
One IDEA project configuration with run configurations managed in VCS
The .idea/runConfigurations directory is versioned separately from the project sources. It contains commands with a working directory set relative to the PROJECT_DIR:
<MavenRunnerParameters>
…
<option name="workingDirPath" value="$PROJECT_DIR$/path/to/submodule" />
</MavenRunnerParameters>
When setting up a new project, the developer also checks out this folder and has a set of pre-configured launch configurations for all projects. The downsides are
All launch configurations are managed centrally instead of with the module
The IDEA project directory has a fixed location relative to the modules. If you set up another project, you will have to change the run configurations
The setup does not clearly state how changes to the launch configurations are shared with other developers

Errors when import existent maven project into eclipse kepler

I have imported a existent maven project (swagger for jersey jax-rs) into eclipse.
I get a bunch of errors:
It always has to do with the jackson-databind.jar
Example error:
Archive for required library: '.../.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.5/jackson-databind-2.1.5.jar' in project 'swagger-core_2.9.1' cannot be read or is not a valid ZIP file
I cannot find the .m2 folder? I am new to the maven stuff,
do i have to install something extra before i import a maven project into eclipse?
Thx
I cannot find the .m2 folder?
By default the .m2 directory is located at the home directory.
For *Unix operating systems, it will be something like /home/<user_who_fires_maven_commands>/.m2/...
For Windows machines , the m2 will be located at C:\Users\<user>\.m2\...
As for the exception you are getting
Archive for required library: '.../.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.5/jackson-databind-2.1.5.jar' in project 'swagger-core_2.9.1' cannot be read or is not a valid ZIP file
It is most probable that the archive file has gotten curropted ( maybe a download issue or might be possible that its sha1 doesn't match with the one that is on the central repo ). So you can try by simply deleting this jar file and then run mvn install and it will re-attempt to download the file again.
Another thing I would like to point out is that since this is a new eclipse installation, I would suggest that you re-index your local m2 folder so that this new eclipse knows about the files and folders inside the original m2 folder. To re-index, goto Window -> preferences --> Maven --> User settings --> there will be a text field stating the path of the .m2 ( make sure its correct ) and then press re-index

How to make a path relative in the vmargs?

In my project I have an eclipse cdo-server which is set up as described here: http://wiki.eclipse.org/Setting_up_a_CDO_Server .
My project structure is like this:
-cdo-server plugin
|- config folder with cdo-server.xml
|- pom.xml
-cdo-server-product
|-pom.xml
-master
|-pom.xml
When I start my cdo-server.product as Eclipse application everything works fine.
When I build it and materialize it with Maven, it also has a BUILD SUCCESS. But when I start the CDO-CommonRepositoryServer.app which was built with Maven, there is the error:
!MESSAGE CDO server configuration not found:
/Users/pathtoCDO-Server/CDO-CommonRepositoryServer.app/Contents/MacOS/${resource_loc:/cdo.server/config}/cdo-server.xml.
This is logical, because this is the wrong path. When I enter the absolute path to the cdo-server.xml in the vmargs (-Dnet4j.config=/Users/pathtoCDO-config/cdo-server.xml) it also works. However, I want to make it relative, so that everybody in our git-repo can use it and not only in my folder structure.
Is there any possibility to make this path relative?
With -Dnet4j.config="${resource_loc:/cdo.server/config}" it only works when i run it as an eclipse application, but not as maven built .app file.
Update:
Now I can start the CDO-CommonRepository.app file if I take
-Dnet4j.config=../../../../../../../../../../cdo.server/config
as path, but then I can only start it with the maven built file and I cannot start it from inside Eclipse anymore...
I've created a new question for this new problem: Slash in property name in pom.xml
I just solved my problem in copying my files with Maven copy-resources in this stupid /Users/pathtoCDO-Server/CDO-CommonRepositoryServer.app/Contents/MacOS/${resource_loc:/cdo.server/config}/cdo-server.xml folder.

How to enable jsp-tags autocompletion in NetBeans within NetBeans Maven projects?

Using NetBeans 7.1.2.
When editing pages with NetBeans as per the procedure explained below, the IDE offers only autocompletion for <jsp:...> tags:
This is how I have created the NetBeans project and the jsp (though it isn't archetype specific, nor the issue has anything to do with opencms): I have created a maven project with the OpenCms-Module archetype
mvn archetype:generate -DarchetypeCatalog=http://bp-cms-commons.sourceforge.net/m2repo
The archetype creates a maven project with jar packaging.
After that, I have added a jsp under src/main/opencms/modules/blahblah/templates.
And then I have added the taglibs.standard dependency to the project, to try to provide NetBeans with the corresponding tlds.
After several hours trying to get this working, I found this reported and closed bug that hinted me into the right direction:
Added src/main/webapp directory Edit 1: There is autocompletion only for jstl tags if the files are inside src/main/webapp. Workaround in linux (not sure if windows links will work): Create a symlink:
ln -s opencms/ src/main/webapp from the project root folder
Change maven project packaging to war (Project properties -> General -> Packaging)
(Notice that neither the #taglib directive nor the taglibs.standard dependency are necessary.)
If the Web Pages entry does not appear under your project (in the projects view), you may need to restart NetBeans. Now you'll have full autocompletion (only) under src/main/webapp! :-)
Edit 2
Unfortunately, if under version control, NetBeans sees the symlink as a new directory, and all files under it, as new files :-( This is very inconvenient, because to access the IDE integrated version control functionality, you still need to open the original resource.

Resources