Search in sources :

Example 31 with JpsLibrary

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

the class JpsDependenciesEnumeratorTest method testAnnotations.

public void testAnnotations() {
    JpsLibrary library = addLibrary();
    String libraryUrl = "temp:///library";
    library.addRoot(libraryUrl, JpsAnnotationRootType.INSTANCE);
    JpsModuleRootModificationUtil.addDependency(myModule, library);
    assertEnumeratorRoots(dependencies(myModule).annotations(), libraryUrl);
    String moduleUrl = "temp://module";
    JpsJavaExtensionService.getInstance().getOrCreateModuleExtension(myModule).getAnnotationRoots().addUrl(moduleUrl);
    assertEnumeratorRoots(dependencies(myModule).annotations(), moduleUrl, libraryUrl);
}
Also used : JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 32 with JpsLibrary

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

the class JpsJavaExtensionTest method testDependency.

public void testDependency() {
    final JpsModel model = myModel.createModifiableModel(new TestJpsEventDispatcher());
    final JpsModule module = model.getProject().addModule("m", JpsJavaModuleType.INSTANCE);
    final JpsLibrary library = model.getProject().addLibrary("l", JpsJavaLibraryType.INSTANCE);
    final JpsLibraryDependency dependency = module.getDependenciesList().addLibraryDependency(library);
    getJavaService().getOrCreateDependencyExtension(dependency).setScope(JpsJavaDependencyScope.TEST);
    getJavaService().getOrCreateDependencyExtension(dependency).setExported(true);
    model.commit();
    List<JpsDependencyElement> dependencies = assertOneElement(myProject.getModules()).getDependenciesList().getDependencies();
    assertEquals(2, dependencies.size());
    final JpsDependencyElement dep = dependencies.get(1);
    final JpsJavaDependencyExtension extension = getJavaService().getDependencyExtension(dep);
    assertNotNull(extension);
    assertTrue(extension.isExported());
    assertSame(JpsJavaDependencyScope.TEST, extension.getScope());
}
Also used : JpsLibraryDependency(org.jetbrains.jps.model.module.JpsLibraryDependency) JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsDependencyElement(org.jetbrains.jps.model.module.JpsDependencyElement) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 33 with JpsLibrary

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

the class JpsModuleTest method testChangeElementInModifiableModel.

public void testChangeElementInModifiableModel() {
    final JpsModule module = myProject.addModule("m", JpsJavaModuleType.INSTANCE);
    final JpsModule dep = myProject.addModule("dep", JpsJavaModuleType.INSTANCE);
    final JpsLibrary library = myProject.addLibrary("l", JpsJavaLibraryType.INSTANCE);
    module.getDependenciesList().addLibraryDependency(library);
    myDispatcher.clear();
    final JpsModel modifiableModel = myModel.createModifiableModel(new TestJpsEventDispatcher());
    final JpsModule m = modifiableModel.getProject().getModules().get(0);
    assertEquals("m", m.getName());
    m.getDependenciesList().getDependencies().get(1).remove();
    m.getDependenciesList().addModuleDependency(dep);
    modifiableModel.commit();
    assertOneElement(myDispatcher.retrieveRemoved(JpsLibraryDependency.class));
    assertSame(dep, assertOneElement(myDispatcher.retrieveAdded(JpsModuleDependency.class)).getModuleReference().resolve());
    List<JpsDependencyElement> dependencies = module.getDependenciesList().getDependencies();
    assertEquals(2, dependencies.size());
    assertSame(dep, assertInstanceOf(dependencies.get(1), JpsModuleDependency.class).getModuleReference().resolve());
}
Also used : JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 34 with JpsLibrary

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

the class MarkDirtyTest method testRecompileDependentTests.

public void testRecompileDependentTests() {
    JpsModule module = addModule();
    addTestRoot(module, "testSrc");
    JpsLibrary library = addLibrary("lib/a.jar");
    JpsModuleRootModificationUtil.addDependency(module, library, JpsJavaDependencyScope.TEST, false);
    doTestBuild(1).assertSuccessful();
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 35 with JpsLibrary

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

the class ArtifactBuilderTest method testCopyLibrary.

public void testCopyLibrary() {
    final JpsLibrary library = addProjectLibrary("lib", getJUnitJarPath());
    final JpsArtifact a = addArtifact(root().lib(library));
    buildAll();
    assertOutput(a, fs().file("junit.jar"));
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) 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