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 Details

    • MD5_FILE

      public static final String 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

      @Parameter(property="python.binary", required=false, defaultValue="") private String 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.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • isContained

      private static boolean isContained(String text, String[] substrings)
      Returns whether at least one of the substrings are contained in text.
      Parameters:
      text - the text to search for
      substrings - the substrings
      Returns:
      true if at least one of substrings is contained in text
    • runPythonTest

      public static String runPythonTest(String[] cmd)
      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

      static String readProcessOutput(InputStream stream) throws IOException
      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

      static List<File> getAllPythonFiles(String directory, boolean recurse)
      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

      public File getHashFile()
      Returns the file containing the MD5 hashes of known Python files.
      Returns:
      the hash