6.6. Using Plug-in ResourcesThe Logifier plug-in requires that the Logging Aspect file be bundled in the plug-in JAR so that, at runtime, it can weave the Logging Aspect onto the target project's code. 6.6.1. How do I do that?There's a special place for plug-in resources in a plug-in project: src/plugin-resources. Figure 6-4 shows the Logifier plug-in file structure showing the Aspect saved in a Logging.aj file. Figure 6-4. Logifier plug-in's file structure showing the Logging.aj plug-in resourceTell Maven to copy these resources in the generated plug-in JAR. You do this by using the resource element in the plug-in's project.xml file: <build> [...] <resources> <resource> <directory>src/plugin-resources</directory> <targetPath>plugin-resources</targetPath> </resource> <resource> <directory>.</directory> <includes> <include>plugin.jelly</include> <include>plugin.properties</include> <include>project.xml</include> </includes> </resource> </resources> </build> This means that your Logging.aj file will be located in a plugin-resources/aspect directory inside the generated plug-in JAR. Now you can reference any resource from your plugin.jelly file, or in the plugin.properties file using the ${plugin.resources} expression. For example, to reference the Logging.aj Aspect you'd write ${plugin.resources}/aspect/Logging.aj. You'll see how this is used in the next section. |