Include unzipped resource in JAR - Maven

Viewed 103

I have a versioned ZIP file deployed in my artifact repository that I need to download, extract, and include as a resource with Maven.

I have been successful using the maven-dependency-plugin to retrieve the artifact and extract it during the package phase with the unpack goal. I see the extracted ZIP where I want it in the build directory. I then have that unpacked directory included as a resource. I can see the directory getting included with the appropriate files inside of the source-jar/myProject-sources.jar. I do not see this folder included in the final JAR myProject.jar.

Any suggestions or examples on how to include this extracted resource would be appreciated.

1 Answers

If you extract during the package phase that's long after the process-resources phase when the maven-resources-plugin's resources goal runs by default:

Maven Lifecycles, Phases, Goals, Plugins

resources:resources copies the resources for the main source code to the main output directory.

This goal usually executes automatically, because it is bound by default to the process-resources life-cycle phase. It always uses the project.build.resources element to specify the resources, and by default uses the project.build.outputDirectory to specify the copy destination.

I'd try to extract at the generate-resources phase.

Related