Making maven copy additional files inside the jar assembly (not resources, but any file inside any package)?

I have an org.myapp.mypackage package with some ruby ​​files (* .rb), and I need to include them in the generated build jar in the same package along with java class files. How can I tell my friend Maven to do this?

OBS: No, I can’t copy anywhere, but thanks for the suggestion. :)

+6
source share
3 answers

You can change the resource section of the <build> POM bit:

 <resources> <resource> <directory>src/main/resources</directory> </resource> <resource> <filtering>false</filtering> <directory>src/main/java</directory> <includes> <include>*.rb</include> </includes> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> </resources> 

Or another answer (create the same package structure in src/main/resources ) will also work.

+6
source

Not sure if I understood the problem correctly, but if your Ruby files are maven packed and declared as a dependency, you can use the shade plugin to include the contents in the resulting jar file:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <artifactSet> <includes> <include>org.myapp.mypackage:mypackage</include> </includes> </artifactSet> <filters> <filter> <artifact>org.myapp.mypackage:mypackage</artifact> <includes> <include>org/my/package/*.rb</include> </includes> </filter> </filters> </configuration> </execution> </executions> </plugin> 
+2
source

Put them in the correct directory (src / main / resources in general) and they should be nested properly. So that the * .rb files create the same dir structure in the src / main / resources folder.

-1
source

Source: https://habr.com/ru/post/914600/


All Articles