org.ops4j.pax.construct.util
Class DirUtils

java.lang.Object
  extended by org.ops4j.pax.construct.util.DirUtils

public final class DirUtils
extends java.lang.Object

Various utility methods for managing and refactoring directories and paths


Nested Class Summary
static interface DirUtils.EntryFilter
          Simple API to allow selected unpacking of content from bundles
 
Method Summary
static java.lang.String[] calculateRelativePath(java.io.File baseDir, java.io.File targetDir)
          Calculate the relative path (and common directory) to get from a base directory to a target directory
static PomUtils.Pom createModuleTree(java.io.File baseDir, java.io.File targetDir)
          Verify all Maven POMs from the base directory to the target, adding missing POMs as required
static java.util.List expandOSGiClassPath(java.io.File outputDir, java.util.List path, java.io.File tempDir)
          Expand any bundle entries on the classpath to include embedded jars, etc.
static PomUtils.Pom findPom(java.io.File baseDir, java.lang.String pomId)
          Search the local project tree for a Maven POM with the given id
static void pruneEmptyFolders(java.io.File baseDir)
          Recursively delete (prune) all empty directories underneath the base directory
static java.lang.String rebasePaths(java.lang.String path, java.lang.String baseDir, char pathSeparator)
          Refactor path string, adding base directory to all entries
static java.io.File resolveFile(java.io.File file, boolean ignoreErrors)
          Resolve a file to its unique canonical path - null resolves to the current directory
static boolean unpackBundle(java.io.File bundle, java.io.File here, DirUtils.EntryFilter filter)
           
static java.lang.String updateLogicalParent(java.io.File pomFile, java.lang.String parentId)
          Set the logical parent for a given POM
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolveFile

public static java.io.File resolveFile(java.io.File file,
                                       boolean ignoreErrors)
Resolve a file to its unique canonical path - null resolves to the current directory

Parameters:
file - file, may be null
ignoreErrors - ignore checked exceptions when true
Returns:
file representing the canonical path

findPom

public static PomUtils.Pom findPom(java.io.File baseDir,
                                   java.lang.String pomId)
Search the local project tree for a Maven POM with the given id

Parameters:
baseDir - directory in the project tree
pomId - either artifactId or groupId:artifactId
Returns:
a Maven POM with the given id, null if not found

createModuleTree

public static PomUtils.Pom createModuleTree(java.io.File baseDir,
                                            java.io.File targetDir)
                                     throws java.io.IOException
Verify all Maven POMs from the base directory to the target, adding missing POMs as required

Parameters:
baseDir - base directory
targetDir - target directory
Returns:
the Maven project in the target directory
Throws:
java.io.IOException

calculateRelativePath

public static java.lang.String[] calculateRelativePath(java.io.File baseDir,
                                                       java.io.File targetDir)
Calculate the relative path (and common directory) to get from a base directory to a target directory

Parameters:
baseDir - base directory
targetDir - target directory
Returns:
three strings: a dotted path, absolute location of the common directory, and a descent path

updateLogicalParent

public static java.lang.String updateLogicalParent(java.io.File pomFile,
                                                   java.lang.String parentId)
                                            throws java.io.IOException
Set the logical parent for a given POM

Parameters:
pomFile - directory or file containing the pom to update
parentId - either artifactId or groupId:artifactId
Returns:
the relative path to the parent, null if it wasn't found
Throws:
java.io.IOException

rebasePaths

public static java.lang.String rebasePaths(java.lang.String path,
                                           java.lang.String baseDir,
                                           char pathSeparator)
Refactor path string, adding base directory to all entries

Parameters:
path - path to refactor
baseDir - base directory to add
pathSeparator - path separator
Returns:
the refactored path

expandOSGiClassPath

public static java.util.List expandOSGiClassPath(java.io.File outputDir,
                                                 java.util.List path,
                                                 java.io.File tempDir)
Expand any bundle entries on the classpath to include embedded jars, etc.

Parameters:
outputDir - current output directory
path - list of classpath elements
tempDir - temporary directory for unpacking
Returns:
expanded classpath

unpackBundle

public static boolean unpackBundle(java.io.File bundle,
                                   java.io.File here,
                                   DirUtils.EntryFilter filter)
Parameters:
bundle - jarfile
here - unpack directory
filter - selection filter
Returns:
true if bundle was successfully unpacked

pruneEmptyFolders

public static void pruneEmptyFolders(java.io.File baseDir)
Recursively delete (prune) all empty directories underneath the base directory

Parameters:
baseDir - base directory


Copyright © 2007-2008 OPS4J. All Rights Reserved.