How to build project from maven pom file

后端 未结 4 1940
离开以前
离开以前 2021-02-01 04:17

I have a maven pom file for an open source project. This pom file has all the info like what other jars it depends on etc. I installed maven. Created a dir samprj and copied the

相关标签:
4条回答
  • 2021-02-01 05:03

    Try out their getting started guide. It has a lot of good examples:

    http://maven.apache.org/guides/getting-started/

    0 讨论(0)
  • 2021-02-01 05:06

    I have a maven pom file for an open source project. This pom file has all the info like what other jars it depends on etc. I installed maven. Created a dir samprj and copied the pom file into that dir ...

    It sounds like you only have the project's POM file. This is not sufficient. You need to checkout the complete source tree for the project. Having done that, change directory to the directory containing the POM file and run mvn install.

    Also, don't copy the POM to a different directory. Maven expects to find all of the source files relative to the POM file location.

    FOLLOW UP

    Thanks for advice. I was not able to use the command mvn install as it gave errors.

    Probably because you hadn't checked out the source.

    I don't know how to check the source tree of the project ...

    Use a subversion client (the svn command for example), or one of the Eclipse subversion plugins.

    If this was a properly documented project, there would be clear instructions on what version control and build tools you needed, how to checkout the source code and how to build it.

    ... as I thought POM itself should have this information to automatically checkout if the source is not check out.

    It doesn't necessarily, though in this particular case it does.

    Anyway I was able use Eclipse to build the project without errors.

    (Other readers can read @icyrock.com's answer for links to the m2eclipse plugin and documentation.)

    The only problem is the dependent jars were downloaded but hidden deep paths in .m2 repository folder on my linux box.

    But I would like these dependent jars to be relative to dir where POM file is.

    Sorry, but that is not the way Maven works.

    The ~/.m2/repository directory is a fundamental part of Maven. It is not a problem. It is a feature. (Don't fight it!)

    0 讨论(0)
  • 2021-02-01 05:16

    mvn install should get you going

    0 讨论(0)
  • 2021-02-01 05:21

    If you want to open this within Eclipse, you need to install m2eclipse:

    • http://www.eclipse.org/m2e/

    and then import the project as a Maven project as described here:

    • http://books.sonatype.com/m2eclipse-book/reference/creating-sect-importing-projects.html
    0 讨论(0)
提交回复
热议问题