Thursday, August 9, 2012

[Solved] File not found when running maven pom.xml in sub-directory

Run a maven project on jenkins.
If the data structure looks like this(pom.xml is under root directory):
my-app
 | - - pom.xml
 | - - src
          | - - main
          |          | - - java
          |                  | - - com
          |                           | - - mycompany
          |                                              | - - app
          |                                                       | - - App.java
          |- - test
                    | - - java
                            | - - com
                                     | - - mycompany
                                                        | - - app
                                                                 | - - AppTest.java

It will work properly, but if my root folder has more than one modules(projects), if will fail and say "no pom.xml"

root-dir
 | - - project1
 |       | - - pom.xml
 |       | - - src
 |- - project2
         | - - pom.xml
         | - - src
For the above structure, each module has its own pom.xml, but there is NO pom.xmll in the root directory, so when you run maven, it will not find any pom.xml in root directory. In order to find out the pom.xml in subdirectory, we need add a pom.xml in root folder:
What you need to do is add modules to your root pom.xml


after you create this pom.xml, paste it into your root directory, data structure will look like:


root-dir
 | - - project1
 |       | - - pom.xml
 |       | - - src

 |- - project2
 |       | - - pom.xml
 |       | - - src
 | - - pom.xml

Hope it helps:)

No comments:

Post a Comment