Class AddDependency

  • All Implemented Interfaces:
    MavenSourceVisitor<org.openrewrite.xml.tree.Xml>, org.openrewrite.RefactorVisitor<org.openrewrite.xml.tree.Xml>, org.openrewrite.SourceVisitor<org.openrewrite.xml.tree.Xml>, org.openrewrite.xml.XmlSourceVisitor<org.openrewrite.xml.tree.Xml>

    public class AddDependency
    extends MavenRefactorVisitor
    Adds a dependency if there is no dependency matching groupId and artifactId. A matching dependency with a different version or scope does NOT have its version or scope updated. Use ChangeDependencyVersion or UpgradeDependencyVersion in the case of a different version. Use ChangeDependencyScope in the case of a different scope.

    Places a new dependency as physically "near" to a group of similar dependencies as possible.

    • Constructor Summary

      Constructors 
      Constructor Description
      AddDependency()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isIdempotent()  
      void setArtifactId​(java.lang.String artifactId)  
      void setClassifier​(java.lang.String classifier)  
      void setFamilyPattern​(java.lang.String familyPattern)  
      void setGroupId​(java.lang.String groupId)  
      void setMetadataPattern​(java.lang.String metadataPattern)
      Allows us to extend version selection beyond the original Node Semver semantics.
      void setReleasesOnly​(boolean releasesOnly)  
      void setScope​(java.lang.String scope)  
      void setSkipIfPresent​(boolean skipIfPresent)  
      void setVersion​(java.lang.String version)  
      org.openrewrite.Validated validate()  
      Maven visitMaven​(Maven maven)  
      • Methods inherited from class org.openrewrite.xml.XmlRefactorVisitor

        enclosingRootTag, enclosingTag, visitAttribute, visitCharData, visitComment, visitDocTypeDecl, visitElement, visitIdent, visitProcessingInstruction, visitProlog, visitTag
      • Methods inherited from class org.openrewrite.AbstractRefactorVisitor

        andThen, andThen, next, refactor, refactor, refactor
      • Methods inherited from class org.openrewrite.AbstractSourceVisitor

        getCursor, setCursoringOn, visit, visitAfter, visitAfter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.openrewrite.RefactorVisitor

        defaultTo, generate, nextCycle
      • Methods inherited from interface org.openrewrite.SourceVisitor

        getCursor, getName, getTags, reduce, visit, visit, visitTree
      • Methods inherited from interface org.openrewrite.xml.XmlSourceVisitor

        enclosingTag, visitAttribute, visitCharData, visitComment, visitDocTypeDecl, visitElement, visitIdent, visitProcessingInstruction, visitProlog, visitTag
    • Constructor Detail

      • AddDependency

        public AddDependency()
    • Method Detail

      • setMetadataPattern

        public void setMetadataPattern​(@Nullable
                                       java.lang.String metadataPattern)
        Allows us to extend version selection beyond the original Node Semver semantics. So for example, We can pair a HyphenRange of "25-29" with a metadata pattern of "-jre" to select Guava 29.0-jre
        Parameters:
        metadataPattern - The metadata pattern extending semver selection.
      • setGroupId

        public void setGroupId​(java.lang.String groupId)
      • setArtifactId

        public void setArtifactId​(java.lang.String artifactId)
      • setVersion

        public void setVersion​(@Nullable
                               java.lang.String version)
      • setClassifier

        public void setClassifier​(@Nullable
                                  java.lang.String classifier)
      • setScope

        public void setScope​(@Nullable
                             java.lang.String scope)
      • setSkipIfPresent

        public void setSkipIfPresent​(boolean skipIfPresent)
      • setReleasesOnly

        public void setReleasesOnly​(boolean releasesOnly)
      • setFamilyPattern

        public void setFamilyPattern​(@Nullable
                                     java.lang.String familyPattern)
        Parameters:
        familyPattern - A glob expression used to identify other dependencies in the same family as the dependency to be added.
      • validate

        public org.openrewrite.Validated validate()
      • isIdempotent

        public boolean isIdempotent()