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.
Related
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!
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"] ...
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
I'm new to Maven so I may be missing something obvious, but
I've got a maven project and when I try to "mvn package" this project it fails with
ERROR BUILD ERROR INFO
------------------------------------------------------------------------ [INFO] Failed to resolve artifact.
Missing:
---------- 1) org.apache.maven.wagon:wagon-ftp:jar:1.0-rc1-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.apache.maven.wagon -DartifactId=wagon-ftp -Dversion=1.0-rc1-SNAPSHOT -Dpackaging=ja r -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.apache.maven.wagon -DartifactId=wagon-ftp -Dversion=1.0-rc1-SNAPSHOT -Dpackaging=jar
-Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) com.cgs:domain:jar:1.0-SNAPSHOT
2) org.apache.maven.wagon:wagon-ftp:jar:1.0-rc1-SNAPSHOT
----------
1 required artifact is missing.
for artifact: com.cgs:domain:jar:1.0-SNAPSHOT
from the specified remote repositories: ibiblio.org (http://mirrors.ibiblio.org/pub/mirrors/maven2)
The first thing I don't understand is the version it requires 1.0-rc1-SNAPSHOT. The projects' site says the current version is 1.0-beta-5. And I suppose beta goes before RC.
Anyway, I've tried to download the latest wagon-ftp JAR (1.0 beta 6 jar) and deploy it according to the instructions in the error message.
But guess what, this gave me the same error.
I've just found the solution as I was typing the end of this question.
The problem was that I was running "mvn install:install-file" from the same directory the failing project POM was in. It installed fine when I run it from another directory without a pom.xml.