1) Put the binaries in src/main/resources. (make sure resource filtering isn't enabled) 2) Watch them get compiled into your plugin's JAR file. 3) use Class.getResourceAsStream() to get an InputStream to each binary. 4) copy the bytes from the InputStream to a FileOutputStream. No need to use any part of the Maven API for this, although there is probably a utility class in plexus-utils that will handle step #4 for you. Justin
________________________________ From: Ian Graham [mailto:[email protected]] Sent: Mon 5/18/2009 6:57 PM To: [email protected] Subject: Self-Extracting Maven Plugin Hello, I'm working on a Maven Reporting plugin that depends on a set of binaries to do its work, but I haven't been able to find a way to package those binaries with my plugin, and extract them for use at runtime. Ideally, I'd like to store the binaries and some associated configuration files, etc. in the plugin's src/main/resources directory, and when the plugin is invoked, the binaries would be extracted to the output directory of whatever project is calling the plugin. The obvious solution would be to include the plugin itself in the project's dependencies, and then use the maven-dependency-plugin to extract the binaries directly from the plugin jar. However, I need to be able to invoke the plugin without modifying the project's POM. So far, I've tried the following: - Create a separate package for the binaries, which the plugin includes as a runtime dependency. In the Plugin's POM, I configured the dependency plugin to extract the binary package, but when the plugin is invoked from a separate project, the package doesn't get extracted. - Manually extract the contents of the plugin's .jar file as part of its own executeReport() method. This didn't work because the Artifact for my plugin as returned by MavenProject.getReportArtifacts() doesn't contain a reference to the actual jar file (Artifact.getFile() returns null). I also tried manually looking up the Artifact using an ArtifactFactory, but I can't see any way to properly construct an instance of or obtain a reference to an ArtifactFactory from within a plugin. Is there a simple solution that I'm overlooking here? At this point, I'm out of ideas, and any help would be greatly appreciated! Thanks, --Ian --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
