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
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/
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"] ...
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
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.