IntelliJ & Maven - mvn command not found - maven

I'm trying to build a drop wizard project created with IntelliJ.
when I run
mvn package
I get
bash: mvn: command not found
I'm on a Mac and I'm following this tutorial: http://www.dropwizard.io/0.9.2/docs/getting-started.html
According to IntelliJ documentation (https://www.jetbrains.com/help/idea/2016.1/maven.html?origin=old_help)
Maven integration is shipped with IntelliJ IDEA, and you do not need to perform any additional actions to install it. You can start using it straight away for importing Maven projects, working with them and for running Maven goals.
So I don't know what I'm suppose to do in order to use the command line
Any idea?
Thanks

In IntelliJ, on the right hand side, click "Maven", and expand "Lifecycle"
Select "Package" and click "Run" (green arrow).

mvn is the command line tool for Maven.
See https://maven.apache.org/install.html for details on how to install it.
Or as you are using a Mac if you use brew try using it to install the maven formula.

If you have maven properly installed and you want to configure intelliJ terminal with a custom Terminal or if you want fix "command not found",
follow these steps:
Click > File
Click > Settings
Click > Tools
Click > Terminal
Edit "Shell path" # "Application Settings", if you use git bash change current path with:
C:\Users\Work\AppData\Local\Programs\Git\bin\sh.exe --login
// The path you may have differs based on your OS, in example: "installationPath\Terminal Folder\bin\sh.exe --login"
Click > Apply
Click > Ok
I used git bash but technically it should work with every terminal. Do not forget to add --login after the *.exe
If it still doesn't work maybe you need to check:
Click > Environment variables
Click > System Properties
Click > Environment Variables
Click > System Variables
Select > Path from the list
Click > Edit
Click > New
Insert the path of your maven bin folder, in example:
"installationPath\apache-maven-3.8.6\bin"
Also insert the path of your jdk, in example:
"installationPath\Java\jdk-18.0.1.1"

Related

Intellij Spring Boot project run configuration

I run my Spring Boot project from the command line using mvn install and then mvn spring-boot:run -Dspring.profiles.active="development". This works fine but is not very convenient. I would like to start it directly from Intellij by clicking the green run button.
I tried to add a new run configuration but without success. I set "main class" and "active profiles" and tried to add "run maven goal" but the last one does not work (when I choose the working directory - the one with pom.xml - it says Maven projects not found). What should I exactly set up ? I just want to run the two commands mentioned above from the root directory of the project.
Update: here is the project structure project structure
Please follow the following steps:
Set the maven goal by clicking the "+" in IntelliJ (circled area)
Write mvn install.
Set the VM Options as: -Dspring.profiles.active=development
After that it should just run fine just by clicking the green play button.
This should help you get started.

Jenkins plugin shows on Plugin page but does not show on configuration page

I am creating a hello world plugin for Jenkins by following Tutorial: Create a Jenkins Plugin to integrate Jenkins and Nexus Repository. After I followed the steps, I can run Jenkins and test the plugin.
It shows on Installed Plugin Page.
Then I go to Configuration page and expect to see Hello World Builder section like the below image, but there is not.
What steps did I miss? Is there anything I have to do before having that plugin show up on the configuration page?
Update
This is the project layout, I haven't modified anything on it yet.
What command did you use to generate the plugin skeleton?
FYI, from the tutorial above, mvn -cpu is deprecated.
To generate the plugin skeleton, use:
mvn hpi:create
or
mvn -U org.jenkins-ci.tools:maven-hpi-plugin:create from the Jenkins Plugin tutorial
I'm going to include each step for what worked for me:
mvn hpi:create, then enter groupId (press enter to use default: org.jenkins-ci.plugins) and artifactId (name of the plugin)
cd new-plugin-name
mvn eclipse:eclipse
mvn package
mvn hpi:run
(default port is 8080, but you can set your own with Dport option (i.e. mvn hpi:run -Dport=9999, use this if port 8080 is in use - otherwise mvn hpi:run will fail)
Open browser and enter URL "localhost:8080" (or 9999)
You should the page below. Click the link and that'll take you to Jenkins home page
Click 'Manage Jenkins' > Configure System. Scroll down near the bottom of the page and you should see the Hello World Builder section
Go back to Jenkins home page and click New Item
Give the project any name, select Freestyle Project, click OK.
Scroll down to the Build section and click 'Add build step' > Say hello world
Enter a name (i.e. TestName), save the project, then run a build ('Build Now')
Click on the latest build under 'Build History' > Console Output.
I had a same problem and solved it.
I am sure you are using eclipse as IDE and imported HelloWorldBuilder as a maven project.
In my case, I converted it to eclipse project after deleted and regenerated again.
Please refer "Setting up a productive environment with you IDE" section of the following url and use this command.
mvn -DdownloadSources=true -DdownloadJavadocs=true -DoutputDirectory=target/eclipse-classes -Declipse.workspace=/path/to/workspace eclipse:eclipse eclipse:add-maven-repo
https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial
If you launch the project after convert and rebuild it, the hello world builder section will be shown in your jenkins configuration menu.
I recently had the same problem. Apparently currently (see date of this message) master of the hello world example is wrong. I needed to change
<artifactId>hello-world</artifactId>
to
<artifactId>hello_world</artifactId>
because some component in the middle doesn't accept "-". I think hpi:create will tell you that, unfortunately the debug log files don't. But the existing hello-world should already have those things correct.
Even I faced same problem, I think reason is because I imported to eclipse as a maven project. I deleted folder and ran command
mvn -U org.jenkins-ci.tools:maven-hpi-plugin:create
to create new project. Then ran mvn hpi:run and it showed up well.

cant' install sublimemaven plugin successfully

I follow this https://coderwall.com/p/etesrq to install the sublimemaven plugin for my sublime2.
All steps seems ok, but I can't get the 'Maven' menu item in 'Tools->Build System'.
I have added the
"m2_home": "F:/jill/job/software/apache-maven-3.0.4",
add
"maven_menu_commands":
by following https://github.com/nlloyd/SublimeMaven.
and restart sublime2 several times.
but still can't get it.
Could some body help?
Thanks
I find that I don't have "maven" in "tools" -> "build system" either, but using cmd + shift + p , then type in "maven", I can see several commands, one of them is "maven: Run...", I use this command when I need to specify one. Commonly, other default maven commands could satisfy your requirement.
Nick Lloyd's SublimeMaven plug-in installed nicely for me on Sublime Text 3 but showed build commands only in the Command Palette (CTRL+SHIFT+P).
Only after I added Andres Koetter's configuration file to the Packages/User directory of my portable SUBLIME_TEXT_3/Data/ dir (or ~/.config/sublime-text-3/ for some) I found a Maven build option in the Tools > Build menu. This new option enables Sublime Text 3's build system run commands for Maven builds, that is:
Build (CTRL+B) : run default build configuration
Build with ... (CTRL+SHIFT+B) : select mvn goals, profiles, command-line options, etc.
Just adding a working directory tip that I found on this URL: https://gist.github.com/4ndrej/5162986
Once I finished instructions provided by user2951392, I got working Maven menu on sublime text 3. Then I tried to build some projects, but for each one of them I got an error like this: "...there is no pom.xml file on directory E:\sublime...".
So, just change the following content on Maven.sublime-build file:
old: "$file_path"
new: "${project_path:${folder}}"
With this final change I got my sublime text 3 and Maven 3+ working fine.
Cheers!

applying mvn commands via intelliJ IDEA

How to run following mvn commands via intelliJ IDEA? I can run these commands from terminal but how to do the same in the IDE for the project opened in it?
--mvn clean dbmaintain:updateDatabase
--mvn clean package
Go to "Edit Configuration" and create a new "Maven Run/Debug Configuration". There you can define the command line and the working directory.
An other way of doing the same is : open de maven projects view (on right edge of the window) expend your module, expand the "Life-cycle", select the phase you need to run. Then a simple rigth click shows a popup allowing you to "run" the phase or create a run configuration preconfigured with the working dir and the phase. (you can always edit it)

Method to run maven command in Netbean

How can I run mvn clean install -Pjnlp command in Netbean 7.3 ?
To activate the profile via Netbeans, you may try the following task: -
Right click at your project and select properties from the context menu.
Select the Configurations from Categories on the left panel.
At the right panel you will see the various profiles defined in your pom. You can Activate them by selecting them and click Activate button or you can create the new on by clicking the Add button.
To achieve your requirement as mvn clean install -Pjnlp is simply just right click at the project and select Clean and Build. The Clean and Build calls mvn clean install together with the activate profile.
I hope this may help.

Resources