Class Scriptlet

java.lang.Object
org.codehaus.mojo.rpm.Scriptlet
Direct Known Subclasses:
BaseTrigger

public class Scriptlet extends Object
Defines a scriptlet including the optinal getSubpackage() and getProgram(). The (optional) contents can be provided by either getScript() or getScriptFile().
Since:
2.0-beta-4
Author:
Brett Okken, Cerner Corp.
  • Constructor Details

    • Scriptlet

      public Scriptlet()
  • Method Details

    • getSubpackage

      public String getSubpackage()
      The optional subpackage. This is passed as a -n argument to the scriptlet directive.
      Returns:
      Returns the subpackage.
    • setSubpackage

      public void setSubpackage(String subpackage)
      Parameters:
      subpackage - The subpackage to set.
    • getProgram

      public String getProgram()
      The program to use to execute the script. This is passed as a -p argument to the scriptlet directive.
      Returns:
      Returns the program.
    • setProgram

      public void setProgram(String program)
      Parameters:
      program - The program to set.
    • getScript

      public String getScript()
      The contents of the script as a String. This value will override anything at getScriptFile().
      Returns:
      Returns the script.
    • setScript

      public void setScript(String script)
      Parameters:
      script - The script to set.
    • getScriptFile

      public String getScriptFile()
      The location of the script: a file path (absolute, or relative to the project base directory) or, with the prefix classpath:, a resource on the plugin class path, for example a script shipped in a jar that is added to the plugin's dependencies. This is ignored if getScript() is populated.
      Returns:
      Returns the scriptFile.
      Since:
      2.5.0 the classpath: prefix, and the return type String instead of File
    • setScriptFile

      public void setScriptFile(String scriptFile)
      Parameters:
      scriptFile - The scriptFile to set.
    • getFileEncoding

      public String getFileEncoding()
      The encoding to use to read getScriptFile(). If null, the default character encoding for th platform will be used.
      Returns:
      Returns the fileEncoding.
    • setFileEncoding

      public void setFileEncoding(String fileEncoding)
      Parameters:
      fileEncoding - The fileEncoding to set.
    • setSourceEncoding

      public void setSourceEncoding(String sourceEncoding)
      This is the maven property: project.build.sourceEncoding
      Parameters:
      sourceEncoding - The sourceEncoding to set.
    • isFilter

      public boolean isFilter()
      Returns:
      Returns the filter.
    • setFilter

      public void setFilter(boolean filter)
      Parameters:
      filter - The filter to set.
    • write

      protected final void write(PrintWriter writer, String directive, AbstractRPMMojo mojo) throws IOException
      Writes the scriptlet.
      Parameters:
      writer - PrintWriter to write content to.
      directive - The directive for the scriptlet.
      mojo - the AbstractRPMMojo which contains any resources needed when writing the scriptlet.
      Throws:
      IOException - if an I/IO error occurs
    • buildScriptletLine

      protected String buildScriptletLine(String directive)
      Builds the scriptlet line including any optional args.
      Parameters:
      directive - The directive for the scriptlet.
      Returns:
      The scriptlet line - this does not include the script.
    • writeContent

      protected final void writeContent(PrintWriter writer, AbstractRPMMojo mojo) throws IOException
      Writes the content (either getScript() or getScriptFile()) to writer.
      Parameters:
      writer - PrintWriter to write content to.
      mojo - the AbstractRPMMojo which contains any resources needed when writing the scriptlet.
      Throws:
      IOException - if an I/IO error occurs
    • toString

      public String toString()
      Overrides:
      toString in class Object