Search in sources :

Example 1 with JpsLibrary

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;
}
Also used : JpsLibraryDependency(org.jetbrains.jps.model.module.JpsLibraryDependency) SmartHashSet(com.intellij.util.containers.SmartHashSet) JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsTypedLibrary(org.jetbrains.jps.model.library.JpsTypedLibrary) JpsDependencyElement(org.jetbrains.jps.model.module.JpsDependencyElement) RepositoryLibraryDescriptor(org.jetbrains.jps.maven.model.RepositoryLibraryDescriptor) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with JpsLibrary

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;
}
Also used : JpsCompositePackagingElement(org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) Element(org.jdom.Element) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException) JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsPackagingElementFactory(org.jetbrains.jps.model.artifact.elements.JpsPackagingElementFactory) File(java.io.File) JpsJavaDependenciesEnumerator(org.jetbrains.jps.model.java.JpsJavaDependenciesEnumerator) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) JpsCompositePackagingElement(org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement)

Example 3 with JpsLibrary

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);
}
Also used : JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 4 with JpsLibrary

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;
}
Also used : ArrayList(java.util.ArrayList) JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) File(java.io.File) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with JpsLibrary

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());
        }
    }
}
Also used : JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Aggregations

JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)41 JpsModule (org.jetbrains.jps.model.module.JpsModule)11 File (java.io.File)10 Element (org.jdom.Element)8 NotNull (org.jetbrains.annotations.NotNull)7 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)7 JpsLibraryRoot (org.jetbrains.jps.model.library.JpsLibraryRoot)6 JpsAndroidModuleExtensionImpl (org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl)5 JpsAndroidModuleProperties (org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)5 JpsElement (org.jetbrains.jps.model.JpsElement)5 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Nullable (org.jetbrains.annotations.Nullable)3 JpsDependencyElement (org.jetbrains.jps.model.module.JpsDependencyElement)3 JpsLibraryDependency (org.jetbrains.jps.model.module.JpsLibraryDependency)3 Logger (com.intellij.openapi.diagnostic.Logger)2 SystemInfo (com.intellij.openapi.util.SystemInfo)2 JpsElementFactory (org.jetbrains.jps.model.JpsElementFactory)2 JpsSdkReference (org.jetbrains.jps.model.library.sdk.JpsSdkReference)2