Search in sources :

Example 6 with JpsLibraryRoot

use of org.jetbrains.jps.model.library.JpsLibraryRoot in project intellij-elixir by KronicDeth.

the class Builder method prependCodePaths.

private static void prependCodePaths(@NotNull GeneralCommandLine commandLine, @NotNull JpsSdk sdk) {
    JpsLibrary jpsLibrary = sdk.getParent();
    List<JpsLibraryRoot> compiledRoots = jpsLibrary.getRoots(JpsOrderRootType.COMPILED);
    for (JpsLibraryRoot compiledRoot : compiledRoots) {
        String url = compiledRoot.getUrl();
        assert url.startsWith(URL_PREFIX);
        String path = url.substring(URL_PREFIX.length(), url.length());
        commandLine.addParameters("-pa", path);
    }
}
Also used : JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) JpsLibraryRoot(org.jetbrains.jps.model.library.JpsLibraryRoot)

Example 7 with JpsLibraryRoot

use of org.jetbrains.jps.model.library.JpsLibraryRoot in project intellij-elixir by KronicDeth.

the class BuilderTest method addElixirSdk.

private JpsSdk<SdkProperties> addElixirSdk(@NotNull JpsSdk erlangSdk) {
    JpsTypedLibrary<JpsSdk<SdkProperties>> elixirTypedLibrary = myModel.getGlobal().addSdk("Elixir " + elixirVersion(), elixirSdkHome(), elixirVersion(), Elixir.INSTANCE);
    HomePath.eachEbinPath(elixirSdkHome(), ebinPath -> elixirTypedLibrary.addRoot(JpsPathUtil.pathToUrl(ebinPath.toAbsolutePath().toString()), JpsOrderRootType.COMPILED));
    JpsLibrary erlangSdkLibrary = erlangSdk.getParent();
    elixirTypedLibrary.getProperties().getSdkProperties().setErlangSdkName(erlangSdkLibrary.getName());
    for (JpsLibraryRoot erlangLibraryRoot : erlangSdkLibrary.getRoots(JpsOrderRootType.COMPILED)) {
        elixirTypedLibrary.addRoot(erlangLibraryRoot.getUrl(), JpsOrderRootType.COMPILED);
    }
    return elixirTypedLibrary.getProperties();
}
Also used : JpsSdk(org.jetbrains.jps.model.library.sdk.JpsSdk) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) JpsLibraryRoot(org.jetbrains.jps.model.library.JpsLibraryRoot)

Example 8 with JpsLibraryRoot

use of org.jetbrains.jps.model.library.JpsLibraryRoot in project teavm by konsoletyper.

the class TeaVMBuild method buildClassPath.

private void buildClassPath(JpsModule module) {
    File output = JpsJavaExtensionService.getInstance().getOutputDirectory(module, false);
    if (output != null) {
        classPathEntries.add(output.getPath());
    }
    for (JpsModuleSourceRoot sourceRoot : module.getSourceRoots()) {
        buildStrategy.addSourcesDirectory(sourceRoot.getFile().getAbsolutePath());
    }
    for (JpsDependencyElement dependency : module.getDependenciesList().getDependencies()) {
        if (dependency instanceof JpsModuleDependency) {
            JpsModuleDependency moduleDependency = (JpsModuleDependency) dependency;
            File dependencyOutput = JpsJavaExtensionService.getInstance().getOutputDirectory(moduleDependency.getModule(), false);
            if (dependencyOutput != null && !isBlacklistedDependency(dependencyOutput)) {
                classPathEntries.add(dependencyOutput.getPath());
            }
            for (JpsModuleSourceRoot sourceRoot : moduleDependency.getModule().getSourceRoots()) {
                buildStrategy.addSourcesDirectory(sourceRoot.getFile().getAbsolutePath());
            }
        } else if (dependency instanceof JpsLibraryDependency) {
            JpsLibrary library = ((JpsLibraryDependency) dependency).getLibrary();
            if (library == null) {
                continue;
            }
            classPathEntries.addAll(library.getFiles(JpsOrderRootType.COMPILED).stream().map(File::getPath).collect(toList()));
            for (JpsLibraryRoot libraryRoot : library.getRoots(JpsOrderRootType.SOURCES)) {
                File file = getFileFromUrl(libraryRoot.getUrl());
                if (file != null) {
                    if (file.isDirectory()) {
                        buildStrategy.addSourcesDirectory(file.getAbsolutePath());
                    } else {
                        buildStrategy.addSourcesJar(file.getAbsolutePath());
                    }
                }
            }
        }
    }
}
Also used : JpsLibraryDependency(org.jetbrains.jps.model.module.JpsLibraryDependency) JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) JpsModuleDependency(org.jetbrains.jps.model.module.JpsModuleDependency) JpsDependencyElement(org.jetbrains.jps.model.module.JpsDependencyElement) File(java.io.File) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) JpsLibraryRoot(org.jetbrains.jps.model.library.JpsLibraryRoot)

Aggregations

JpsLibraryRoot (org.jetbrains.jps.model.library.JpsLibraryRoot)8 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 NotNull (org.jetbrains.annotations.NotNull)2 ApplicationStarter (com.intellij.openapi.application.ApplicationStarter)1 PathManager (com.intellij.openapi.application.PathManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 com.intellij.openapi.projectRoots (com.intellij.openapi.projectRoots)1 JavaDependentSdkType (com.intellij.openapi.projectRoots.impl.JavaDependentSdkType)1 AnnotationOrderRootType (com.intellij.openapi.roots.AnnotationOrderRootType)1 JavadocOrderRootType (com.intellij.openapi.roots.JavadocOrderRootType)1 OrderRootType (com.intellij.openapi.roots.OrderRootType)1 Messages (com.intellij.openapi.ui.Messages)1 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1 SystemInfo (com.intellij.openapi.util.SystemInfo)1 ThrowableComputable (com.intellij.openapi.util.ThrowableComputable)1