如何在Maven中仅部署zip工件 [英] How to deploy only zip artifacts in maven

查看:121
本文介绍了如何在Maven中仅部署zip工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用下面的描述符和pom文件在maven中完成了一些zip打包.但是默认情况下,在Maven中,它在目标文件夹中创建了jar和zip.现在我只想在使用deploy:deploy-file插件的地方部署zip内容.但它并未部署,而是显示错误.不确定标签有什么问题以及如何解决.

I have done some zip packaging in maven using the below descriptor and pom file. But in maven by default it created both jar and zip in target folder. Now i want to deploy only zip contents where i am using deploy:deploy-file plugin. but it is not deploying instead it is showing error. Not sure what is wrong with tag and how it should be resolved.

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>com.wyndhamvo.prototype.dbscripts</groupId>
  <artifactId>DB_SCRIPTS</artifactId>
  <version>2.0.0.1</version>


<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptor>src/assembly/descriptor.xml</descriptor>
            </configuration>
            <executions> 
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>


  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <distributionManagement>
    <snapshotRepository>
        <id>wvoNexus</id>
        <file>${project.artifactId}-${project.version}.zip</file>
        <url>http://nexus.corproot.com/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>

    <repository>
        <id>wvoNexus</id>
        <file>${project.artifactId}-${project.version}.zip</file>
        <url>http://nexus.corproot.com/nexus/content/repositories/releases/</url>
    </repository>
  </distributionManagement>

</project>

程序集插件描述符文件:

assembly plugin descriptor file:

<assembly>
<formats>
    <format>zip</format>
</formats>

<fileSets>
    <fileSet>
        <directory>src/main/resources</directory>
        <includes>
            <include>**/*</include>
        </includes>
        <outputDirectory>DB_Files</outputDirectory>
    </fileSet>
</fileSets>
</assembly>

已执行命令:

mvn -X clean package deploy:deploy-file

错误:

[ERROR] Malformed POM C:\Divakar\MavenPrototype\DB_Maven_Test\dev\pom.xml: Unrecognised tag: 'file' (position: START_TAG seen ...<id>wvoNexus</id>\r\n\t\t\t<file>... @37:10)  @ C:\Divakar\MavenPrototype\DB_Maven_Test\dev\pom.xml, line 37, column 10

推荐答案

首先,您必须像下面这样来解决您在distributionManagement区域中的错误:

First you have to fix you error in distributionManagement area like this:

  <distributionManagement>
    <snapshotRepository>
        <id>wvoNexus</id>
        <url>http://nexus.corproot.com/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>

    <repository>
        <id>wvoNexus</id>
        <url>http://nexus.corproot.com/nexus/content/repositories/releases/</url>
    </repository>
  </distributionManagement>

如果您修复了问题,则可以通过以下方式将文件简单地部署到您的关系:

If you fixed that you can simple deploy the files to your nexus via:

mvn clean deploy

如果您也不想部署jar,则需要像这样更改pom中的包装类型:

If you don't like having a jar deployed as well you need to change the packing type in your pom like this:

<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.wyndhamvo.prototype.dbscripts</groupId>
  <artifactId>DB_SCRIPTS</artifactId>
  <version>2.0.0.1</version>
  <packaging>pom</packaging>


    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptor>src/assembly/descriptor.xml</descriptor>
                </configuration>
                <executions> 
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

此外,我建议像这样定义您使用的插件的版本:

Furthermore i recommend to define the versions of your used plugins like this:

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <descriptor>src/assembly/descriptor.xml</descriptor>
                </configuration>
                <executions> 
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

这篇关于如何在Maven中仅部署zip工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