Ich habe ein paar Zip-Packungen in Maven mit dem folgenden Deskriptor und der folgenden POM-Datei gemacht. Aber in maven hat es standardmäßig sowohl jar als auch Zip im Zielordner erstellt. Jetzt möchte ich nur Zip-Inhalte bereitstellen, bei denen ich das Plugin deploy: deploy-file verwende. Es wird jedoch nicht bereitgestellt, sondern es wird ein Fehler angezeigt. Ich bin nicht sicher, was mit dem Tag nicht stimmt und wie es behoben werden soll.
Pom-Datei:
<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>
Assembler-Plugin-Deskriptordatei:
<Assembly>
<formats>
<format>Zip</format>
</formats>
<fileSets>
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>DB_Files</outputDirectory>
</fileSet>
</fileSets>
</Assembly>
Befehl ausgeführt:
mvn -X clean package deploy:deploy-file
Error:
[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
Zuerst müssen Sie Ihren Fehler im Bereich "DistributionManagement" wie folgt beheben:
<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>
Wenn Sie das Problem behoben haben, können Sie die Dateien einfach auf Ihrem Nexus bereitstellen:
mvn clean deploy
Wenn Sie nicht möchten, dass auch ein Glas bereitgestellt wird, müssen Sie die Verpackungsart in Ihrem Pom wie folgt ändern:
<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>
Außerdem empfehle ich, die Versionen Ihrer verwendeten Plugins wie folgt zu definieren:
<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>
Sie haben einen Fehler gemacht: Das <file/>
-Element ist kein Teil von <snapshotRepository/>
, sondern ein Konfigurationselement des Implementierungs-Plugins! Sie sollten Ihre Zip-Datei wie folgt bereitstellen:
mvn -X clean package deploy:deploy-file -Dfile=/path/to/your-artifact-1.0.Zip