Section 6.6. Using Plug-in Resources


6.6. Using Plug-in Resources

The 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 resource


Tell 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.



Maven. A Developer's Notebook
Maven: A Developers Notebook (Developers Notebooks)
ISBN: 0596007507
EAN: 2147483647
Year: 2003
Pages: 125

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net