简体   繁体   中英

Multiple maven pom.xml files

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

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM