与Maven建立

时间:2015-11-03 21:45:14

标签: maven

您好我一直在尝试创建一个适当的Maven构建。我创建了我的Pom.xml文件:

<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>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>XO Artifactory</name>
  <url>artifactory:8081/artifactory/webapp/home.html?0</url>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.2</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

</project>

我正在尝试将构建发布到artifactory,我也试图让构建依赖项成为神器。对于要发布到artifactory的构建,我将在settings.xml中设置正确的内容吗?

将Settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
      <id>artifactory:8081/artifactory/webapp/home.html?0</id>
      <username>mhopper</username>
      <password>*******</password>
    </server>
  </servers>

</settings>

1 个答案:

答案 0 :(得分:1)

您需要两个步骤:

  1. 将适当的服务器设置添加到本地〜/ .m2 / settings.xml,其中包含服务器的ID和访问它的凭据:

    <servers>
      <server>
        <id>deployment</id>
        <username>deployment</username>
        <password>deployment123</password>
      </server>
    </servers>
    
  2. 在您的项目pom.xml中反馈id,您可以在其中为此定义实际的URL:

    <distributionManagement>
      <repository>
        <id>deployment</id>
        <name>Internal Releases</name>
        <url>artifactory:8081/artifactory/releases</url>
      </repository>
      <snapshotRepository>
        <id>deployment</id>
        <name>Internal Snapshots</name>
        <url>artifactory:8081/artifactory/snapshots</url>
      </snapshotRepository>
    </distributionManagement>