How to build the simplest multi module Maven project using Windows command line? -


i have multi module project very simple.

directory structure:

   c:\acme-project\parent    c:\acme-project\alpha       c:\acme-project\beta 

logical structure:

     parent     /     \  alpha <- beta 

i cannot build beta because depends on alpha. , meven doesn't want build alpha during beta's build process!

c:\acme-project\beta> mvn package [info] scanning projects... [info]                                                                          [info] ------------------------------------------------------------------------ [info] building beta 1.0-snapshot [info] ------------------------------------------------------------------------ [warning] pom com.company:alpha:jar:1.0-snapshot missing, no dependency information available [info] ------------------------------------------------------------------------ [info] build failure [info] ------------------------------------------------------------------------ [info] total time: 1.263 s [info] finished at: 2017-03-28t15:00:34+03:00 [info] final memory: 16m/220m [info] ------------------------------------------------------------------------ [error] failed execute goal on project beta: not resolve dependencies project com.company:beta:jar:1.0-snapshot: following artifacts not resolved: com.company:alpha:jar:1.0-snapshot: not find artifact com.company:alpha:jar:1.0-snapshot -> [help 1] [error]  [error] see full stack trace of errors, re-run maven -e switch. [error] re-run maven using -x switch enable full debug logging. [error]  [error] more information errors , possible solutions, please read following articles: [error] [help 1] http://cwiki.apache.org/confluence/display/maven/dependencyresolutionexception 

my poms :

c:\acme-project\parent\parent.pom :

<?xml version='1.0' encoding='utf-8'?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">   <modelversion>4.0.0</modelversion>    <groupid>com.company</groupid>   <artifactid>parent</artifactid>   <version>1</version>   <packaging>pom</packaging>    <modules>     <module>../alpha</module>     <module>../beta</module>       </modules> </project> 

c:\acme-project\alpha\alpha.com :

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0"          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"          xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">   <parent>     <artifactid>parent</artifactid>     <groupid>com.company</groupid>     <version>1</version>     <relativepath>../parent/pom.xml</relativepath>   </parent>   <modelversion>4.0.0</modelversion>    <artifactid>alpha</artifactid>   <version>1.0-snapshot</version>  </project> 

c:\acme-project\beta\beta.pom :

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0"          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"          xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">   <modelversion>4.0.0</modelversion>    <parent>     <groupid>com.company</groupid>     <artifactid>parent</artifactid>     <version>1</version>     <relativepath>../parent/pom.xml</relativepath>   </parent>    <artifactid>beta</artifactid>   <version>1.0-snapshot</version>   <packaging>jar</packaging>    <dependencies>     <dependency>       <groupid>com.company</groupid>       <artifactid>alpha</artifactid>       <version>1.0-snapshot</version>     </dependency>   </dependencies> </project> 

i can build acme-project running mvn package in c:...\parent. in case of more complex project parent have 100 sub-modules. , don't want build 98 modules (others beta doesn't depend on) make maven happy.

if want build projects beta depends on, go root aggregator (i.e., project <modules>; parent in case) , ask maven build beta and dependencies in current reactor:

cd parent mvn package --projects com.company:beta --also-make 

fyi, can abbreviated:

mvn package -pl :beta -am 

in minimal example, above command still build (as beta depends on alpha , implicitly on parent), in larger reactors build minimal subset necessary build beta.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -