简体   繁体   English

DistributionManagement和Repositories中的不同存储库

[英]Different repository in DistributionManagement and Repositories

In <DistributionManagement> ... </DistributionManagement> and <Repositories> ... <Repositories> sections, there can be a <DistributionManagement> ... </DistributionManagement> and <Repositories> ... <Repositories>部分中,可以有一个

<Repository> ... </Repository>

definition. 定义。 What's the difference between the two definition? 这两个定义有什么区别? This is one example: 这是一个例子:

<distributionManagement>

                <downloadUrl>https://github.com/marytts/marytts/releases</downloadUrl>
                <repository>
                        <id>bintray</id>
                        <url>https://api.bintray.com/maven/marytts/marytts/marytts</url>
                </repository>
                <snapshotRepository>
                        <id>bintray</id>
                        <url>http://oss.jfrog.org/artifactory/oss-snapshot-local</url>
                </snapshotRepository>
        </distributionManagement>

And

<repositories>
        <repository>
                <id>marytts-dependencies</id>
                <name>marytts-dependencies</name>
                <releases>
                        <enabled>true</enabled>
                </releases>
                <snapshots>
                        <enabled>false</enabled>
                </snapshots>
                <url>file://${project.local.repository.path}</url>
        </repository>
        <repository>
                <id>central</id>
                <name>jcenter</name>
                <releases>
                        <enabled>true</enabled>
                </releases>
                <snapshots>
                        <enabled>false</enabled>
                </snapshots>
                <url>http://jcenter.bintray.com</url>
        </repository>
</repositories>

Distribution Management 分销管理

Distribution management acts precisely as it sounds: it manages the distribution of the artifact and supporting files generated throughout the build process. 分发管理就像听起来一样:它管理工件的分发和在整个构建过程中生成的支持文件。 Starting with the last elements first: 首先从最后一个元素开始:

Repository 知识库

Where as the repositories element specifies in the POM the location and manner in which Maven may download remote artifacts for use by the current project, distributionManagement specifies where (and how) this project will get to a remote repository when it is deployed. 当存储库元素在POM中指定Maven可以下载远程工件以供当前项目使用的位置和方式时,distributionManagement指定在部署时该项目将在何处(以及如何)到达远程存储库。 The repository elements will be used for snapshot distribution if the snapshotRepository is not defined. 如果未定义snapshotRepository,则存储库元素将用于快照分发。

Deploy using the repository layout 使用存储库布局进行部署

To deploy your file using the maven layout you should define the distribution management location : 要使用maven布局部署文件,您应该定义分发管理位置:

<project>
    ...
    <distributionManagement>
        <repository>
              <id>myrepository</id>
              <url>file:D:/repository/</url>
        </repository>
      </distributionManagement>
</project>       

Then you just need to execute the following command to get you artifact copied in your file system location 然后,您只需执行以下命令即可在文件系统位置复制工件

Maven command to deploy a file in the local file system Maven命令在本地文件系统中部署文件

mvn deploy

Site Distribution 网站分发

More than distribution to the repositories, distributionManagement is responsible for defining how to deploy the project's site and documentation. 分发管理不仅仅是分发到存储库,还负责定义如何部署项目的站点和文档。

In pom.xml , configure where to deploy your site within distributionManagement tag. pom.xml ,配置在distributionManagement标记内部署站点的位置。

<distributionManagement>
    <site>
      <id>mkyongserver</id>
      <url>dav:http://127.0.0.1/sites/</url>
    </site>
</distributionManagement>

Relocation 搬迁

Projects are not static; 项目不是静态的; they are living things (or dying things, as the case may be). 它们是生物(或死亡的东西,视情况而定)。 A common thing that happens as projects grow, is that they are forced to move to more suitable quarters. 随着项目的发展,一个常见的事情就是他们被迫搬到更合适的地方。 For example, when your next wildly successful open source project moves under the Apache umbrella, it would be good to give your users as heads-up that the project is being renamed to org.apache:my-project:1.0. 例如,当你的下一个非常成功的开源项目在Apache保护伞下移动时,最好让你的用户单独将项目重命名为org.apache:my-project:1.0。 Besides specifying the new address, it is also good form to provide a message explaining why. 除了指定新地址外,提供解释原因的消息也是一种很好的形式。

