@Nullable
 private static String getProjectName(@Nullable MavenDomDependency dependency) {
   if (dependency != null) {
     MavenDomProjectModel model = dependency.getParentOfType(MavenDomProjectModel.class, false);
     if (model != null) {
       String name = model.getName().getStringValue();
       return StringUtil.isEmptyOrSpaces(name) ? model.getArtifactId().getStringValue() : name;
     }
   }
   return null;
 }
Ejemplo n.º 2
0
  public static MavenId describe(PsiFile psiFile) {
    MavenDomProjectModel model = getMavenDomModel(psiFile, MavenDomProjectModel.class);

    String groupId = model.getGroupId().getStringValue();
    String artifactId = model.getArtifactId().getStringValue();
    String version = model.getVersion().getStringValue();

    if (groupId == null) {
      groupId = model.getMavenParent().getGroupId().getStringValue();
    }

    if (version == null) {
      version = model.getMavenParent().getVersion().getStringValue();
    }

    return new MavenId(groupId, artifactId, version);
  }