use of org.jetbrains.jps.model.module.JpsModuleDependency in project android by JetBrains.
the class AndroidBuildDataCache method collectAndroidDependencies.
private static void collectAndroidDependencies(@NotNull JpsModule module, @NotNull MyAndroidDeps result, @NotNull Set<String> visitedSet, boolean fillLibs, boolean recursively) {
final List<JpsDependencyElement> dependencies = new ArrayList<JpsDependencyElement>(JpsJavaExtensionService.getInstance().getDependencies(module, JpsJavaClasspathKind.PRODUCTION_RUNTIME, false));
for (int i = dependencies.size() - 1; i >= 0; i--) {
final JpsDependencyElement item = dependencies.get(i);
if (item instanceof JpsModuleDependency) {
final JpsModule depModule = ((JpsModuleDependency) item).getModule();
if (depModule != null) {
final JpsAndroidModuleExtension depExtension = AndroidJpsUtil.getExtension(depModule);
if (depExtension != null && visitedSet.add(depModule.getName())) {
if (recursively) {
final boolean newRecursively = AndroidJpsUtil.shouldProcessDependenciesRecursively(depModule);
collectAndroidDependencies(depModule, result, visitedSet, fillLibs && depExtension.isLibrary(), newRecursively);
}
result.myAndroidDeps.add(depExtension);
if (fillLibs && depExtension.isLibrary()) {
result.myLibAndroidDeps.add(depExtension);
}
}
}
}
}
}
use of org.jetbrains.jps.model.module.JpsModuleDependency in project android by JetBrains.
the class AndroidSourceGeneratingBuilder method checkAndroidDependencies.
private static void checkAndroidDependencies(@NotNull Map<JpsModule, MyModuleData> moduleDataMap, @NotNull CompileContext context) {
for (Map.Entry<JpsModule, MyModuleData> entry : moduleDataMap.entrySet()) {
final JpsModule module = entry.getKey();
final MyModuleData moduleData = entry.getValue();
final JpsAndroidModuleExtension extension = moduleData.getAndroidExtension();
if (extension.isLibrary()) {
continue;
}
for (JpsDependencyElement item : JpsJavaExtensionService.getInstance().getDependencies(module, JpsJavaClasspathKind.PRODUCTION_RUNTIME, false)) {
if (item instanceof JpsModuleDependency) {
final JpsModule depModule = ((JpsModuleDependency) item).getModule();
if (depModule != null) {
final JpsAndroidModuleExtension depExtension = AndroidJpsUtil.getExtension(depModule);
if (depExtension != null && !depExtension.isLibrary()) {
String message = "Suspicious module dependency " + module.getName() + " -> " + depModule.getName() + ": Android application module depends on other application module. Possibly, you should " + "change type of module '" + depModule.getName() + "' to 'Library' or change the dependency scope to 'Provided'.";
context.processMessage(new CompilerMessage(ANDROID_VALIDATOR, BuildMessage.Kind.WARNING, message));
}
}
}
}
}
}
use of org.jetbrains.jps.model.module.JpsModuleDependency in project intellij-community by JetBrains.
the class DependentModulesCompilationTest method addExportedDependency.
private static void addExportedDependency(JpsModule main, JpsModule dep) {
JpsModuleDependency dependency = main.getDependenciesList().addModuleDependency(dep);
JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency).setExported(true);
}
use of org.jetbrains.jps.model.module.JpsModuleDependency 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