7

以下の記述子と pom ファイルを使用して、maven でいくつかの zip パッケージを作成しました。しかし、maven では、デフォルトでターゲットフォルダーに 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>

アセンブリ プラグイン記述子ファイル:

<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
4

2 に答える 2

9

最初に、次のように 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>

次の方法でファイルをネクサスに簡単に展開できることを修正した場合:

mvn clean deploy

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>

さらに、使用するプラグインのバージョンを次のように定義することをお勧めします。

    <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>
于 2014-08-22T07:37:09.323 に答える
0

間違いです:<file/>要素は の一部ではありません<snapshotRepository/>。デプロイ プラグインの構成アイテムです! 次のようにzipファイルを展開する必要があります。

mvn -X clean package deploy:deploy-file -Dfile=/path/to/your-artifact-1.0.zip
于 2014-08-22T07:37:12.230 に答える