What is “pom” packaging in maven?

前端 未结 10 1742
长发绾君心
长发绾君心 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:05

    I suggest to see the classic example at: http://maven.apache.org/guides/getting-started/index.html#How_do_I_build_more_than_one_project_at_once

    Here my-webapp is web project, which depends on the code at my-app project. So to bundle two projects in one, we have top level pom.xml which mentions which are the projects (modules as per maven terminology) to be bundled finally. Such top level pom.xml can use pom packaging.

    my-webapp can have war packaging and can have dependency on my-app. my-app can have jar packaging.

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

    pom packaging is simply a specification that states the primary artifact is not a war or jar, but the pom.xml itself.

    Often it is used in conjunction with "modules" which are typically contained in sub-directories of the project in question; however, it may also be used in certain scenarios where no primary binary was meant to be built, all the other important artifacts have been declared as secondary artifacts

    Think of a "documentation" project, the primary artifact might be a PDF, but it's already built, and the work to declare it as a secondary artifact might be desired over the configuration to tell maven how to build a PDF that doesn't need compiled.

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

    “pom” packaging is nothing but the container, which contains other packages/modules like jar, war, and ear.

    if you perform any operation on outer package/container like mvn clean compile install. then inner packages/modules also get clean compile install.

    no need to perform a separate operation for each package/module.

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

    To simply answer your question when you do a mvn:install, maven will create a packaged artifact based on (packaging attribute in pom.xml), After you run your maven install you can find the file with .package extension

    • In target directory of the project workspace
    • Also where your maven 2 local repository is search for (.m2/respository) on your box, Your artifact is listed in .m2 repository under (groupId/artifactId/artifactId-version.packaging) directory
    • If you look under the directory you will find packaged extension file and also pom extension (pom extension is basically the pom.xml used to generate this package)
    • If your maven project is multi-module each module will two files as described above except for the top level project that will only have a pom
    0 讨论(0)
  • 2020-11-30 18:17

    Packaging of pom is used in projects that aggregate other projects, and in projects whose only useful output is an attached artifact from some plugin. In your case, I'd guess that your top-level pom includes <modules>...</modules> to aggregate other directories, and the actual output is the result of one of the other (probably sub-) directories. It will, if coded sensibly for this purpose, have a packaging of war.

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

    POM(Project Object Model) is nothing but the automation script for building the project,we can write the automation script in XML, the building script files are named diffrenetly in different Automation tools

    like we call build.xml in ANT,pom.xml in MAVEN

    MAVEN can packages jars,wars, ears and POM which new thing to all of us

    if you want check WHAT IS POM.XML

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