Package org.jetbrains.idea.maven.dom.model

Examples of org.jetbrains.idea.maven.dom.model.MavenDomDependency


        // suppress inspection for projects not having an OSGi context.
        if (!OsmorcFacet.hasOsmorcFacet(xmltag)) {
          return;
        }
        // get the dependency
        MavenDomDependency dependency = getDependency(xmltag);
        if (dependency != null) {
          String scope = dependency.getScope().getStringValue();
          if ("test".equals(scope)) {
            // don't test this for "test" dependencies...
            return;
          }
          // get the projects manager for this dependency
          MavenProjectsManager manager = MavenProjectsManager.getInstance(xmltag.getProject());
          // try to resolve the jar file
          File artifactFile = MavenArtifactUtil
            .getArtifactFile(manager.getLocalRepository(), dependency.getGroupId().getStringValue(),
                             dependency.getArtifactId().getStringValue(),
                             dependency.getVersion().getStringValue(), "jar");
          if (artifactFile.exists() && !CachingBundleInfoProvider.isBundle(artifactFile.getPath())) {
            problemsHolder.registerProblem(xmltag, "Dependency is not OSGi-ready", new FindOsgiCapableMavenDependencyQuickFix());
          }
        }
      }
View Full Code Here


    public String getName() {
      return "Find OSGi-ready version";
    }

    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {
      final MavenDomDependency dependency = getDependency((XmlTag)problemDescriptor.getPsiElement());
      final ObrMavenResult mavenResult =
        ObrSearchDialog.queryForMavenArtifact(project, dependency.getArtifactId().toString());
      if (mavenResult != null) {

        final PsiFile psiFile = problemDescriptor.getPsiElement().getContainingFile();
        new WriteCommandAction(project, psiFile) {
          protected void run(Result result) throws Throwable

          {
            MavenDomProjectModel model =
              MavenDomUtil.getMavenDomProjectModel(getProject(), psiFile.getVirtualFile());
            // adds a new dependency to the end of the list
            MavenDomDependency dummy = model.getDependencies().addDependency();
            dummy.getArtifactId().setStringValue(mavenResult.getArtifactId());
            dummy.getVersion().setStringValue(mavenResult.getVersion());
            dummy.getGroupId().setStringValue(mavenResult.getGroupId());
            // copy over scope from old item
            if (!"".equals(dependency.getScope().getStringValue())) {
              dummy.getScope().setStringValue(dependency.getScope().getStringValue());
            }

            PsiElement newDep = dummy.getXmlElement();
            PsiElement oldDep = dependency.getXmlElement();
            // add after the old element a copy of our dummy element (which is at the end of the list so far)
            oldDep.getParent().addAfter(newDep.copy(), oldDep);
            // kill old dependency and the dummy
            oldDep.delete();
View Full Code Here

TOP

Related Classes of org.jetbrains.idea.maven.dom.model.MavenDomDependency

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.