0

I have a set of files I'd like to include in the .jar generated by mvn compile. Unfortunately, I would like them to be placed in a specific path inside the .jar. For example, I want shaders/main.glsl to be in the .jar file as com/purplefrog/expglsl/castle/main.glsl

How do I specify this mapping in the pom.xml ? I can not mess with the directory heirarchy of the source project without throwing a wrench into other coders' workflows.

Mutant Bob
  • 3,121
  • 2
  • 27
  • 52
  • Put the class in `src/main/resources/com/purplefrog/expglsl/castle/main.glsl` and it will be automatically there. If this will mess others sounds like you violate SRP. – khmarbaise Aug 26 '15 at 17:01

2 Answers2

1

Take a look at the Maven Resources Plugin and this question.

Sounds like that should handle what you're looking to do if modifying the project structure up front isn't an option.

Community
  • 1
  • 1
whitlaaa
  • 892
  • 8
  • 15
1

During the process-resources phase non-compilable files can be moved (by the maven-resources-plugin). What you should do is add a resource-block to your pom. Here you need to specify the directory. You can also add a targetPath. All together it would look like

<resource>
  <directory>shaders</directory>
  <!-- include all ore just a couple of files? -- >
  <includes>
    <include>main.glsl</include>
  </includes>
  <targetPath>com/purplefrog/expglsl/castle</targetPath>
</resource> 

Now these files are copied to the target/classes and during the package phase they'll become part of the jar.

Robert Scholte
  • 11,889
  • 2
  • 35
  • 44