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 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 static booleanisContained(String text, String[] substrings) Returns whether at least one of thesubstringsare contained intext.(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") private String ignoreText -
python
-
-
Constructor Details
-
PythonCompileMojo
public PythonCompileMojo()
-
-
Method Details
-
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
-
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
-