public final class FileUtilities extends Object
Modifier and Type | Method and Description |
---|---|
static File |
convertArtifactToLocalRepositoryFile(org.apache.maven.artifact.Artifact artifact)
take any (even unresolved) Maven Arfifact instance and construct a local
repository based File instance for it.
|
static File |
convertStringToFile(String str)
converts a string representing a path to a normalized File instance
|
static FileObject |
convertStringToFileObject(String str) |
static URI |
convertStringToUri(String str) |
static FileObject |
convertURItoFileObject(URI uri) |
static SortedSet<String> |
getBasePackageNames(Project prj) |
static URI |
getDirURI(FileObject root,
String path) |
static URI |
getDirURI(File root,
String path) |
static SortedSet<String> |
getPackageNames(Project prj)
Inspired by org.netbeans.modules.apisupport.project.Util.scanProjectForPackageNames
Returns sorted set of given project's package names in x.y.z form.
|
static String |
getRelativePath(File dir,
File file)
get relative path between file and it's child.
|
static File |
getUserSettingsFile(boolean forceCreate)
Get the user settings.xml file.
|
static String |
relativizeFile(File basedir,
File file)
Produce a machine-independent relativized version of a filename from a basedir.
|
static File |
resolveFilePath(File basedir,
String filename)
copied from netbeans.org's ant/project sources.
|
@CheckForNull public static FileObject convertURItoFileObject(@NullAllowed URI uri)
@CheckForNull public static FileObject convertStringToFileObject(@NullAllowed String str)
@NullUnknown public static File convertStringToFile(@NullAllowed String str)
str
- @NullUnknown public static URI convertStringToUri(@NullAllowed String str)
public static File convertArtifactToLocalRepositoryFile(org.apache.maven.artifact.Artifact artifact)
artifact
- public static File resolveFilePath(File basedir, String filename)
public static URI getDirURI(@NonNull FileObject root, @NonNull String path)
public static String getRelativePath(File dir, File file)
dir
- file
- public static String relativizeFile(File basedir, File file)
URI.relativize(java.net.URI)
this will produce "../" sequences as needed.basedir
- a directory to resolve relative to (need not exist on disk)file
- a file or directory to find a relative path forIllegalArgumentException
- if the basedir is known to be a file and not a directory
copied from project.ant's PropertyUtilspublic static SortedSet<String> getPackageNames(Project prj)
prj
- project to retrieve package names frompublic static SortedSet<String> getBasePackageNames(Project prj)
public static File getUserSettingsFile(boolean forceCreate)
forceCreate
- determines whether file should be created in case it does not existnull
if not available