Search in sources :

Example 6 with JpsDependencyElement

use of org.jetbrains.jps.model.module.JpsDependencyElement 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 7 with JpsDependencyElement

use of org.jetbrains.jps.model.module.JpsDependencyElement in project intellij-plugins by JetBrains.

the class OsgiBuildSession method prepare.

private void prepare() throws OsgiBuildException {
    myModuleOutputDir = JpsJavaExtensionService.getInstance().getOutputDirectory(myModule, false);
    if (myModuleOutputDir == null) {
        throw new OsgiBuildException("Unable to determine the compiler output path for the module.");
    }
    String jarFileLocation = myExtension.getJarFileLocation();
    if (jarFileLocation.isEmpty()) {
        throw new OsgiBuildException("Bundle path is empty - please check OSGi facet settings.");
    }
    myOutputJarFile = new File(jarFileLocation);
    myOutputJarFiles = myTarget.getOutputRoots(myContext);
    for (File jarFile : myOutputJarFiles) {
        if (!FileUtil.delete(jarFile)) {
            throw new OsgiBuildException("Can't delete bundle file '" + jarFile + "'.");
        }
    }
    if (!FileUtil.createParentDirs(myOutputJarFile)) {
        throw new OsgiBuildException("Cannot create a directory for bundles '" + myOutputJarFile.getParent() + "'.");
    }
    List<File> classes = ContainerUtil.newSmartList();
    if (myModuleOutputDir.exists()) {
        classes.add(myModuleOutputDir);
    }
    for (JpsDependencyElement dependency : myModule.getDependenciesList().getDependencies()) {
        if (dependency instanceof JpsModuleDependency) {
            JpsModule module = ((JpsModuleDependency) dependency).getModule();
            if (module != null && JpsOsmorcExtensionService.getExtension(module) == null) {
                File outputDir = JpsJavaExtensionService.getInstance().getOutputDirectory(module, false);
                if (outputDir != null && outputDir.exists()) {
                    classes.add(outputDir);
                }
            }
        }
    }
    myClasses = classes.isEmpty() ? ArrayUtil.EMPTY_FILE_ARRAY : classes.toArray(new File[classes.size()]);
    List<File> sources = ContainerUtil.newSmartList();
    for (JpsModuleSourceRoot sourceRoot : myModule.getSourceRoots()) {
        File sourceDir = sourceRoot.getFile();
        if (sourceDir.exists()) {
            sources.add(sourceDir);
        }
    }
    mySources = sources.isEmpty() ? ArrayUtil.EMPTY_FILE_ARRAY : sources.toArray(new File[sources.size()]);
    myBndWrapper = new BndWrapper(this);
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) 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)

Aggregations

JpsDependencyElement (org.jetbrains.jps.model.module.JpsDependencyElement)7 JpsModule (org.jetbrains.jps.model.module.JpsModule)7 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)3 JpsLibraryDependency (org.jetbrains.jps.model.module.JpsLibraryDependency)3 File (java.io.File)2 NotNull (org.jetbrains.annotations.NotNull)2 JpsModuleDependency (org.jetbrains.jps.model.module.JpsModuleDependency)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