use of org.jetbrains.jps.model.java.JpsJavaDependenciesEnumerator in project intellij-community by JetBrains.
the class JpsGantProjectBuilder method getModuleDependencies.
private static Set<String> getModuleDependencies(JpsModule module, boolean includeTests) {
JpsJavaDependenciesEnumerator enumerator = JpsJavaExtensionService.dependencies(module).recursively();
if (!includeTests) {
enumerator = enumerator.productionOnly();
}
Set<String> names = new HashSet<>();
for (JpsModule depModule : enumerator.getModules()) {
names.add(depModule.getName());
}
return names;
}
use of org.jetbrains.jps.model.java.JpsJavaDependenciesEnumerator in project intellij-community by JetBrains.
the class JpsPluginSyntheticArtifactProvider method createArtifact.
private static JpsArtifact createArtifact(JpsModule module, JpsPluginModuleProperties properties) {
JpsPackagingElementFactory factory = JpsPackagingElementFactory.getInstance();
JpsCompositePackagingElement root = factory.createArtifactRoot();
String pluginXmlUrl = properties.getPluginXmlUrl();
if (pluginXmlUrl != null) {
String pluginXmlPath = JpsPathUtil.urlToPath(pluginXmlUrl);
JpsCompositePackagingElement metaInfDir = factory.getOrCreateDirectory(root, "META-INF");
metaInfDir.addChild(factory.createFileCopy(pluginXmlPath, null));
File pluginXmlFile = JpsPathUtil.urlToFile(pluginXmlUrl);
if (pluginXmlFile.exists()) {
try {
Element rootElement = JDOMUtil.load(pluginXmlFile);
for (Element dependsElement : JDOMUtil.getChildren(rootElement, "depends")) {
String relativePath = dependsElement.getAttributeValue("config-file");
if (relativePath != null) {
File dependencyFile = new File(pluginXmlFile.getParent(), FileUtil.toSystemDependentName(relativePath));
String dependencyPath = FileUtil.toSystemIndependentName(dependencyFile.getAbsolutePath());
metaInfDir.addChild(factory.createFileCopy(dependencyPath, null));
}
}
} catch (JDOMException | IOException e) {
LOG.info(e);
}
}
}
JpsJavaDependenciesEnumerator enumerator = JpsJavaExtensionService.dependencies(module).recursively().includedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME);
JpsCompositePackagingElement classesDir = factory.getOrCreateDirectory(root, "classes");
for (JpsModule depModule : enumerator.getModules()) {
if (depModule.getModuleType().equals(JpsJavaModuleType.INSTANCE)) {
classesDir.addChild(JpsJavaExtensionService.getInstance().createProductionModuleOutput(depModule.createReference()));
}
}
classesDir.addChild(JpsJavaExtensionService.getInstance().createProductionModuleOutput(module.createReference()));
for (JpsLibrary library : enumerator.getLibraries()) {
JpsCompositePackagingElement parent;
if (hasDirsOnly(library)) {
parent = classesDir;
} else {
parent = factory.getOrCreateDirectory(root, "lib");
}
parent.addChild(factory.createLibraryElement(library.createReference()));
}
String name = module.getName() + ":plugin";
JpsArtifact artifact = JpsArtifactService.getInstance().createArtifact(name, root, DirectoryArtifactType.INSTANCE, JpsElementFactory.getInstance().createDummyElement());
JpsSdk<JpsSimpleElement<JpsIdeaSdkProperties>> sdk = module.getSdk(JpsIdeaSdkType.INSTANCE);
if (sdk != null) {
String sandboxHome = sdk.getSdkProperties().getData().getSandboxHome();
if (sandboxHome != null) {
artifact.setOutputPath(sandboxHome + "/plugins/" + module.getName());
}
}
return artifact;
}
use of org.jetbrains.jps.model.java.JpsJavaDependenciesEnumerator in project intellij-community by JetBrains.
the class JpsGantProjectBuilder method moduleRuntimeClasspath.
public List<String> moduleRuntimeClasspath(JpsModule module, boolean forTests) {
JpsJavaDependenciesEnumerator enumerator = JpsJavaExtensionService.dependencies(module).recursively().includedIn(JpsJavaClasspathKind.runtime(forTests));
Collection<File> roots = enumerator.classes().getRoots();
List<String> result = new ArrayList<>();
for (File root : roots) {
result.add(root.getAbsolutePath());
}
return result;
}
Aggregations