private boolean generateExportPackageInformation()

in com.microsoft.java.lsif.core/src/com/microsoft/java/lsif/core/internal/indexer/Indexer.java [223:292]


	private boolean generateExportPackageInformation(IProject proj, IProgressMonitor monitor, LsifService lsif,
			IJavaProject javaProject) throws Exception {
		IPath folderPath = proj.getLocation();
		if (folderPath == null) {
			return false;
		}
		IProjectImporter importer = this.handler.getImporter(folderPath.toFile(), monitor);
		if (importer instanceof MavenProjectImporter) {
			File pomfile = VisitorUtils.findPom(proj.getLocation(), 0);
			if (pomfile == null) {
				return false;
			}
			MavenProject mavenProject = Repository.getInstance().enlistMavenProject(lsif, pomfile);
			if (mavenProject == null) {
				return false;
			}
			Model model = mavenProject.getModel();
			String groupId = model.getGroupId();
			if (groupId == null) {
				return false;
			}
			String artifactId = model.getArtifactId();
			if (artifactId == null) {
				return false;
			}
			String version = model.getVersion();
			if (version == null) {
				return false;
			}
			Scm scm = model.getScm();
			String url = null;
			String type = null;
			// scm is optional
			if (scm != null) {
				url = scm.getUrl();
				String connect = scm.getConnection();
				if (connect != null) {
					type = ScmUrlUtils.getProvider(connect);
				}
			}
			Repository.getInstance().enlistPackageInformation(lsif, javaProject.getPath().toString(),
					groupId + "/" + artifactId, PackageInformation.MAVEN, version, type, url);
			return true;
		} else if (importer instanceof GradleProjectImporter) {
			GradleBuild build = GradleCore.getWorkspace().getBuild(proj).get();
			ProjectPublications model = build
					.withConnection(connection -> connection.getModel(ProjectPublications.class), monitor);
			List<? extends GradlePublication> publications = model.getPublications().getAll();
			if (publications.size() == 0) {
				return false;
			}
			GradleModuleVersion gradleModuleVersion = publications.get(0).getId();
			String groupId = gradleModuleVersion.getGroup();
			if (StringUtils.isEmpty(groupId)) {
				return false;
			}
			String artifactId = gradleModuleVersion.getName();
			if (StringUtils.isEmpty(artifactId)) {
				return false;
			}
			String version = gradleModuleVersion.getVersion();
			if (StringUtils.isEmpty(version)) {
				return false;
			}
			Repository.getInstance().enlistPackageInformation(lsif, javaProject.getPath().toString(),
					groupId + "/" + artifactId, PackageInformation.MAVEN, version, null, null);
			return true;
		}
		return false;
	}