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());
}
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);
}
Aggregations