Multiple maven pom.xml files

烂漫一生 提交于 2019-12-08 20:23:08

问题


I have an Eclipse project with a GWT client and a Restlet API. I normally use Maven for dependency management but I havent used it in an Eclipse project where seperate parts have seperate dependencies. For example - the client would use Google Gin for dependency injection and the server uses Google Guice.

Am I able to split it into two seperate pom.xml files to manage the dependencies of both seperate areas?

Thanks


回答1:


You can create a multi module project. See examples here and here and here.




回答2:


You could create a new pom like this:

<?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.mycompany</groupId>
    <artifactId>your-dependencies</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>

    <dependencies>
        ...
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>mailapi</artifactId>
            <version>1.5.0</version>
        </dependency>
        ...
    </dependencies>
</project>

Then in your original project just add:

<dependencies>
    <dependency>
        <groupId>com.mycompany</groupId>
        <artifactId>your-dependencies</artifactId>
        <version>1.0.0</version>
        <type>pom</type>
    </dependency>
</dependencies>


来源:https://stackoverflow.com/questions/4175380/multiple-maven-pom-xml-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!