如何在maven中仅部署zip工件

div*_*scm 7 maven-plugin maven maven-deploy-plugin

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

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>
Run Code Online (Sandbox Code Playgroud)

程序集插件描述符文件:

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

<fileSets>
    <fileSet>
        <directory>src/main/resources</directory>
        <includes>
            <include>**/*</include>
        </includes>
        <outputDirectory>DB_Files</outputDirectory>
    </fileSet>
</fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)

执行命令:

mvn -X clean package deploy:deploy-file
Run Code Online (Sandbox Code Playgroud)

错误:

[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
Run Code Online (Sandbox Code Playgroud)

khm*_*ise 7

首先,您需要在distributionManagement区域修复错误,如下所示:

  <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>
Run Code Online (Sandbox Code Playgroud)

如果你修复了,你可以通过以下方式将文件简单地部署到你的nexus:

mvn clean deploy
Run Code Online (Sandbox Code Playgroud)

如果您不喜欢部署jar,则需要更改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>
  <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>
Run Code Online (Sandbox Code Playgroud)

此外,我建议您定义使用过的插件的版本,如下所示:

    <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>
Run Code Online (Sandbox Code Playgroud)

  • 您在`<version> 2.0.0.1 </ version>`中定义了这是Mavne的发布版本.如果你喜欢SNAPSHOT,你需要定义`<version> 2.0.0.1-SNAPSHOT </ version>`. (3认同)