I have created a custom plugin in Maven. However, the jar
file that is created has the name CustomPlugin-1.0.jar.lastUpdated
'lastUpdated' is the extension, and it's not possible to open the file due to it being corrupt.
The steps I followed to create it are as follows:
packaging=maven-plugin
). AbstractMojo
and contains the custom plugin code. How do I create a valid jar file for a custom plugin?
Use maven-shade plugin to package your jar. It will automatically package and create a jar(fat-jar) with all the dependencies, resources and correct jar name and extension.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<!-- put your configurations here -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
Add this to your custom maven plugin pom and the build using mvn clean install
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.