How to deploy own files from maven - maven

I am installing and running sakai project from command prompt
mvn install sakai:deploy
but command prompt show me error that 2 artifact missing that is 2 jar files are missing dwnload it manually
i am dwnload it and save it in local system then how i can install and deploy it

When you build Sakai it will generate that missing jar file and place it into the local maven repo. That said, this version of Sakai is very old and you should be running Sakai 10. We suggest you upgrade to Sakai 10 and maven 3. If you do, this issue will go away.
The process for building Sakai is as follows:
Open a command line shell
Change directory to your Sakai source root directory (should contain many directories including the "master" directory)
Execute mvn clean install to build the Sakai source using maven
Note: The build will take an extra 5-10 minutes to download dependencies the first time
Execute mvn sakai:deploy to deploy Sakai to your tomcat using maven
Partial builds are supported by the maven2/3 build system
You can do a "mvn clean install sakai:deploy" from any subdirectory and build just that code
Once you have downloaded the jars you can run maven off-line with mvn -o clean install sakai:deploy

As i can understand you have to manually add the jar in .m2 repository where it needs to be or
add dependency in pom.xml for it(it will automatically add it in repository).
One more thing you can try, go to project>right click>build path> add external jar (it will add the jar to your project).

Related

How to check maven installed in Drools machine

I have installed Drools in my machine and we have m2 repository in our linux machine. Does that mean maven installed in my machine.
If type mvn -v its saying command not found.
I am new to this maven. Kindly help me out
Drools is a library. It does not "install". You add it as a dependency to a Java project. If you "installed" something, it's not Drools. Perhaps it's jBPM or some other application which uses Drools.
Maven is a toolchain. When you install it, the zip file includes a binary that you need to put on your path. That binary (mvn) allows you to run from the commandline.
The two are not related in any way.
If you get an error when trying to run mvn -v that the command is not recognized, that means that the Maven binary is not on your path. Find where you installed Maven, locate the 'bin' directory in that installation, and add that bin directory to your Path environment variable.
If you did not install Maven, and therefore don't have an install directory, you probably want to go do that. Don't forget to put the bin directory on your path after installing.
(A less common way of using Maven involves packaging a mvn.cmd or mvn.sh script with your project itself so that you don't need to have Maven installed globally. If this is what you're doing instead, you need to run the mvn command from the same directory as that script.)

how to use mvnw command for first project setting

I am new to maven and have some basical questions.
When I see some projects, there is mvnw file included.
What I know is I dont need to install maven on my local if I use mvnw.
My question is:
what will happen when I firstly execute mvnw install?
maven with certain version is automatically installed on my local?
can I use like mvn compile instead of mvnw compile after executing mvnw install?
Thanks in advance.
what will happen when I firstly execute mvnw install? maven with certain version is automatically installed on my local?
The mvnw command will look for maven-wrapper.jar in the .mvn/wrapper directory. It will automatically download this jar file if it is not present there. We can consider this step as installing maven in the local machine just for this project. And the version of maven-wrapper.jar installed depends on the configuration in the mvnw command. On the other hand, if the maven-wrapper.jar is already present in the ./mvn/wrapper directory, the mvnw command simply uses it.
can I use like mvn compile instead of mvnw compile after executing mvnw install?
If you have maven installed in your local machine, you certainly can use mvn compile instead of mvnw compile, as long as the version of maven installed in the local machine is compatible with the project. However this can cause problems if the maven installed in the local machine is an older version and the project requires a newer version, or the the other way around.

Download all transitive dependencies on mvn install

I'm currently starting to get into Maven.
I've been tasked to create a maven environment for a large pre-existing project and I want the build environment to be as portable as possible. My problem is, that on a machine with a fresh maven installation, my project does not seem to download transitive dependencies when in run 'mvn install'.
Currently maven comes up with a build order like this:
ProjA
ProjB
Project A has some dependencies and code that Project B depends on. So I set Project B to only depend on Project A. When running 'mvn install' though, compilation of ProjB fails, because it says it is missing a package that ProjA depends on.
Am I running the wrong command for a fresh setup, or do I have to add a specific line in the POM of Project B to make it work on a fresh machine?
Thanks in advance.

Maven: The following artifacts could not be resolved. Where to place the friend's .m2 folder on my Mac?

My friend and I are working on a project using Maven on Windows.
I want to run the same project on Mac. I do not know where to place the .m2 folder that I copied from Windows on Mac.
I put the .m2 into /Users/.m2. When I run the mvn clean install from the folder with a pom file I get:
Could not resolve dependencies for project ...
First copying the cache is a bad idea...apart from that the cache on Mac is under the appropriate user like /Users/USERNAME/.m2/ ...Just transfer the project (I hope you are working with a version control system like Git/SVN etc.) and just try to build it on the Mac on plain command line mvn clean package. The downloads will be done automatically.

What is the difference between "mvn clean install" & "mvn eclipse:clean eclipse:eclipse" command?

I have a maven project in eclipse. I use mvn clean install for installing dependencies in pom.xml.
I want to know what mvn eclipse:clean eclipse:eclipse command does and also the difference between these two?
mvn eclipse:clean eclipse:eclipse
The second command is completely different from the first one.
First, it deletes previously generated Eclipse files (like .project and .classpath and .settings) and then generates new ones, thus, effectively updating them. It may be useful if you introduced some changes in pom.xml (like new dependencies or plugins) and want Eclipse to be aware of them.
mvn clean install
The first command deletes target directory and then builds all you code and installs artifacts into local repository.

Resources