Repositories

Repositories are collections of artifacts which adhere to the Maven repository directory layout. 存储库是符合Maven存储库目录布局的工件集合。 In order to be a Maven repository artifact, a POM file must live within the structure $BASE_REPO/groupId/artifactId/version/artifactId-version.pom. 为了成为Maven存储库工件,POM文件必须位于结构$ BASE_REPO / groupId / artifactId / version / artifactId-version.pom中。 $BASE_REPO can be local (file structure) or remote (base URL); $ BASE_REPO可以是本地(文件结构)或远程(基本URL); the remaining layout will be the same. 剩下的布局将是相同的。 Repositories exist as a place to collect and store artifacts. 存储库作为收集和存储工件的地方而存在。 Whenever a project has a dependency upon an artifact, Maven will first attempt to use a local copy of the specified artifact. 每当项目依赖于工件时,Maven将首先尝试使用指定工件的本地副本。 If that artifact does not exist in the local repository, it will then attempt to download from a remote repository. 如果该工件在本地存储库中不存在,则它将尝试从远程存储库下载。 The repository elements within a POM specify those alternate repositories to search. POM中的存储库元素指定要搜索的备用存储库。

The repository is one of the most powerful features of the Maven community. 存储库是Maven社区最强大的功能之一。 The default central Maven repository lives on http://repo.maven.apache.org/maven2/ . 默认的中央Maven存储库位于http://repo.maven.apache.org/maven2/上 Another source for artifacts not yet in iBiblio is the Codehaus snapshots repo. iBiblio中尚未出现的工件的另一个来源是Codehaus快照存储库。

Be remember you can add only one <repository> and one <snapshotRepository> child inside <distributionManagement> 请记住,您只能在<distributionManagement>添加一个<repository>和一个<snapshotRepository>子项

How to declare proxy 如何申报代理

Just go to Maven-> conf-> setting.xml file and add proxy 只需转到Maven-> conf-> setting.xml文件并添加代理

<proxies>
    <proxy>
      <id>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>global.proxy.mycompany.com</host>
      <port>8000</port>
      <username></username>
      <password></password>
      <nonProxyHosts>localhost,127.0.0.1</nonProxyHosts>
    </proxy>
 </proxies>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为插件和库配置不同的distributionManagement存储库? - How to configure distinct distributionManagement repositories to plugins and libs? 部署失败:在 distributionManagement 元素或 -DaltDeploymentRepository 中的 POM 中未指定存储库元素 - Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository Spring Data JPA:从相同的存储库接口定义实例化多个存储库,每个存储库指向不同的数据库 - Spring Data JPA: Instantiate multiple repositories from same repository interface definitions, each pointing to a different database 未在POM内部distributionManagement元素或-DaltDep loymentRepository = id :: layout :: url参数中指定存储库元素 - repository element was not specified in the POM inside distributionManagement element or in -DaltDep loymentRepository=id::layout::url parameter 在Java中使用存储库模式时,可以将单个Manager / Controller用于3个不同的存储库吗? - When using the Repository Pattern in Java, is it ok to use a single Manager/Controller for 3 different Repositories? 存储库模式:存储库可以使用其他存储库吗? - Repository pattern: Can a repository use other repositories? 如何在IntelliJ IDEA 13中将存储库添加到“索引Maven存储库”? - How to add repository/repositories to “Indexed Maven Repositories” in IntelliJ IDEA 13? jpa:repositories / @EnableJpaRepositories vs @Repository-春天 - jpa:repositories / @EnableJpaRepositories vs @Repository - spring Maven 多模块项目分布管理 - Maven distributionManagement for multimodule project 在 Maven POM 中禁用 distributionManagement - Disable distributionManagement in Maven POM
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM