Class DependencyUtil


  • public final class DependencyUtil
    extends java.lang.Object
    Utility class with static helper methods
    Version:
    $Id$
    • Constructor Summary

      Constructors 
      Constructor Description
      DependencyUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String cleanToBeTokenizedString​(java.lang.String str)
      clean up configuration string before it can be tokenized
      private static java.lang.String getDependencyId​(org.apache.maven.artifact.Artifact artifact, boolean removeVersion)  
      static java.lang.String getFormattedFileName​(org.apache.maven.artifact.Artifact artifact, boolean removeVersion)
      Builds the file name.
      static java.lang.String getFormattedFileName​(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId)
      Builds the file name.
      static java.lang.String getFormattedFileName​(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean useBaseVersion)
      Builds the file name.
      static java.lang.String getFormattedFileName​(org.apache.maven.artifact.Artifact artifact, boolean removeVersion, boolean prependGroupId, boolean useBaseVersion, boolean removeClassifier)
      Builds the file name.
      static java.io.File getFormattedOutputDirectory​(boolean useSubdirsPerScope, boolean useSubdirsPerType, boolean useSubdirPerArtifact, boolean useRepositoryLayout, boolean removeVersion, java.io.File outputDirectory, org.apache.maven.artifact.Artifact artifact)
      Formats the outputDirectory based on type.
      static void log​(java.lang.String string, org.apache.maven.plugin.logging.Log log)
      Writes the specified string to the log at info level.
      static java.lang.String[] tokenizer​(java.lang.String str)
      mainly used to parse excludes,includes configuration
      static void write​(java.lang.String string, java.io.File file, boolean append, org.apache.maven.plugin.logging.Log log)
      Writes the specified string to the specified file.
      • Methods inherited from class java.lang.Object

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

      • DependencyUtil

        public DependencyUtil()
    • Method Detail

      • getFormattedFileName

        public static java.lang.String getFormattedFileName​(org.apache.maven.artifact.Artifact artifact,
                                                            boolean removeVersion)
        Builds the file name. If removeVersion is set, then the file name must be reconstructed from the artifactId, Classifier (if used) and Type. Otherwise, this method returns the artifact file name.
        Parameters:
        artifact - File to be formatted.
        removeVersion - Specifies if the version should be removed from the file name.
        Returns:
        Formatted file name in the format artifactId-[version]-[classifier].[type]
        See Also:
        getFormattedFileName(Artifact, boolean, boolean)
      • getFormattedFileName

        public static java.lang.String getFormattedFileName​(org.apache.maven.artifact.Artifact artifact,
                                                            boolean removeVersion,
                                                            boolean prependGroupId)
        Builds the file name. If removeVersion is set, then the file name must be reconstructed from the groupId (if prependGroupId is true) artifactId, Classifier (if used) and Type. Otherwise, this method returns the artifact file name.
        Parameters:
        artifact - File to be formatted.
        removeVersion - Specifies if the version should be removed from the file name.
        prependGroupId - Specifies if the groupId should be prepended to the file name.
        Returns:
        Formatted file name in the format [groupId].artifactId-[version]-[classifier].[type]
      • getFormattedFileName

        public static java.lang.String getFormattedFileName​(org.apache.maven.artifact.Artifact artifact,
                                                            boolean removeVersion,
                                                            boolean prependGroupId,
                                                            boolean useBaseVersion)
        Builds the file name. If removeVersion is set, then the file name must be reconstructed from the groupId (if prependGroupId is true) artifactId, Classifier (if used) and Type. Otherwise, this method returns the artifact file name.
        Parameters:
        artifact - File to be formatted.
        removeVersion - Specifies if the version should be removed from the file name.
        prependGroupId - Specifies if the groupId should be prepended to the file name.
        useBaseVersion - Specifies if the baseVersion of the artifact should be used instead of the version.
        Returns:
        Formatted file name in the format [groupId].artifactId-[version]-[classifier].[type]
      • getFormattedFileName

        public static java.lang.String getFormattedFileName​(org.apache.maven.artifact.Artifact artifact,
                                                            boolean removeVersion,
                                                            boolean prependGroupId,
                                                            boolean useBaseVersion,
                                                            boolean removeClassifier)
        Builds the file name. If removeVersion is set, then the file name must be reconstructed from the groupId (if prependGroupId is true) artifactId, Classifier (if used) and Type. Otherwise, this method returns the artifact file name.
        Parameters:
        artifact - File to be formatted.
        removeVersion - Specifies if the version should be removed from the file name.
        prependGroupId - Specifies if the groupId should be prepended to the file name.
        useBaseVersion - Specifies if the baseVersion of the artifact should be used instead of the version.
        removeClassifier - Specifies if the classifier of the artifact should be remved from the file name.
        Returns:
        Formatted file name in the format [groupId].artifactId-[version]-[classifier].[type]
      • getFormattedOutputDirectory

        public static java.io.File getFormattedOutputDirectory​(boolean useSubdirsPerScope,
                                                               boolean useSubdirsPerType,
                                                               boolean useSubdirPerArtifact,
                                                               boolean useRepositoryLayout,
                                                               boolean removeVersion,
                                                               java.io.File outputDirectory,
                                                               org.apache.maven.artifact.Artifact artifact)
        Formats the outputDirectory based on type.
        Parameters:
        useSubdirsPerScope - if a new sub directory should be used for each scope.
        useSubdirsPerType - if a new sub directory should be used for each type.
        useSubdirPerArtifact - if a new sub directory should be used for each artifact.
        useRepositoryLayout - if dependencies must be moved into a Maven repository layout, if set, other settings will be ignored.
        removeVersion - if the version must not be mentioned in the filename
        outputDirectory - base outputDirectory.
        artifact - information about the artifact.
        Returns:
        a formatted File object to use for output.
      • getDependencyId

        private static java.lang.String getDependencyId​(org.apache.maven.artifact.Artifact artifact,
                                                        boolean removeVersion)
      • write

        public static void write​(java.lang.String string,
                                 java.io.File file,
                                 boolean append,
                                 org.apache.maven.plugin.logging.Log log)
                          throws java.io.IOException
        Writes the specified string to the specified file.
        Parameters:
        string - the string to write
        file - the file to write to
        append - append to existing file or not.
        log - where to send the logging output.
        Throws:
        java.io.IOException - if an I/O error occurs
      • log

        public static void log​(java.lang.String string,
                               org.apache.maven.plugin.logging.Log log)
                        throws java.io.IOException
        Writes the specified string to the log at info level.
        Parameters:
        string - the string to write
        log - where to log information.
        Throws:
        java.io.IOException - if an I/O error occurs
      • tokenizer

        public static java.lang.String[] tokenizer​(java.lang.String str)
        mainly used to parse excludes,includes configuration
        Parameters:
        str - The string to be split.
        Returns:
        The result items.
      • cleanToBeTokenizedString

        public static java.lang.String cleanToBeTokenizedString​(java.lang.String str)
        clean up configuration string before it can be tokenized
        Parameters:
        str - The str which should be cleaned.
        Returns:
        cleaned up string.