use of org.gradle.tooling.model.idea.IdeaModuleDependency in project meghanada-server by mopemope.
the class GradleProject method analyzeDependencies.
private Set<ProjectDependency> analyzeDependencies(final IdeaModule ideaModule) {
final Set<ProjectDependency> dependencies = new HashSet<>(16);
for (final IdeaDependency dependency : ideaModule.getDependencies().getAll()) {
if (dependency instanceof IdeaSingleEntryLibraryDependency) {
final IdeaSingleEntryLibraryDependency libraryDependency = (IdeaSingleEntryLibraryDependency) dependency;
final File file = libraryDependency.getFile();
final GradleModuleVersion gradleModuleVersion = libraryDependency.getGradleModuleVersion();
String scope = libraryDependency.getScope().getScope();
String id;
String version;
if (isNull(gradleModuleVersion)) {
id = file.getName();
// dummy
version = "1.0.0";
} else {
id = String.join(":", gradleModuleVersion.getGroup(), gradleModuleVersion.getName(), gradleModuleVersion.getVersion());
version = gradleModuleVersion.getVersion();
}
if (isNull(scope)) {
scope = "COMPILE";
}
if (!scope.equals("PROVIDED")) {
final ProjectDependency.Type type = ProjectDependency.getFileType(file);
final ProjectDependency projectDependency = new ProjectDependency(id, scope, version, file, type);
dependencies.add(projectDependency);
}
} else if (dependency instanceof IdeaModuleDependency) {
final IdeaModuleDependency moduleDependency = (IdeaModuleDependency) dependency;
final String scope = moduleDependency.getScope().getScope();
final String moduleName = moduleDependency.getTargetModuleName();
this.allModules.computeIfPresent(moduleName, (key, projectRoot) -> {
final ProjectDependency projectDependency = new ProjectDependency(key, scope, "1.0.0", projectRoot, ProjectDependency.Type.PROJECT);
dependencies.add(projectDependency);
return projectRoot;
});
if (!this.allModules.containsKey(moduleName)) {
log.warn("missing module:{}", moduleName);
}
} else {
log.warn("dep ??? class={}", dependency.getClass());
}
}
return dependencies;
}
Aggregations