如何使用p2-maven-plugin高效管理第三方依赖?

How to efficiently manage third-party dependencies with p2-maven-plugin?

为了管理 Eclipse RCP 应用程序(使用 Tycho 构建)中的第三方依赖项,我使用 p2-maven-plugin 和 Jetty 将 maven 中央工件转换为包,并使它们作为 P2 存储库在我的目标定义文件。我的设置和工作流程如下:

所以我有 3 个问题:

总而言之,您如何管理团队中的第三方依赖项?

  • 问题是,当您构建 p2 站点时,还会生成 "context.xml" 和 "artifact.xml" 包含捆绑信息的元数据。 p2 解析器使用这些元数据来解析捆绑包。所以我认为如果不重建站点,将很难更新您的 p2 存储库。

    我的建议:自从你在团队中工作以来,最明确的方法是为所有第三方依赖项(你可以使用 category.xml).

    部署重新创建的 p2 没什么大不了的,您可以在创建站点的同一个 pom 中使用 wagon-maven-plugin 并将其绑定到部署阶段,因此使用 mvn clean deploy 您可以创建存储库并已部署

示例:

<build>
<plugins>
    <plugin>
        <groupId>org.reficio</groupId>
        <artifactId>p2-maven-plugin</artifactId>
        <version>1.2.0-SNAPSHOT</version>
        <executions>
            <execution>
                <id>default-cli</id>
                <configuration>
                    <artifacts>
                        <!-- specify your depencies here -->
                        <!-- groupId:artifactId:version -->
                        <artifact><id>commons-io:commons-io:2.1</id></artifact>
                        <artifact><id>commons-lang:commons-lang:2.4</id></artifact>
                        <artifact><id>commons-lang:commons-lang:2.5</id></artifact>
                        <artifact><id>commons-lang:commons-lang:2.6</id></artifact>
                        <artifact><id>org.apache.commons:commons-lang3:3.1</id></artifact>
                    </artifacts>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>wagon-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
            <execution>
                <id>upload-repo</id>
                <phase>deploy</phase>
                <goals>
                    <goal>upload</goal>
                </goals>
                <configuration>
                    <fromDir>${project.build.directory}/repository/</fromDir>
                    <includes>*/**</includes>
                    <serverId>my-p2-repository</serverId>
                    <url>dav:http://mycompany.com/../content/repositories</url>
                    <toDir>thirdparty-p2-repository</toDir>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>
<extensions>
    <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-webdav-jackrabbit</artifactId>
        <version>1.0-beta-7</version>
    </extension>
</extensions>

<distributionManagement>
        <repository>
            <id>my-p2-repository</id>
            <url>dav:http://mycompany.com/../content/repositories</url>
        </repository>
</distributionManagement>

注意:pom 的 distributionManagement 部分中 URL 的 ID 需要与 settings.xml 文件中服务器部分的 ID 相匹配。

在settings.xml中添加服务器:

<server>
 <id>my-p2-repository</id>
 <username>...</username>
 <password>...</password>
</server>

希望这对您有所帮助。