Class MavenEntry

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class MavenEntry
    extends java.lang.Object
    implements java.io.Closeable
    An entry (a group/artifact) in the maven cache in the .m2/repository directory. It provides methods to get the pom and the artifact.
    • Constructor Summary

      Constructors 
      Constructor Description
      MavenEntry​(Maven maven, java.lang.String path)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      private CachedPom createPom​(java.net.URI url)
      Help function to create the POM and record its source.
      (package private) boolean download​(java.net.URI repo, java.lang.String path)
      Download a resource from the given repo.
      java.io.File getArtifact()  
      java.io.File getArtifactFile()  
      CachedPom getPom​(java.net.URI[] urls)
      This is the method to get the POM for a cached entry.
      java.io.File getPomFile()  
      protected java.util.Properties getProperties()
      Answer the properties, loading if needed.
      private java.lang.String getProperty​(java.lang.String key)
      Answer a property.
      private boolean isValid()
      Check if this is a valid cache directory, might probably need some more stuff.
      void remove()  
      private void saveProperties()  
      private void setProperty​(java.lang.String key, java.lang.String value)
      We maintain a set of bnd properties in the cache directory.
      (package private) java.net.URL toURL​(java.net.URI base, java.lang.String path)
      Converts a repo + path to a URL..
      (package private) boolean verify​(java.net.URI repo, java.lang.String path)
      Verify that the repo has a checksum file for the given path and that this checksum matchs.
      private boolean verify​(java.net.URI repo, java.lang.String path, java.lang.String algorithm)
      Verify the path against its digest for the given algorithm.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • maven

        final Maven maven
      • root

        final java.io.File root
      • dir

        final java.io.File dir
      • path

        final java.lang.String path
      • poms

        final java.util.Map<java.net.URI,​CachedPom> poms
      • pomFile

        final java.io.File pomFile
      • artifactFile

        final java.io.File artifactFile
      • pomPath

        final java.lang.String pomPath
      • propertiesFile

        final java.io.File propertiesFile
      • propertiesChanged

        private boolean propertiesChanged
      • artifact

        java.util.concurrent.FutureTask<java.io.File> artifact
      • artifactPath

        java.lang.String artifactPath
    • Constructor Detail

      • MavenEntry

        MavenEntry​(Maven maven,
                   java.lang.String path)
        Constructor.
        Parameters:
        maven -
        path -
    • Method Detail

      • getArtifactFile

        public java.io.File getArtifactFile()
      • getPom

        public CachedPom getPom​(java.net.URI[] urls)
                         throws java.lang.Exception
        This is the method to get the POM for a cached entry.
        Parameters:
        urls - The allowed URLs
        Returns:
        a CachedPom for this maven entry
        Throws:
        java.lang.Exception - If something goes haywire
      • download

        boolean download​(java.net.URI repo,
                         java.lang.String path)
                  throws java.net.MalformedURLException
        Download a resource from the given repo.
        Parameters:
        url - The base url for the repo
        path - The path part
        Throws:
        java.net.MalformedURLException
      • toURL

        java.net.URL toURL​(java.net.URI base,
                           java.lang.String path)
                    throws java.net.MalformedURLException
        Converts a repo + path to a URL..
        Parameters:
        base - The base repo
        path - The path in the directory + url
        Returns:
        a URL that points to the file in the repo
        Throws:
        java.net.MalformedURLException
      • isValid

        private boolean isValid()
        Check if this is a valid cache directory, might probably need some more stuff.
        Returns:
        true if valid
      • setProperty

        private void setProperty​(java.lang.String key,
                                 java.lang.String value)
        We maintain a set of bnd properties in the cache directory.
        Parameters:
        key - The key for the property
        value - The value for the property
      • getProperties

        protected java.util.Properties getProperties()
        Answer the properties, loading if needed.
      • getProperty

        private java.lang.String getProperty​(java.lang.String key)
        Answer a property.
        Parameters:
        key - The key
        Returns:
        The value
      • saveProperties

        private void saveProperties()
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • createPom

        private CachedPom createPom​(java.net.URI url)
                             throws java.lang.Exception
        Help function to create the POM and record its source.
        Parameters:
        url - the repo from which it was constructed
        Returns:
        the new pom
        Throws:
        java.lang.Exception
      • verify

        boolean verify​(java.net.URI repo,
                       java.lang.String path)
                throws java.lang.Exception
        Verify that the repo has a checksum file for the given path and that this checksum matchs.
        Parameters:
        repo - The repo
        path - The file id
        Returns:
        true if there is a digest and it matches one of the algorithms
        Throws:
        java.lang.Exception
      • verify

        private boolean verify​(java.net.URI repo,
                               java.lang.String path,
                               java.lang.String algorithm)
                        throws java.lang.Exception
        Verify the path against its digest for the given algorithm.
        Parameters:
        repo -
        path -
        algorithm -
        Throws:
        java.lang.Exception
      • getArtifact

        public java.io.File getArtifact()
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getPomFile

        public java.io.File getPomFile()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • remove

        public void remove()