final String apiVersion) throws Abort
{
boolean dependenciesAsResourceRoot = needDependenciesAsResourceRoot(project);
DirectoryResource moduleDir = getOrCreatePluginModuleDirectory(dep);
String pluginName = dep.getGroupId() + "." + dep.getArtifactId();
String pluginSlot = dep.getVersion();
FileResource<?> moduleXml = (FileResource<?>) moduleDir.getChild("module.xml");
if (moduleXml.exists()
&& !shell.promptBoolean(
"An existing installation for version [" + pluginSlot
+ "] of this plugin was found. Replace it?", true))
{
throw new Abort("Aborted.");
}
moduleXml.delete();
moduleXml.createNewFile();
// <resource-root path="maven-dependency.jar" />
Node module = XMLParser.parse(getClass().getResourceAsStream(MODULE_TEMPLATE_XML));
module.attribute("name", pluginName);
module.attribute("slot", pluginSlot);
Node resources = module.getSingle("resources");
resources.createChild("resource-root").attribute("path", dep.getArtifactId() + ".jar");
if (dependenciesAsResourceRoot)
{
writeResourceRoots(project, module, moduleDir, resources);
}
// Copy the compiled JAR into the module directory
FileResource<?> jar = moduleDir.getChild(dep.getArtifactId() + ".jar").reify(FileResource.class);
jar.createNewFile();
jar.setContents(artifact.getResourceInputStream());
// <module name="org.jboss.forge:main" />
Node dependencies = module.getSingle("dependencies");