New to maven. When I run this command i get access denied error? any help? I am trying to configure maven to run with eclipse. Let me know if you need more information.
mvn -Declipse.workspace=<c:\temp\eclipse\workspace>eclipse:add-mvn-repo
Path:
C:\apache-tomcat-7.0.55\bin;C:\apache-ant-1.9.4-bi
n\bin;C:\apache-maven-3.2.2\bin;C:\Program Files (x86)\Google\google_appengine\
C:\Temp\eclipse\workspace>mvn -v
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:4
2-04:00)
Maven home: C:\apache-maven-3.2.2\bin\..
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
C:\Temp\eclipse\workspace>cd\Temp\eclipse\workspace
**C:\Temp\eclipse\workspace>mvn -Declipse.workspace=<C:\Temp\eclipse\workspace> eclipse:add-maven-repo
Access is denied.
C:\Temp\eclipse\workspace>**
Configuring Maven to run within Eclipse.
Eclipse has an embedded version of Maven which you can use. Assuming that you want to use Maven within Eclipse and outside of it, download Maven from http://maven.apache.org/download.cgi, extract it and set the M2_HOME environment variable such that it points to your local Maven installation directory.
Set JAVA_HOME environment variable so that it points to the JDK which you want to use.
Append %JAVA_HOME%\bin and %M2_HOME%\bin to the Path so that the jdk and mvn executables can be executed from anywhere.
Now open an Eclipse Workspace and go to Window > Preferences > Maven > Installations. If you want to use your standalone installation instead of using the embedded one, you can change it here.
If you have a specific Maven settings file which you want to use, then dump that settings.xml file under the .m2 folder of your User home directory.
Once this is done, you can easily use Maven from within eclipse.(File > Import > Maven > Existing Maven Projects) or create a new one (File > New > Maven > Maven Project). Once you have a project in your workspace, you can run different Maven goals on it by right clicking on the Project and selecting what you want from the Run As option.
Related
I was testing the move from a Jenkins docker image to another using Thinbacvkup and restore the backup and restore went well and of course it didn't bring maven with it (No problem there) I went online and got the latest apache maven bin file (apache-maven-3.8.4-bin), extracted and set up the global tool configuration, export M2_HOME ...ETC. BUT for some reason, it didn't work giving me the same message
#tmp/durable-e665ee46/script.sh: 1: mvn: not found
searched and searched nothing worked, so I went to the original docker and got the same maven from there (apache-maven-3.5.3-bin)edited the configs and all, and it worked but now I wanted to know why did this work and that won't is there something with my project, build or what?
Not using a Docker image, but had no problem on a clean install, no plugins,
Global Tool Configuration ( /configureTools/ ), add maven configuration:
Create job with Invoke top-level maven step, choose same maven version:
If a pipeline job, then the reference would be tools:
tools {
maven 'maven-3.8.4'
}
or withMaven:
withMaven(
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: 'maven-3.8.4',
Works fine. I did not set M2_HOME or add to PATH; Tool configuration takes care of that.
Started by user admin
Running as SYSTEM
Building in workspace C:\Users\jenkins\.jenkins.2.322.new\workspace\M-Foo
Unpacking https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip to C:\Users\jenkins\.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4 on Jenkins
[M-Foo] $ cmd.exe /C "C:\Users\jenkins\.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4\bin\mvn.cmd -version && exit %%ERRORLEVEL%%"
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Users\jenkins\.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4
Java version: 1.8.0_312, vendor: Temurin, runtime: C:\Tools\Java\jdk8\jre
Default locale: en_CA, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Finished: SUCCESS
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Users\jenkins.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4
Note: you must have proxy set up properly for the "Install from Apache" to populate for "Install automatically".
If you un-tick "Install automatically", then you must input the MAVEN_HOME (which should really be labelled M2_HOME) and then choose that.
Started by user admin
Running as SYSTEM
Building in workspace C:\Users\jenkins\.jenkins.2.322.new\workspace\M-Foo
[M-Foo] $ cmd.exe /C "C:\Tools\apache-maven\apache-maven-3.8.1\bin\mvn.cmd -version && exit %%ERRORLEVEL%%"
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Tools\apache-maven\apache-maven-3.8.1\bin\..
Java version: 1.8.0_312, vendor: Temurin, runtime: C:\Tools\Java\jdk8\jre
Default locale: en_CA, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Finished: SUCCESS
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Tools\apache-maven\apache-maven-3.8.1\bin..
I recently installed Maven and I want to avoid it from downloading content into the Windows OS hard drive. I added the following line in the global settings.xml file:
<localRepository>D:\path\to\maven\local\repository</localRepository>
And as soon as I run mvn clear on a sample project it creates content into the %USERPROFILE%\.m2\repository folder.
How to configure Maven for storing content at D:\path\to\maven\local\repository only?
If you are using eclipse to build your project then eclipse comes with its own embedded Maven. Default location for the maven repository would be ~/.m2/repository. You can change the Default maven installation to your maven installation from Preferences --> Maven --> Installations and then add location of your maven installation.
I'm new to maven. I just joined a new company and they use maven for all their projects.
I set up the company's server for maven dependencies.
I'm using Fedora.
For most of the projects everything goes well. For some of them I get this error when running mvn compile:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project xlayer: Fatal error compiling: Error while executing the external compiler. Error while executing process. Cannot run program "java -classpath "${env.M2_REPO}/org/eclipse/jdt/core/3.4.2.v_883_R34x/core-3.4.2.v_883_R34x.jar" org.eclipse.jdt.internal.compiler.batch.Main -sourcepath "src/main"" (in directory "/home/es/ion_projects/XLayer"): error=2, No such file or directory -> [Help 1]
I looked several hours on the web, nothing would do.
PATH and JAVA_HOME are correctly set.
Running mvn --version gives:
Apache Maven 3.0.4 (rNON-CANONICAL_2013-01-22_13-18_mockbuild; 2013-01-22 14:18:29+0100)
Maven home: /usr/share/maven
Java version: 1.7.0_17, vendor: Oracle Corporation
Java home: /home/es/kit/jdk1.7.0_17/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.8.3-103.fc17.i686", arch: "i386", family: "unix"
UPDATE:
In the pom.xml (of parent, but that is not important), the maven-compiler-plugin defined the executable as
java -classpath "${env.M2_REPO}/org/eclipse/jdt/core/${org.eclipse.jdt.core.version}/core-${org.eclipse.jdt.core.version}.jar" org.eclipse.jdt.internal.compiler.batch.Main -sourcepath "src/main"
in order to use the Eclipse compiler instead of sun's comiler. This worked for developpers using windows. On linux, maven tries to execute "java -classpath ...." as a single command, which does not exist.
I am still loking for a solution. the only hack I found was to put the executable "java -classpath ..." in an executable file on my machine and put the name of that file in the tag on maven.
I am trying to run the Broadleaf Demosite project in eclipse. I have setup the Demosite by following the instructions from the
Getting started guide from broadleaf site. The default code in the build.properties file inside the Demosite maven parent project shows this,
#required
maven.home=/usr/share/maven
#optional
jrebel.path=/usr/lib/jrebel/jrebel.jar
As maven.home is required to start up the server and so now that I have downloaded and extracted the maven 3.0.4 in C:\Users\admin\Downloads\apache-maven-3.0.4\lib.
What is the path I have to specify in the maven.home line in the properties file,
Should it be something like this?
maven.home=C:\User\admin\apache-maven-3.0.4\lib
Maven is shipped into a .zip archive. So unzip maven where do you want. Let's say somewhere like :
C:\User\admin\apache-maven-3.0.4\
then set into your build.properties
maven.home=C:/User/admin/apache-maven-3.0.4
and this should work.
I just changed the maven.home to point to the path like this,
maven.home==/Users/admin/Downloads/apache-maven-3.0.4
Download maven and extract it wherever you want in you computer. Set the path to that directory using command prompt,
C:\Users\admin>set PATH="c:\Users\admin\downloads\apache-maven-3.0.4\bin";%PATH%
Now I'm able to start the jetty server in eclipse with BUILD SUCCESS.
UPDATE:
As the above solution only works for once and you need to run that command every-time you restart the system. For it to work always you have to set the PATH environment variable for maven. Look at How to install maven in Windows? for a permanent solution. Once installed run the following to check if you have installed maven correctly and to check other variables are properly set.
CMD PROMPT
C:\Users\admin>mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 14:14:56+0530)
Maven home: c:\Users\admin\Downloads\apache-maven-3.0.4\bin\..
Java version: 1.6.0_32, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_32\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
C:\Users\admin>
If all the above works fine then in the properties file, you have to specify the maven home directory which in my case was,
C:/Users/admin/Downloads/apache-maven-3.0.4
Sometimes the single forward slash(/) doesn't work in Windows, so replace it with double-forward slash(//) and that should work.
Default value in build.properties file:
#required
maven.home=/usr/share/maven
You have to follow the below format:-
#required
maven.home=C://Program Files//apache-maven-3.0.5-bin//apache-maven-3.0.5
I use maven 3.0.3 and have tried to generate pom for third-party jar like this:
mvn install:install-file -Dfile=cobra.jar -DgroupId=com.cobra
-DartifactId=cobra -Dversion=0.98.4 -Dpackaging=jar -DgeneratePom=true
According to link below it should generate proper pom.xml and install artifact in the repo.
http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html
Meanwhile, it returns such a error:
[ERROR] The goal you specified requires a project to execute but there
is no POM in this directory (D:\cobra-0.98.4\lib). Please verify you
invoked Maven from the correct directory. -> [Help 1]
Why is it asking for pom.xml while it should generate pom.xml?
This is an old question, but was a serious PITA for me for a few minutes, so I thought I'd share:
I just ran into this problem, and I believe that the issue is probably platform-dependent. The real tip-off was that the solution from Cyril's answer wasn't working as expected: despite my specification of -DgroupId=com.xyz and -DartifactId=whatever on the command-line and the corresponding entry in the POM file, the jar was installed in the local repo under com/whatever.
This led me to experiment with quoting command-line arguments, and the eventual correct result from formatting the command-line like this (after deleting the POM file):
mvn install:install-file "-Dfile=cobra.jar" "-DgroupId=com.cobra" "-DartifactId=cobra" "-Dversion=0.98.4" "-Dpackaging=jar" "-DgeneratePom=true"
Some of the quoting is doubtless redundant, but better safe than sorry, right? I happen to be running Vista on this computer, and would not be surprised if this problem were specific to this OS version...by the way, this was with Maven v3.0.4.
Are you sure that you are executing the install-file goal? I checked your command and it works for me, but when I place a blank install :install-file (maybe you have this typo) the install goal would be used which needs a pom.xml.
Try to use the -X parameter to get more debug information:
-X,--debug Produce execution debug output
My system
Maven
c:\>mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: C:\progs\apache-maven-3.0.3
Java version: 1.6.0_21, vendor: Sun Microsystems Inc.
Java home: c:\Program Files (x86)\Java\jdk1.6.0_21\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
Install Plugin
c:\>mvn -Dplugin=install help:describe
Name: Maven Install Plugin
Description: Copies the project artifacts to the user's local repository.
Group Id: org.apache.maven.plugins
Artifact Id: maven-install-plugin
Version: 2.3.1
Goal Prefix: install
This plugin has 3 goals:
install:help
Description: Display help information on maven-install-plugin.
Call
mvn install:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
install:install
Description: Installs the project's main artifact in the local repository.
install:install-file
Description: Installs a file in the local repository.
For more information, run 'mvn help:describe [...] -Ddetail'
I found a bypass. You need to create a simple pom.xml like this :
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cobra</groupId>
<artifactId>cobra</artifactId>
<version>0.98.4</version>
</project>
It's not perfect but it's worked for me. If you find a better way to do that, I'm interested.
My config :
$mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /usr/local/maven
Java version: 1.6.0_20, vendor: Sun Microsystems Inc.
Java home: /usr/local/jdk1.6.0_20/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-25-generic-pae", arch: "i386", family: "unix"
$mvn -Dplugin=install help:describe
...
Name: Maven Install Plugin
Description: Copies the project artifacts to the user's local repository.
Group Id: org.apache.maven.plugins
Artifact Id: maven-install-plugin
Version: 2.3.1
Goal Prefix: install
...
Try to run it on cmd.exe or execute cmd command before the mvn command.
Using maven version 3.6.3, this worked for me to generate pom file in my chosen directory:
C:<MyChosenDir> mvn archetype:generate "-DgroupId=com.mycompany.app" "-DartifactId=my-app" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DarchetypeVersion=1.4" "-DinteractiveMode=false"
just go under your project directory where you can find your pom.xml file then execute the same command ! it works for me ;)
If you are having trouble with the command line version of Maven, you might want to try the M2E plugin for eclipse. It is far more user friendly for people without very much experience with Maven.
It worked for me when I changed Powershell to Cygwin. Powershell is somehow parsing the command line argument incorrectly.
I had that error when I was using maven in Windows, what worked for me was opening the cmd and not the PowerShell.
Apparently certain errors appear when you don't do it with the cmd.
I hope it works.
If you are getting this error during jenkins pipeline setup , Then the error is we are placing git repository without .git in jenkins git url blank .Generally we put website url of git repo but we need to place clone url of git repo.Insert .git (cloned url) to website url , Simply insert git clone url.