use of meghanada.project.ProjectDependency in project meghanada-server by mopemope.
the class AndroidSupport method addAAR.
private void addAAR(File jar) {
String pkg = jar.getParentFile().getParentFile().getParentFile().getParentFile().getName();
String name = jar.getParentFile().getParentFile().getParentFile().getName();
String id = pkg + '.' + name;
String version = jar.getParentFile().getParentFile().getName();
ProjectDependency projectDependency = new ProjectDependency(id, DEFAULT_SCOPE, version, jar, ProjectDependency.Type.JAR);
this.project.getDependencies().add(projectDependency);
}
use of meghanada.project.ProjectDependency in project meghanada-server by mopemope.
the class AndroidSupport method addDependencies.
private void addDependencies(Set<ProjectDependency> dependencies, File jar) {
String id = jar.getName();
String version = DEFAULT_VERSION;
String scope = DEFAULT_SCOPE;
ProjectDependency projectDependency = new ProjectDependency(id, scope, version, jar, ProjectDependency.Type.JAR);
dependencies.add(projectDependency);
}
use of meghanada.project.ProjectDependency 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;
}
use of meghanada.project.ProjectDependency in project meghanada-server by mopemope.
the class MavenProject method parseProject.
@Override
public Project parseProject() throws ProjectParseException {
try {
final String mavenPath = Config.load().getMavenPath();
if (!Strings.isNullOrEmpty(mavenPath)) {
this.mavenCmd = mavenPath;
}
final File logFile = File.createTempFile("meghanada-maven-classpath", ".log");
logFile.deleteOnExit();
final String logPath = logFile.getCanonicalPath();
log.info("running maven. resolve dependencies ...");
if (this.runMvn(RESOLVE_TASK, SOURCES_TASK, BUILD_CLASSPATH_TASK, String.format("-Dmdep.outputFile=%s", logPath)) != 0) {
throw new ProjectParseException("Could not resolve dependencies. please try 'mvn dependency:resolve' or 'mvn install'");
}
final String cpTxt = Files.asCharSource(logFile, StandardCharsets.UTF_8).readFirstLine();
if (cpTxt != null && !cpTxt.isEmpty()) {
for (final String dep : Splitter.on(File.pathSeparator).split(cpTxt)) {
final File file = new File(dep);
final String parentPath = file.getParent();
final String version = MavenProject.getVersion(parentPath);
final String code = MavenProject.getArtifactCode(parentPath);
final ProjectDependency.Type type = ProjectDependency.getFileType(file);
final ProjectDependency dependency = new ProjectDependency(code, "COMPILE", version, file, type);
super.dependencies.add(dependency);
}
}
final POMParser pomParser = new POMParser(this.projectRoot);
final POMInfo pomInfo = pomParser.parsePom(this.pomFile);
{
super.sources.addAll(pomInfo.getSourceDirectory());
File src = new File(this.projectRoot, String.join(File.separator, "src", "main", "java"));
super.sources.add(src);
super.resources.addAll(pomInfo.getResourceDirectories());
File resource = new File(this.projectRoot, String.join(File.separator, "src", "main", "resource"));
super.resources.add(resource);
File output = pomInfo.getOutputDirectory();
if (output == null) {
output = new File(this.projectRoot, String.join(File.separator, "target", "classes"));
}
super.output = output;
}
{
super.testSources.addAll(pomInfo.getTestSourceDirectory());
File src = new File(this.projectRoot, String.join(File.separator, "src", "test", "java"));
super.testSources.add(src);
super.testResources.addAll(pomInfo.getTestResourceDirectories());
File testResource = new File(this.projectRoot, String.join(File.separator, "src", "test", "resource"));
super.testResources.add(testResource);
File output = pomInfo.getTestOutputDirectory();
if (output == null) {
output = new File(this.projectRoot, String.join(File.separator, "target", "test-classes"));
}
super.testOutput = output;
}
super.compileSource = pomInfo.compileSource;
super.compileTarget = pomInfo.compileTarget;
} catch (IOException | InterruptedException e) {
throw new ProjectParseException(e);
}
return this;
}
Aggregations