eu.lindenbaum.maven.util
Class MojoUtils

java.lang.Object
  extended by eu.lindenbaum.maven.util.MojoUtils

public final class MojoUtils
extends Object

Containing utilities related to maven-erlang-plugin specific Mojos.

Since:
2.0.0
Author:
Olle Törnström , Sven Heyll , Tobias Schlager

Constructor Summary
MojoUtils()
           
 
Method Summary
static void emitBackendLogInfo(org.apache.maven.plugin.logging.Log log, File backendLog)
          Emits an info that backend node output is available in the given file if existing.
static Map<String,String> getApplicationReplacements(Properties p)
          Returns a mapping of string replacements for application projects.
static List<File> getEunitTestSet(Collection<File> tests, Collection<File> excludes)
          Filters a given list of compiled test files and returns a list of files that must be run (using eunit) to cover all modules that could possibly contain tests.
static boolean isWindows()
          Returns whether the executing JVM is running under Microsoft Windows or not.
static boolean newerFilesThan(File reference, Collection<File> dirs)
          Returns whether there are erlang source/header files in a specific directory (recursive) having a newer modification time than a given reference file.
static Collection<String> parseDialyzerOutput(String[] output, Collection<File> sources)
          Parses the output of the DialyzerScript and converts it to a beautified Collection of strings to be logged.
static void startBackend(org.apache.maven.plugin.logging.Log log, String cmd, String nodeName, String nodeCookie, File cwd, File backendLog)
          Attaches the plugin to a backend erlang node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MojoUtils

public MojoUtils()
Method Detail

isWindows

public static boolean isWindows()
                         throws org.apache.maven.plugin.MojoExecutionException
Returns whether the executing JVM is running under Microsoft Windows or not.

Returns:
true on Microsoft Windows systems, false otherwise
Throws:
org.apache.maven.plugin.MojoExecutionException - in case the 'os.name' property is not set

startBackend

public static void startBackend(org.apache.maven.plugin.logging.Log log,
                                String cmd,
                                String nodeName,
                                String nodeCookie,
                                File cwd,
                                File backendLog)
                         throws org.apache.maven.plugin.MojoExecutionException
Attaches the plugin to a backend erlang node. If the backend node is not already running it will be started.

Parameters:
log - logger to use
cmd - path to the erl command
nodeName - name of the backend to connect to
nodeCookie - cookie of the backend to connect to
cwd - the backend node's current working directory
backendLog - file to write the ouput from the backend nodes to
Throws:
org.apache.maven.plugin.MojoExecutionException

newerFilesThan

public static boolean newerFilesThan(File reference,
                                     Collection<File> dirs)
Returns whether there are erlang source/header files in a specific directory (recursive) having a newer modification time than a given reference file.

Parameters:
reference - the file taken as reference time (modified)
dirs - input directories to check
Returns:
true if there are .erl/.hrl files newer than the reference file

parseDialyzerOutput

public static Collection<String> parseDialyzerOutput(String[] output,
                                                     Collection<File> sources)
Parses the output of the DialyzerScript and converts it to a beautified Collection of strings to be logged.

Parameters:
output - the dialyzers warning output
sources - a complete collection of source files dialyzer was run on
Returns:
a list of warning strings that can be logged

getEunitTestSet

public static List<File> getEunitTestSet(Collection<File> tests,
                                         Collection<File> excludes)
Filters a given list of compiled test files and returns a list of files that must be run (using eunit) to cover all modules that could possibly contain tests. In fact this will remove a module ending with _tests.beam from the list whenever another module is contained without this suffix (the according test will be run by eunit automatically). The input list will not be modified.

Parameters:
tests - list of test modules to find the tests to execute for.
excludes - list of infrastructure modules that should be excluded from test execution
Returns:
a non-null list of test modules

getApplicationReplacements

public static Map<String,String> getApplicationReplacements(Properties p)
                                                     throws org.apache.maven.plugin.MojoExecutionException
Returns a mapping of string replacements for application projects. The replacements will contain all mappings returned by MavenUtils#getProjectReplacements(org.apache.maven.project.MavenProject) and the following additional mappings: Note: The compile phase must have run to be able to call this function.

Parameters:
p - the build properties
Returns:
a non-null Map of string mappings
Throws:
org.apache.maven.plugin.MojoExecutionException - when failing to get module attributes

emitBackendLogInfo

public static void emitBackendLogInfo(org.apache.maven.plugin.logging.Log log,
                                      File backendLog)
Emits an info that backend node output is available in the given file if existing.

Parameters:
log - logger to use
backendLog - referring to the backend log file.


Copyright © 2012 Lindenbaum GmbH. All Rights Reserved.