简体   繁体   中英

Include unzipped resource in JAR - Maven

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.

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 生命周期、阶段、目标、插件

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM