info.rvin.flexmojos.utilities
Class MavenUtils

java.lang.Object
  extended by info.rvin.flexmojos.utilities.MavenUtils

public class MavenUtils
extends java.lang.Object

Utility class to help get information from Maven objects like files, source paths, resolve dependencies, etc.

Author:
velo.br

Method Summary
static java.io.File getArtifactFile(org.apache.maven.artifact.Artifact a, org.apache.maven.model.Build build)
          Get the file reference of an SWC artifact.
static java.io.File getConfigFile(org.apache.maven.model.Build build)
          Returns file reference to config.xml file.
static java.util.Set<org.apache.maven.artifact.Artifact> getDependencyArtifacts(org.apache.maven.project.MavenProject project, org.apache.maven.artifact.resolver.ArtifactResolver resolver, org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List remoteRepositories, org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource)
          Get dependency artifacts for a project using the local and remote repositories to resolve the artifacts
static java.util.List<Namespace> getFdkNamespaces(java.util.Collection<org.apache.maven.artifact.Artifact> dependencies, org.apache.maven.model.Build build)
           
static java.lang.String getFlexMojosVersion()
           
static java.io.File getFontsFile(org.apache.maven.model.Build build)
          Returns the file reference to the fonts file.
static java.io.File getLocaleResourcePath(java.lang.String resourceBundlePath, java.lang.String locale)
          Returns the file reference to a localize resourceBundlePath.
static boolean isApplicationFile(java.io.File file)
          Parse an MXML file and returns true if the file is an application one
static boolean isLinux()
          Return a boolean to show if we are running on Linux.
static boolean isMac()
          Return a boolean to show if we are running on Mac OS X.
static boolean isSolaris()
          Return a boolean to show if we are running on Solaris.
static boolean isUnixBased()
          Return a boolean to show if we are running on a unix-based OS.
static boolean isWindows()
          Return a boolean to show if we are running on Windows.
static boolean isWindowsVista()
          Return a boolean to show if we are running on Windows Vista.
static java.lang.String osString()
           
static void resolveArtifact(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.resolver.ArtifactResolver resolver, org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List remoteRepositories)
          Use the resolver to resolve the given artifact in the local or remote repositories.
static java.io.File resolveResourceFile(org.apache.maven.project.MavenProject project, java.lang.String fileName)
          Resolve a resource file in a maven project resources folders
static java.io.File resolveSourceFile(org.apache.maven.project.MavenProject project, java.lang.String sourceFileName)
          Resolve a source file in a maven project
static org.apache.maven.artifact.Artifact searchFor(java.util.Collection<org.apache.maven.artifact.Artifact> artifacts, java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String type, java.lang.String classifier)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isApplicationFile

public static boolean isApplicationFile(java.io.File file)
Parse an MXML file and returns true if the file is an application one

Parameters:
file - the file to be parsed
Returns:
true if the file is an application one

resolveSourceFile

public static java.io.File resolveSourceFile(org.apache.maven.project.MavenProject project,
                                             java.lang.String sourceFileName)
Resolve a source file in a maven project

Parameters:
project - maven project
sourceFileName - sugested name on pom
Returns:
source file or null if source not found

resolveResourceFile

public static java.io.File resolveResourceFile(org.apache.maven.project.MavenProject project,
                                               java.lang.String fileName)
                                        throws org.apache.maven.plugin.MojoFailureException
Resolve a resource file in a maven project resources folders

Parameters:
project - maven project
fileName - sugested name on pom
Returns:
source file or null if source not found
Throws:
org.apache.maven.plugin.MojoFailureException

getDependencyArtifacts

public static java.util.Set<org.apache.maven.artifact.Artifact> getDependencyArtifacts(org.apache.maven.project.MavenProject project,
                                                                                       org.apache.maven.artifact.resolver.ArtifactResolver resolver,
                                                                                       org.apache.maven.artifact.repository.ArtifactRepository localRepository,
                                                                                       java.util.List remoteRepositories,
                                                                                       org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource)
                                                                                throws org.apache.maven.plugin.MojoExecutionException
Get dependency artifacts for a project using the local and remote repositories to resolve the artifacts

Parameters:
project - maven project
resolver - artifact resolver
localRepository - artifact repository
remoteRepositories - List of remote repositories
artifactMetadataSource - artifactMetadataSource
Returns:
all dependencies from the project
Throws:
org.apache.maven.plugin.MojoExecutionException - thrown if an exception occured during artifact resolving

getArtifactFile

public static java.io.File getArtifactFile(org.apache.maven.artifact.Artifact a,
                                           org.apache.maven.model.Build build)
                                    throws org.apache.maven.plugin.MojoExecutionException
Get the file reference of an SWC artifact.
If the artifact file does not exist in the [build-dir]/libraries/[scope] directory, the artifact file is copied to that location.

Parameters:
a - artifact for which to retrieve the file reference
scope - scope of the library
build - build for which to get the artifact
Returns:
swc artifact file reference
Throws:
org.apache.maven.plugin.MojoExecutionException - thrown if an IOException occurs while copying the file to the [build-dir]/libraries/[scope] directory

resolveArtifact

public static void resolveArtifact(org.apache.maven.artifact.Artifact artifact,
                                   org.apache.maven.artifact.resolver.ArtifactResolver resolver,
                                   org.apache.maven.artifact.repository.ArtifactRepository localRepository,
                                   java.util.List remoteRepositories)
                            throws org.apache.maven.plugin.MojoExecutionException
Use the resolver to resolve the given artifact in the local or remote repositories.

Parameters:
artifact - Artifact to be resolved
resolver - ArtifactResolver to use for resolving the artifact
localRepository - ArtifactRepository
remoteRepositories - List of remote artifact repositories
Throws:
org.apache.maven.plugin.MojoExecutionException - thrown if an exception occured during artifact resolving

getConfigFile

public static java.io.File getConfigFile(org.apache.maven.model.Build build)
                                  throws org.apache.maven.plugin.MojoExecutionException
Returns file reference to config.xml file. Copies the config file to the build directory.

Parameters:
build - Build for which to get the config.xml file
Returns:
file reference to config.xml file
Throws:
org.apache.maven.plugin.MojoExecutionException - thrown if the config file could not be copied to the build directory

getFontsFile

public static java.io.File getFontsFile(org.apache.maven.model.Build build)
                                 throws org.apache.maven.plugin.MojoExecutionException
Returns the file reference to the fonts file. Depending on the os, the correct fonts.ser file is used. The fonts file is copied to the build directory.

Parameters:
build - Build for which to get the fonts file
Returns:
file reference to fonts file
Throws:
org.apache.maven.plugin.MojoExecutionException - thrown if the config file could not be copied to the build directory

getLocaleResourcePath

public static java.io.File getLocaleResourcePath(java.lang.String resourceBundlePath,
                                                 java.lang.String locale)
                                          throws org.apache.maven.plugin.MojoExecutionException
Returns the file reference to a localize resourceBundlePath. Replaces the {locale} variable in the given resourceBundlePath with given locale.

Parameters:
resourceBundlePath - Path to resource bundle.
locale - Locale
Returns:
File reference to the resourceBundlePath for given locale
Throws:
org.apache.maven.plugin.MojoExecutionException - thrown if the resourceBundlePath for given locale can not be found

osString

public static java.lang.String osString()

isWindows

public static boolean isWindows()
Return a boolean to show if we are running on Windows.

Returns:
true if we are running on Windows.

isLinux

public static boolean isLinux()
Return a boolean to show if we are running on Linux.

Returns:
true if we are running on Linux.

isSolaris

public static boolean isSolaris()
Return a boolean to show if we are running on Solaris.

Returns:
true if we are running on Solaris.

isUnixBased

public static boolean isUnixBased()
Return a boolean to show if we are running on a unix-based OS.

Returns:
true if we are running on a unix-based OS.

isMac

public static boolean isMac()
Return a boolean to show if we are running on Mac OS X.

Returns:
true if we are running on Mac OS X.

isWindowsVista

public static boolean isWindowsVista()
Return a boolean to show if we are running on Windows Vista.

Returns:
true if we are running on Windows Vista.

searchFor

public static org.apache.maven.artifact.Artifact searchFor(java.util.Collection<org.apache.maven.artifact.Artifact> artifacts,
                                                           java.lang.String groupId,
                                                           java.lang.String artifactId,
                                                           java.lang.String version,
                                                           java.lang.String type,
                                                           java.lang.String classifier)

getFdkNamespaces

public static java.util.List<Namespace> getFdkNamespaces(java.util.Collection<org.apache.maven.artifact.Artifact> dependencies,
                                                         org.apache.maven.model.Build build)
                                                  throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

getFlexMojosVersion

public static java.lang.String getFlexMojosVersion()


Copyright © 2008-2009 Flex-Mojos. All Rights Reserved.