Search code examples
mavencommand-linedependenciespropertiescommand-line-interface

How to resolve maven dependency explicitly from command line arguments?


I have a project A which depends on artifact B. I made some hack on B, and want to see it in A. So I don't want A to use the version in my local repository, instead, I want A to use my hacked version of B.

I'm looking for a solution that can specify my-hacked-B.jar as dependency of A, like this:

cd A && mvn package -Ddependency.org.groupB.B.jar.path=path/to/my-hacked-B.jar

Is it possible, or I have to install the modified B in my local repository?


Solution

  • There is no way to resolve dependency from command line, but there is a way to let maven resolve dependency externally.

    I created a temporal wrapper pom.xml which aggregates the two projects. It works, without install anything into local repository.

    The only problem is that I am unable to use absolute path in <module/>.

    See http://maven.apache.org/pom.html#Aggregation