use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-community by JetBrains.
the class DependencyResolvingBuilder method getRepositoryLibraries.
@NotNull
private static Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> getRepositoryLibraries(ModuleChunk chunk) {
final Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> result = new SmartHashSet<>();
for (JpsModule module : chunk.getModules()) {
for (JpsDependencyElement dep : module.getDependenciesList().getDependencies()) {
if (dep instanceof JpsLibraryDependency) {
final JpsLibrary _lib = ((JpsLibraryDependency) dep).getLibrary();
final JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>> lib = _lib != null ? _lib.asTyped(JpsMavenRepositoryLibraryType.INSTANCE) : null;
if (lib != null) {
result.add(lib);
}
}
}
}
return result;
}
use of org.jetbrains.jps.model.library.JpsLibrary 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.library.JpsLibrary in project intellij-community by JetBrains.
the class JpsEclipseClasspathReader method addModuleLibrary.
@Override
protected void addModuleLibrary(JpsModule rootModel, Element element, boolean exported, String libName, String url, String srcUrl, String nativeRoot, ExpandMacroToPathMap macroMap) {
final JpsLibrary jpsLibrary = rootModel.addModuleLibrary(libName, JpsJavaLibraryType.INSTANCE);
final JpsDependenciesList dependenciesList = rootModel.getDependenciesList();
final JpsLibraryDependency dependency = dependenciesList.addLibraryDependency(jpsLibrary);
url = StringUtil.trimStart(url, "file://");
final String linked = expandLinkedResourcesPath(url, macroMap);
if (linked != null) {
url = pathToUrl(linked);
} else {
url = expandEclipsePath2Url(rootModel, url);
}
LOG.debug("loading " + rootModel.getName() + ": adding module library " + libName + ": " + url);
jpsLibrary.addRoot(url, JpsOrderRootType.COMPILED);
setLibraryEntryExported(dependency, exported);
}
use of org.jetbrains.jps.model.library.JpsLibrary in project intellij-plugins by JetBrains.
the class FlexBuildTarget method computeRootDescriptors.
@Override
@NotNull
public List<BuildRootDescriptor> computeRootDescriptors(final JpsModel model, final ModuleExcludeIndex index, final IgnoredFileIndex ignoredFileIndex, final BuildDataPaths dataPaths) {
final List<BuildRootDescriptor> result = new ArrayList<>();
final Collection<File> srcRoots = new ArrayList<>();
for (JpsModuleSourceRoot sourceRoot : myBC.getModule().getSourceRoots(JavaSourceRootType.SOURCE)) {
final File root = JpsPathUtil.urlToFile(sourceRoot.getUrl());
result.add(new FlexSourceRootDescriptor(this, root));
srcRoots.add(root);
}
if (FlexCommonUtils.isFlexUnitBC(myBC)) {
for (JpsModuleSourceRoot sourceRoot : myBC.getModule().getSourceRoots(JavaSourceRootType.TEST_SOURCE)) {
final File root = JpsPathUtil.urlToFile(sourceRoot.getUrl());
result.add(new FlexSourceRootDescriptor(this, root));
srcRoots.add(root);
}
}
for (final JpsFlexDependencyEntry entry : myBC.getDependencies().getEntries()) {
if (entry instanceof JpsFlexBCDependencyEntry) {
final JpsFlexBuildConfiguration dependencyBC = ((JpsFlexBCDependencyEntry) entry).getBC();
if (dependencyBC != null) {
result.add(new FlexSourceRootDescriptor(this, new File(dependencyBC.getActualOutputFilePath())));
}
} else if (entry instanceof JpsLibraryDependencyEntry) {
final JpsLibrary library = ((JpsLibraryDependencyEntry) entry).getLibrary();
if (library != null) {
for (String rootUrl : library.getRootUrls(JpsOrderRootType.COMPILED)) {
result.add(new FlexSourceRootDescriptor(this, JpsPathUtil.urlToFile(rootUrl)));
}
}
}
}
final BuildConfigurationNature nature = myBC.getNature();
if (nature.isWebPlatform() && nature.isApp() && myBC.isUseHtmlWrapper() && !myBC.getWrapperTemplatePath().isEmpty()) {
addIfNotUnderRoot(result, new File(myBC.getWrapperTemplatePath()), srcRoots);
}
if (FlexCommonUtils.canHaveRLMsAndRuntimeStylesheets(myBC)) {
for (String cssPath : myBC.getCssFilesToCompile()) {
if (!cssPath.isEmpty()) {
addIfNotUnderRoot(result, new File(cssPath), srcRoots);
}
}
}
if (!myBC.getCompilerOptions().getAdditionalConfigFilePath().isEmpty()) {
addIfNotUnderRoot(result, new File(myBC.getCompilerOptions().getAdditionalConfigFilePath()), srcRoots);
}
if (nature.isApp()) {
if (nature.isDesktopPlatform()) {
addAirDescriptorPathIfCustom(result, myBC.getAirDesktopPackagingOptions(), srcRoots);
} else if (nature.isMobilePlatform()) {
if (myBC.getAndroidPackagingOptions().isEnabled()) {
addAirDescriptorPathIfCustom(result, myBC.getAndroidPackagingOptions(), srcRoots);
}
if (myBC.getIosPackagingOptions().isEnabled()) {
addAirDescriptorPathIfCustom(result, myBC.getIosPackagingOptions(), srcRoots);
}
}
}
return result;
}
use of org.jetbrains.jps.model.library.JpsLibrary in project android by JetBrains.
the class AndroidJpsUtil method collectResDirectoriesFromAarDeps.
public static void collectResDirectoriesFromAarDeps(@NotNull JpsModule module, @NotNull Collection<String> result) {
final Set<JpsLibrary> libs = JpsJavaExtensionService.getInstance().enumerateDependencies(Collections.singletonList(module)).runtimeOnly().productionOnly().getLibraries();
for (JpsLibrary lib : libs) {
final Pair<File, List<File>> pair = getResDirAndJarsIfAar(lib);
final File resDir = pair != null ? pair.getFirst() : null;
if (resDir != null) {
result.add(resDir.getPath());
}
}
}
Aggregations