Wanna run an application from maven command line, any command?
look into Maven Exec Plugin
mvn exec:java -Dexec.mainClass="com.example.Main" [-Dexec.args="argument1"] ...
Related
I want to download the source codes of json-simple library using maven2 command line interaface. So, I download this .pom file into ~/project/pom.xml
http://json-simple.googlecode.com/svn/trunk/pom.xml
And then, using the relevant SO question's answer: How to install Maven artifact with sources from command line?, I try to download source codes with the following commands,
$ cd ~/project
$ mvn eclipse:eclipse -DdownloadSources=true
$ ls
The output is only the pom.xml. What is wrong?
$ mvn --version
Apache Maven 2.2.1 (rdebian-8)
Use the get goal of the dependency plugin
Full command line (execute somewhere - you do not need a pom)
mvn -DgroupId=com.googlecode.json-simple
-DartifactId=json-simple
-Dversion=1.1.1
-Dclassifier=sources
-DremoteRepositories=http://nexus.dmz1.heuboe.hbintern:8080/nexus/content/repositories/central/
org.apache.maven.plugins:maven-dependency-plugin:2.8:get
or as a oneliner
mvn -DgroupId=com.googlecode.json-simple -DartifactId=json-simple -Dversion=1.1.1 -Dclassifier=sources -DremoteRepositories=http://nexus.dmz1.heuboe.hbintern:8080/nexus/content/repositories/central/ org.apache.maven.plugins:maven-dependency-plugin:2.8:get
Normally I am using Maven 3 but I tested this also with Maven 2.2.1 on Windows and it works.
You can also consider to use the m2e Maven Integration in eclipse (check the eclipse Marketplace to install this if not already installed) instead of the maven-eclipse-plugin (eclipse:eclipse). You than have an eclipse preferences option to download the sources.
I want to know what is the build command for maven .Including test cases skip. please help to solve this problem.
mvn install -DskipTests try this command. It includes the test skip part too. This will fix your problem.
mvn install this is the code without test skips
Use below
mvn clean package install -Dmaven.test.skip=true
Building a Project
mvn clean install
mvn clean package
Skip Unit Test
mvn install -Dmaven.test.skip=true
mvn package -Dmaven.test.skip=true
Source: http://www.mkyong.com/maven/how-to-skip-maven-unit-test/
I have tried to build the Hadoop MapReduce eclipse-plugin from source, but get the following error.
SRC_BASE_DIR/hadoop-common/hadoop-mapreduce-project/build/ivy/lib/Hadoop/common
does not exist.
I cloned the Hadoop source from the Apache GIT repo and managed to build the actual Hadoop binaries using the following commands
cd SRC_BASE_DIR/hadoop-common
mvn clean install
This was successful so next I changed directory
cd SRC_BASE_DIR/hadoop-common/hadoop-mapreduce-project/src/contrib/eclipse-plugin
I appended eclipse.home property to the build.properties file...
echo "eclipse.home=/opt/eclipse" >> build.properties
then tried to build the plugin...
ant jar
But I still get the error outlined above.
What am I missing?
OK I was missing a step.
In the folder
SRC_BASE_DIR/hadoop-common/hadoop-mapreduce-project
I ran the following command
mvn -DskipTests install
which was successful. Then in folder
SRC_BASE_DIR/hadoop-common/hadoop-mapreduce-project/src/contrib/eclipse-plugin
I ran the command
ant jar
and this time it was succesful and created the JAR file hadoop-1.0.2-eclipse-plugin.jar
Now, I just hope that that the plugin works!
lets say we have a ParentPom.xml and there are sub child modules under it; subModule-A and subModule-B. I want to use subModule-A.jar in an another project. If i run "mvn install" command only in subModule-A directory i can install it into my M2 repository but after i define dependency to it from my other project it says something "no parent found for subModule-A". It is OK if i run install command for ParentPom.xml.
Any idea about this problem?
Thx...
You need to install / deploy all modules that are referenced by submodule-A, including the parent.
You can do it like this:
mvn deploy -pl submodule-a -am
Which translates to
deploy module submodule (-pl submodule-a)
and all of it's dependencies in the current reactor project (-am)
Call mvn -help to see all possible command line options
Is there a goal one can execute that will just echo the version of a pom? I can think of a way to make it work using the maven-ant-plugin, but that requires me to have ant-plugin configuration in the pom and I would like a method that would work with any pom.
mvn help:evaluate -Dexpression=project.version
If you want just the version echoed, and not the rest of the Maven "noise", you would use
mvn help:evaluate -Dexpression=project.version -q -DforceStdout