when will .m2/repository folder gets created in linux for maven 2 - maven-2

I've unzipped maven 2 package, set the M2_Home, M2, PATH variables and tested maven with mvn --version ...I dont see .m2/repository folder created.
I've edited settings.xml in conf folder adding some profiles for nexus. when I run a job in jenkins. It fails and it doesn't download any dependencies from nexus and still no repository folder is created in .m2 directory
let me know whats going wrong here

Check here
/var/lib/jenkins/.m2/

In most cases you just need to go to your project main directory (the one with master pom.xml) and run the following command:
mvn clean install
It will by default download any necessary artifacts into your local maven repository creating the folders if does not exist yet.

Related

maven repository and dependencies download

I've used standard maven command mvn clean install and according to logs (in the same console window) dependencies were loaded and artifacts were installed to my dedicated directory for maven repository P:\.m2\repository. Maven build process succeeded.
I'm using maven 2.2.1
Here is the problem. Repository directory is empty. What I'm missing?
Thanks.
Some reasons:
Someone deleted the folder (or it's content)
Maven installed the files in a different place
I suggest to run mvn again with the option -X. Running mvn clean -X should be enough to see the paths which it uses to locate dependencies (install will download many more files but we need to see only one).
Note: P:\ sounds like a network drive. Even if this is your home folder (i.e. not shared with other people), this isn't a very good idea since it will cause a lot of network traffic and make your builds slow and brittle (in case of network problems).
Did you change the repository location in your m2_install_dir/conf/settings.xml?
If not, try to locate your files in something like:
C:\Documents & Settings\your_username.m2
or C:\Users\your_username.m2
I think you are using something like gitbash and its stripping off the backslashes in your repo value. run maven install with -X. check if you have a directory called P:\.m2repository

Intellij IDEA: Server Configuration cannot be run cause file does not yet exist. Use maven goal result as artifact?

until now I deployed to a Glassfish server with the default IntelliJ artifact "Web Application: Archive". Now my built process got a bit more complicated with maven modifying several files.
In the glassfish configuration under Deployment, I substituted the Artifact to deploy with the direct war file and put the maven goal in "Before Launch: Another Configuration"
However, if mvn clean was run the war does not exist and I cannot run the configuration (because the external file doesn't exist).
Can I avoid having to run mvn package once manually? E.g. by making the output of a maven goal an Artifact?
Thanks!

Maven Unique Version in Jar File Name

I am using Maven with Nexus for building my project with hudson ci. Everytime when I am deploying a new snapshot artifact he is doing this with a unique version in nexus. Which is OK for me as Nexus is giving me always the latest version.
Now I looked into the war file of my project which is using this snapshot dependency and its having the following jar file in its lib directory which is absolutely not fine:
framework-client-1.1-20120302.141044-3.jar
The problem is that I am using EBean as an ORM and I need to specify the jar name in the ebean.properties to let him know where to find its models.
How can I prevent such behaviour so that the latest snapshot dep is always call framework-client-1.1-SNAPSHOT.jar?
Thank you!
Just rename the jar in the war file to whatever name you like. Details are here
Renaming Maven dependency in WAR's WEB-INF/lib folder

Existing project which is having pom.xml file in it

I have been given an existing project which is consisting of pom.xml file in it .
Can we manually run the pom.xml file , to create a war file and deploy it into Tomcat WEB Apps
Please tell me how to do this .
Thank you very much for reading .
(And also in our existing Application , we are having more than one POM.xml files in it )
Make sure you have (Maven)[http://maven.apache.org/] installed and set your environment variables for JAVA_HOME and M2_HOME or M3_HOME based on the version of Maven.
From the command line, navigate to the location that has the pom.xml file.
Type: mvn clean install.
This will create a target folder that has the .war in it.
Take the .war file and install in Tomcat.
Hope this helps.
Thanks...

Forcing Maven2 to download source jars to local repository

I have my company dependencies (including non-FOSS third party stuff) in a Nexus repository, including source jars (downloaded with mvn dependency:resolve), where available.
I would like to have the source jars (and javadoc jars) download to my local repository (~/.m2/repository) so that I can go "offline".
I tried various combinations of mvn dependency:resolve dependency:go-offline -Dclassifier=sources, but it does not seem to copy them to my local repository.
Thanks.
Did you try:
mvn dependency:sources