您将哪些存储库放入通用 pom 文件中?

发布于 2024-10-17 08:32:37 字数 2901 浏览 2 评论 0原文

我正在为我的项目构建一个通用的父 pom 文件。

在该文件中,我希望有一个最常见的 Maven 存储库的列表,以便在子项目(Jboss、Spring 等)中提供大多数依赖项。

这是当前的 pom:

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.courtine</groupId>
    <artifactId>parent</artifactId>
    <packaging>pom</packaging>
    <name>Parent</name>
    <version>1.0</version>
    <description>Common repositories</description>
    <repositories>
        <repository>
            <id>javanet</id>
            <name>Repository for Maven2</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>google</id>
            <name>Google repository for Maven2</name>
            <url>https://oss.sonatype.org/content/repositories/google-releases/</url>
        </repository>
        <repository>
            <id>jboss</id>
            <name>JBoss repository for Maven2</name>
            <url>http://repository.jboss.org/maven2/</url>
        </repository>
        <repository>
            <id>com.springsource.repository.bundles.release</id>
            <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
            <url>http://repository.springsource.com/maven/bundles/release</url>
        </repository>
        <repository>
            <id>com.springsource.repository.bundles.external</id>
            <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
            <url>http://repository.springsource.com/maven/bundles/external</url>
        </repository>
        <repository>
            <id>com.springsource.repository.libraries.release</id>
            <name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name>
            <url>http://repository.springsource.com/maven/libraries/release</url>
        </repository>
        <repository>
            <id>com.springsource.repository.libraries.external</id>
            <name>SpringSource Enterprise Bundle Repository - External Library Releases</name>
            <url>http://repository.springsource.com/maven/libraries/external</url>
        </repository>
    </repositories>
</project>
  1. 这样一个列出常见存储库的通用文件是个好主意吗?
  2. 您知道其他常见的公共 Maven 存储库可以放入这样的通用 pom 文件吗?

I am building a generic parent pom file for my projects.

In that file, I would like to have a list of most common Maven repositories, in order to have most dependencies available in the sub-projects (Jboss, Spring, etc.).

Here is this current pom:

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.courtine</groupId>
    <artifactId>parent</artifactId>
    <packaging>pom</packaging>
    <name>Parent</name>
    <version>1.0</version>
    <description>Common repositories</description>
    <repositories>
        <repository>
            <id>javanet</id>
            <name>Repository for Maven2</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>google</id>
            <name>Google repository for Maven2</name>
            <url>https://oss.sonatype.org/content/repositories/google-releases/</url>
        </repository>
        <repository>
            <id>jboss</id>
            <name>JBoss repository for Maven2</name>
            <url>http://repository.jboss.org/maven2/</url>
        </repository>
        <repository>
            <id>com.springsource.repository.bundles.release</id>
            <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
            <url>http://repository.springsource.com/maven/bundles/release</url>
        </repository>
        <repository>
            <id>com.springsource.repository.bundles.external</id>
            <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
            <url>http://repository.springsource.com/maven/bundles/external</url>
        </repository>
        <repository>
            <id>com.springsource.repository.libraries.release</id>
            <name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name>
            <url>http://repository.springsource.com/maven/libraries/release</url>
        </repository>
        <repository>
            <id>com.springsource.repository.libraries.external</id>
            <name>SpringSource Enterprise Bundle Repository - External Library Releases</name>
            <url>http://repository.springsource.com/maven/libraries/external</url>
        </repository>
    </repositories>
</project>
  1. Is such a generic file listing common repositories a good idea?
  2. Do you know other common public Maven repositories to put in such a generic pom file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最好是你 2024-10-24 08:32:37

将存储库放入 pom 中并不是一个好主意。最好使用存储库管理器,例如 NexusArtifactoryArchiva
在这种 pom 中,您应该放置默认插件及其适当的修订版 (pluginManagement) 或应使用的依赖项 (dependencyManagement) 之类的内容。

查看 这个。并看看 这里如何设置它。

It is not a good idea to put repositories into a pom. Better use a Repository Manager like Nexus, Artifactory or Archiva.
In such kind of pom you should put things like default plugins with their appropriate revisions (pluginManagement) or dependencies which should be used (dependencyManagement).

Take a look for explanation into this. and take a look here how to setup this.

辞旧 2024-10-24 08:32:37

我有另一种选择来做你想做的事。您可以在 settings.xml 中使用一个配置文件,它会为您引用所有存储库(就像 nexus/archiva 所做的那样)。
我在我的网站上发布了一些关于他的内容< /a>.

只需将其添加到您的 settings.xml 中即可:

<profile>
    <id>my-repository</id>
    <activation>
    <!-- here we did not activat this profile by default -->
            <activeByDefault>false</activeByDefault>
    </activation>
    <repositories>
    <!-- list of standard repository -->
    <repository>
        <id>javanet</id>
        <name>Repository for Maven2</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>google</id>
        <name>Google repository for Maven2</name>
        <url>https://oss.sonatype.org/content/repositories/google-releases/</url>
    </repository>
    <repository>
        <id>jboss</id>
        <name>JBoss repository for Maven2</name>
        <url>http://repository.jboss.org/maven2/</url>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.release</id>
        <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/release</url>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/external</url>
    </repository>
    <repository>
        <id>com.springsource.repository.libraries.release</id>
        <name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name>
        <url>http://repository.springsource.com/maven/libraries/release</url>
    </repository>
    <repository>
        <id>com.springsource.repository.libraries.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Library Releases</name>
        <url>http://repository.springsource.com/maven/libraries/external</url>
    </repository>
     <repository>
        <id>intelligents-ia</id>
        <name>Intelligents-ia Repository</name>
        <url>http://intelligents-ia.com/maven2</url>
     </repository>
    </repositories>
    </profile>

您可以通过在命令行上添加 -Pmy-repository 来构建您的项目:

mvn -Pmy-repository clean install

或者通过设置 true 来默认激活此配置文件:

<activation>
       <activeByDefault>true</activeByDefault>
</activation>

I have another option for doing what you want to do. You could using a profile in your settings.xml which reference all your repository for you (as an nexus/archiva will do).
I've posted something about his on my site.

Simply add this in your settings.xml:

<profile>
    <id>my-repository</id>
    <activation>
    <!-- here we did not activat this profile by default -->
            <activeByDefault>false</activeByDefault>
    </activation>
    <repositories>
    <!-- list of standard repository -->
    <repository>
        <id>javanet</id>
        <name>Repository for Maven2</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>google</id>
        <name>Google repository for Maven2</name>
        <url>https://oss.sonatype.org/content/repositories/google-releases/</url>
    </repository>
    <repository>
        <id>jboss</id>
        <name>JBoss repository for Maven2</name>
        <url>http://repository.jboss.org/maven2/</url>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.release</id>
        <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/release</url>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/external</url>
    </repository>
    <repository>
        <id>com.springsource.repository.libraries.release</id>
        <name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name>
        <url>http://repository.springsource.com/maven/libraries/release</url>
    </repository>
    <repository>
        <id>com.springsource.repository.libraries.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Library Releases</name>
        <url>http://repository.springsource.com/maven/libraries/external</url>
    </repository>
     <repository>
        <id>intelligents-ia</id>
        <name>Intelligents-ia Repository</name>
        <url>http://intelligents-ia.com/maven2</url>
     </repository>
    </repositories>
    </profile>

And you could build your project by adding -Pmy-repository on the command line:

mvn -Pmy-repository clean install

Or activate this profile by default by setting true on :

<activation>
       <activeByDefault>true</activeByDefault>
</activation>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文