How to extend maven packaging type? Is there some extra plugin packaging step I'm missing?
I have been trying to get a zip maven plugin that I have created to work for over a week. There are many examples, but I just cannot get it to work. Some of the examples I've looked at are as follows:
- http://softwaredistilled.blogspot.com/2015/07/how-to-create-custom-maven-packaging.html
- http://maestrodev.github.io/zip-bundle-maven-plugin/usage.html
- Plus many more ...
The examples I found in my search only indicate that the extension requires a component.xml file, and in the project where it is used, add the attribute <extensions>true</extensions>
to the plugin link.
I created the following .xml components in src / main / resources / META-INF / plexus /
<component-set>
<components>
<!--
| ZIP
|-->
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>zip</role-hint>
<implementation>
org.apache.maven.artifact.handler.DefaultArtifactHandler
</implementation>
<configuration>
<type>zip</type>
<includesDependencies>true</includesDependencies>
<addedToClasspath>false</addedToClasspath>
</configuration>
</component>
<component>
<role>
org.apache.maven.lifecycle.mapping.LifecycleMapping
</role>
<role-hint>zip</role-hint>
<implementation>
org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
</implementation>
<configuration>
<lifecycles>
<lifecycle>
<id>default</id>
<phases>
<package>
org.apache.maven.plugins:maven-assembly-plugin:2.3:single
</package>
<install>
org.apache.maven.plugins:maven-install-plugin:2.3.1:install
</install>
<deploy>
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
</deploy>
</phases>
</lifecycle>
</lifecycles>
</configuration>
</component>
</components>
</component-set>
<component-set>
org.apache.maven.artifact.handler.ArtifactHandler zipper org.apache.maven.artifact.handler.DefaultArtifactHandler zipper true false org.apache.maven.lifecycle.mapping.LifecycleMapping zipper org.apache.mapping zipper lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins: Maven build-plugin: 2.3: standalone org.apache.maven.plugins: Maven-install-plugin: 2.3.1: install org.apache.maven.plugins: Maven-plugin-deployment:2.7: expand
And a plugin pom.xml file that looks 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.mycompany.devops.maven.plugins</groupId>
<artifactId>zip-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>zip-maven-plugin Maven Plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<goalPrefix>zip</goalPrefix>
<skipErrorNoDescriptorsFound>
true
</skipErrorNoDescriptorsFound>
</configuration>
</plugin>
</plugins>
</build>
</project>
I added the plugin to target pom.xml like this:
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>my-zipped-artifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>zip</packaging>
<build>
<plugins>
<plugin>
<groupId>com.mycompany.devops.maven.plugins</groupId>
<artifactId>zip-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
By enabling Maven debug mode using the -X flag, I find this output:
[DEBUG] Created new class realm extension>com.mycompany.devops.maven.plugins:zip-maven-plugin:0.0.1-SNAPSHOT
[DEBUG] Importing foreign packages into class realm extension>com.mycompany.devops.maven.plugins:zip-maven-plugin:0.0.1-SNAPSHOT
[DEBUG] Imported: < maven.api
[DEBUG] Populating class realm extension>com.mycompany.devops.maven.plugins:zip-maven-plugin:0.0.1-SNAPSHOT
[DEBUG] Included: com.mycompany.devops.maven.plugins:zip-maven-plugin:jar:0.0.1-SNAPSHOT
[DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:1.1
[DEBUG] Extension realms for project mycompany:myartifact:zip:0.0.1-SNAPSHOT: [ClassRealm[extension>com.mycompany.devops.maven.plugins:zip-maven-plugin:0.0.1-SNAPSHOT, parent: sun.misc.Launcher$AppClassLoader@42a57993]]
[DEBUG] Created new class realm project>mycompany:myartifact:0.0.1-SNAPSHOT
[DEBUG] Populating class realm project>mycompany:myartifact:0.0.1-SNAPSHOT
[DEBUG] Looking up lifecyle mappings for packaging zip from ClassRealm[project>mycompany:myartifact:0.0.1-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unknown packaging: zip @ line 12, column 16
Maven tries to process my plugin but doesn't find it later. Any ideas?
source to share
No one has answered this question yet
Check out similar questions: