What is “pom” packaging in maven?

前端 未结 10 1743
长发绾君心
长发绾君心 2020-11-30 17:24

I was given a maven project to compile and get deployed on a tomcat server. I have never used maven before today, but I have been googling quite a bit. It seems like the top

相关标签:
10条回答
  • 2020-11-30 18:21

    https://maven.apache.org/pom.html

    The packaging type required to be pom for parent and aggregation (multi-module) projects. These types define the goals bound to a set of lifecycle stages. For example, if packaging is jar, then the package phase will execute the jar:jar goal. If the packaging is pom, the goal executed will be site:attach-descriptor

    0 讨论(0)
  • 2020-11-30 18:22

    Packaging an artifact as POM means that it has a very simple lifecycle

    package -> install -> deploy
    

    http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

    This is useful if you are deploying a pom.xml file or a project that doesn't fit with the other packaging types.

    We use pom packaging for many of our projects and bind extra phases and goals as appropriate.

    For example some of our applications use:

    prepare-package -> test -> package -> install -> deploy
    

    When you mvn install the application it should add it to your locally .m2 repository. To publish elsewhere you will need to set up correct distribution management information. You may also need to use the maven builder helper plugin, if artifacts aren't automatically attached to by Maven.

    0 讨论(0)
  • 2020-11-30 18:24

    pom is basically a container of submodules, each submodule is represented by a subdirectory in the same directory as pom.xml with pom packaging.

    Somewhere, nested within the project structure you will find artifacts (modules) with war packaging. Maven generally builds everything into /target subdirectories of each module. So after mvn install look into target subdirectory in a module with war packaging.

    Of course:

    $ find . -iname "*.war"
    

    works equally well ;-).

    0 讨论(0)
  • 2020-11-30 18:26

    Real life use case

    At a Java-heavy company we had a python project that needed to go into a Nexus artifact repository. Python doesn't really have artifacts, so simply just wanted to .tar or .zip the python files and push. The repo already had maven integration, so we used <packaging>pom</packaging> designator with the maven assembly plugin to package the python project as a .zip and upload it.

    The steps are outlined in this SO post

    0 讨论(0)
提交回复
热议问题