Search in sources :

Example 1 with JpsSdk

use of org.jetbrains.jps.model.library.sdk.JpsSdk in project intellij-community by JetBrains.

the class JpsPluginProjectSerializationTest method testLoadProject.

public void testLoadProject() {
    loadProject("plugins/devkit/jps-plugin/testData/pluginProject/pluginProject.ipr");
    JpsModule module = assertOneElement(myProject.getModules());
    assertEquals(JpsPluginModuleType.INSTANCE, module.getModuleType());
    JpsTypedModule<JpsSimpleElement<JpsPluginModuleProperties>> pluginModule = module.asTyped(JpsPluginModuleType.INSTANCE);
    assertNotNull(pluginModule);
    String url = pluginModule.getProperties().getData().getPluginXmlUrl();
    assertEquals(getUrl("META-INF/plugin.xml"), url);
    JpsTypedLibrary<JpsSdk<JpsDummyElement>> javaSdk = myModel.getGlobal().addSdk("1.6", null, null, JpsJavaSdkType.INSTANCE);
    JpsSimpleElement<JpsIdeaSdkProperties> properties = JpsElementFactory.getInstance().createSimpleElement(new JpsIdeaSdkProperties(null, "1.6"));
    JpsTypedLibrary<JpsSdk<JpsSimpleElement<JpsIdeaSdkProperties>>> pluginSdk = myModel.getGlobal().addSdk("IDEA plugin SDK", null, null, JpsIdeaSdkType.INSTANCE, properties);
    assertSame(pluginSdk.getProperties(), module.getSdk(JpsIdeaSdkType.INSTANCE));
    assertSame(javaSdk.getProperties(), module.getSdk(JpsJavaSdkType.INSTANCE));
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) JpsSdk(org.jetbrains.jps.model.library.sdk.JpsSdk)

Example 2 with JpsSdk

use of org.jetbrains.jps.model.library.sdk.JpsSdk in project intellij-community by JetBrains.

the class JpsSdkTableSerializer method saveSdks.

public static void saveSdks(JpsLibraryCollection libraryCollection, Element sdkListElement) {
    for (JpsLibrary library : libraryCollection.getLibraries()) {
        JpsElement properties = library.getProperties();
        if (properties instanceof JpsSdk<?>) {
            Element sdkTag = new Element(JDK_TAG);
            saveSdk((JpsSdk<?>) properties, sdkTag);
            sdkListElement.addContent(sdkTag);
        }
    }
}
Also used : JpsElement(org.jetbrains.jps.model.JpsElement) JpsElement(org.jetbrains.jps.model.JpsElement) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) Element(org.jdom.Element) JpsSdk(org.jetbrains.jps.model.library.sdk.JpsSdk) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 3 with JpsSdk

use of org.jetbrains.jps.model.library.sdk.JpsSdk in project intellij-community by JetBrains.

the class JpsDependenciesEnumeratorTest method testDoNotAddJdkRootsFromModuleDependency.

public void testDoNotAddJdkRootsFromModuleDependency() {
    JpsModule dep = addModule("dep");
    JpsTypedLibrary<JpsSdk<JpsDummyElement>> jdk8 = addJdk("1.8");
    JpsModuleRootModificationUtil.addDependency(myModule, dep);
    JpsModuleRootModificationUtil.setModuleSdk(dep, jdk8.getProperties());
    assertClassRoots(dependencies(myModule).recursively(), getRtJarJdk17());
    assertClassRoots(dependencies(dep).recursively(), getRtJarJdk18());
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsSdk(org.jetbrains.jps.model.library.sdk.JpsSdk)

Example 4 with JpsSdk

use of org.jetbrains.jps.model.library.sdk.JpsSdk in project intellij-community by JetBrains.

the class JpsDependenciesEnumeratorTest method addJdk.

@NotNull
private JpsTypedLibrary<JpsSdk<JpsDummyElement>> addJdk(final String mockJdkVersion) {
    final String mockJdkDir = "mockJDK-" + mockJdkVersion;
    File home = PathManagerEx.findFileUnderCommunityHome("java/" + mockJdkDir);
    JpsTypedLibrary<JpsSdk<JpsDummyElement>> jdk = myModel.getGlobal().addSdk(mockJdkVersion, home.getAbsolutePath(), mockJdkVersion, JpsJavaSdkType.INSTANCE);
    jdk.addRoot(getRtJar(mockJdkDir), JpsOrderRootType.COMPILED);
    return jdk;
}
Also used : JpsSdk(org.jetbrains.jps.model.library.sdk.JpsSdk) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with JpsSdk

use of org.jetbrains.jps.model.library.sdk.JpsSdk in project intellij-community by JetBrains.

the class JpsJavaExtensionServiceImpl method addJavaSdk.

@Override
public JpsTypedLibrary<JpsSdk<JpsDummyElement>> addJavaSdk(@NotNull JpsGlobal global, @NotNull String name, @NotNull String homePath) {
    String version = JdkVersionDetector.getInstance().detectJdkVersion(homePath);
    JpsTypedLibrary<JpsSdk<JpsDummyElement>> sdk = global.addSdk(name, homePath, version, JpsJavaSdkType.INSTANCE);
    File homeDir = new File(FileUtil.toSystemDependentName(homePath));
    List<File> roots = JavaSdkUtil.getJdkClassesRoots(homeDir, false);
    for (File root : roots) {
        sdk.addRoot(root, JpsOrderRootType.COMPILED);
    }
    return sdk;
}
Also used : JpsSdk(org.jetbrains.jps.model.library.sdk.JpsSdk) File(java.io.File)

Aggregations

JpsSdk (org.jetbrains.jps.model.library.sdk.JpsSdk)7 File (java.io.File)2 NotNull (org.jetbrains.annotations.NotNull)2 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)2 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)2 JpsModule (org.jetbrains.jps.model.module.JpsModule)2 Element (org.jdom.Element)1 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)1 JpsElement (org.jetbrains.jps.model.JpsElement)1 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)1 JpsLibraryRoot (org.jetbrains.jps.model.library.JpsLibraryRoot)1