如何通过Maven

时间:2017-09-13 22:01:05

标签: xml maven nexus

我有一个zip文件,我想将其部署到Nexus存储库。所以我创建了一个pom.xml文件和一个settings.xml文件来执行此操作。我能够成功上传到nexus,但似乎它被部署为jar文件

当我输入<packaging>zip</packaging>元素时,maven无法识别它。如何实现将zip文件部署到nexus的目标?任何帮助将不胜感激。

目录内容: 1. content.zip 2. pom文件 3.设置文件

的pom.xml:

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company.ct.ty16.archive</groupId>
    <artifactId>contentzip</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Deploy-zip-file</name>
    <description>Deploy zipped content file on Jenkins to Nexus</description>
    ...
    ...
    ...
    </project>

注意:我没有使用maven来构建content.zip文件,只需上传它

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

在settings.xml中定义服务器

<servers>
  ...
  <server>
    <id>server-snapshots</id>
    <username>server-snapshots-username</username>
    <password>server-snapshots-password</password>
  </server>
  ...
</servers>

deploy阶段定义部署文件配置

<plugin>
  <artifactId>maven-deploy-plugin</artifactId>
  <executions>
    <execution>
      <id>deploy-file</id>
      <phase>deploy</phase>
      <goals>
        <goal>deploy-file</goal>
      </goals>
      <configuration>
        <file>${project.build.directory}/${project.artifactId}-${project.version}.zip</file>
        <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
        <url>${project.distributionManagement.snapshotRepository.url}</url>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <packaging>zip</packaging>
      </configuration>
    </execution>
  </executions>
</plugin>

定义snapshotRepository

<distributionManagement>
  <snapshotRepository>
    <id>server-snapshots</id>
    <name>Snapshots repository (snapshots)</name>
    <url>http://repository.com/repo/server-snapshots</url>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </snapshotRepository>
</distributionManagement>

执行mvn deploy