Class PythonCompileMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
de.iip_ecosphere.platform.tools.maven.python.AbstractLoggingMojo
de.iip_ecosphere.platform.tools.maven.python.PythonCompileMojo
- All Implemented Interfaces:
Logger,org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="compile-python",
defaultPhase=COMPILE)
public class PythonCompileMojo
extends AbstractLoggingMojo
Python compiler Mojo plugin.
- Author:
- Alexander Weber, SSE, Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Stringprivate Stringstatic final Stringprivate org.apache.maven.project.MavenProjectprivate Stringprivate Stringprivate booleanprivate booleanFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()getAllPythonFiles(String directory, boolean recurse) Give a list of files in a directory.Returns the file containing the MD5 hashes of known Python files.private voidOutputsflist.private static booleanisContained(String text, String[] substrings) Returns whether at least one of thesubstringsare contained intext.private booleanReturns whether the given line seems to indicate an error, not a warning.private static String[]Joins anarrayand alistto an array.private intmaxCmdLength(String pythonExecutable, String separator) Estimates the maximum command line length.(package private) static StringreadProcessOutput(InputStream stream) Shall take in input stream of processes to collect console output.static StringrunPythonTest(String[] cmd) Running the syntax check for the python Files.Methods inherited from class de.iip_ecosphere.platform.tools.maven.python.AbstractLoggingMojo
error, error, info, warnMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
MD5_FILE
- See Also:
-
project
@Parameter(defaultValue="${project}", required=true, readonly=true) private org.apache.maven.project.MavenProject project -
failOnError
@Parameter(property="python-compile.failOnError", defaultValue="true") private boolean failOnError -
skip
@Parameter(property="python-compile.skip", required=false, defaultValue="false") private boolean skip -
useHash
@Parameter(property="python-compile.useHash", required=false, defaultValue="true") private boolean useHash -
hashDir
@Parameter(property="python-compile.hashDir", required=false, defaultValue="") private String hashDir -
ignoreText
@Parameter(property="python-compile.ignoreText", required=false, defaultValue="imported but unused;is assigned to but never used;redefinition of unused;is unused:;SyntaxWarning: invalid escape sequence") private String ignoreText -
python
-
pythonArgs
-
-
Constructor Details
-
PythonCompileMojo
public PythonCompileMojo()
-
-
Method Details
-
maxCmdLength
Estimates the maximum command line length.- Parameters:
pythonExecutable- the python executable to useseparator- the separator between arguments- Returns:
- the maximum command line length
-
info
Outputsflist.- Parameters:
flist- the files list to be emitted
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
join
Joins anarrayand alistto an array.- Parameters:
array- the array, may be nulllist- the list (may be null- Returns:
- the joined array
-
isError
Returns whether the given line seems to indicate an error, not a warning.- Parameters:
line- the output line- Returns:
truefor error,falsefor not error/potential warning
-
isContained
Returns whether at least one of thesubstringsare contained intext.- Parameters:
text- the text to search forsubstrings- the substrings- Returns:
trueif at least one ofsubstringsis contained intext
-
runPythonTest
Running the syntax check for the python Files.- Parameters:
cmd- the command to run, either utilising pyflaks or py_compile- Returns:
- The output to add to the other outputs
-
readProcessOutput
Shall take in input stream of processes to collect console output.- Parameters:
stream- Process to be observed.- Returns:
- The read Lines from the process.
- Throws:
IOException- If the reading of the lines does fail.
-
getAllPythonFiles
Give a list of files in a directory.- Parameters:
directory- the path to the directory as String.recurse- if all nested directories shall be considered or if only the files in the top-level directory shall be returned- Returns:
- list of files in directory
-
getHashFile
Returns the file containing the MD5 hashes of known Python files.- Returns:
- the hash
-