return moduleDir;
}
private void createDependenciesModule(final Project project, final Dependency dep)
{
DirectoryResource dependencyDir = getOrCreatePluginDependenciesModuleDirectory(dep);
String pluginName = dep.getGroupId() + "." + dep.getArtifactId();
String pluginSlot = dep.getVersion();
DependencyFacet deps = project.getFacet(DependencyFacet.class);
FileResource<?> moduleXml = (FileResource<?>) dependencyDir.getChild("module.xml");
moduleXml.delete();
moduleXml.createNewFile();
// <resource-root path="maven-dependency.jar" />
Node module = XMLParser.parse(getClass().getResourceAsStream("/org/jboss/forge/modules/module.xml"));
module.attribute("name", pluginName + ".dependencies");
module.attribute("slot", pluginSlot);
Node resources = module.getSingle("resources");
// <module name="org.jboss.forge:main" />
Node dependencies = module.getSingle("dependencies");
dependencies.createChild("module").attribute("name", "javax.api");
List<DependencyResource> pluginDependencies = new ArrayList<DependencyResource>();
List<Dependency> effectiveDependenciesInScopes = deps.getEffectiveDependenciesInScopes(ScopeType.COMPILE,
ScopeType.RUNTIME);
for (Dependency d : effectiveDependenciesInScopes) {
if (d.getPackagingTypeEnum().equals(PackagingType.JAR)
&& !d.getGroupId().equals("org.jboss.forge"))
{
List<DependencyResource> artifacts = resolveArtifacts(project, d);
pluginDependencies.addAll(artifacts);
}
// TODO encapsulate this?
if (DependencyBuilder.areEquivalent(d, DependencyBuilder.create("org.jboss.forge:forge-javaee-api")))
{
module.getSingle("dependencies").createChild("module")
.attribute("name", "org.jboss.forge.javaee-api");
}
}
// Copy dependencies into module
for (DependencyResource d : pluginDependencies) {
String name = d.getName();
Resource<?> child = dependencyDir.getChild(name);
child.delete();
FileResource<?> depJar = child.reify(FileResource.class);
depJar.setContents(d.getResourceInputStream());
resources.createChild("resource-root").attribute("path", name);
}