Setting options for Gosu command prompt compilation

The gwb compile command provides multiple options that modify the behavior of the Gosu compiler. These configuration options apply only to the gwb compile command. The compilation tools that Guidewire Studio provides do not use these options. For example, if you make changes to your Gosu code that might cause many compilation errors or warnings, you can set options to terminate the compilation after reaching a threshold.

To set Gosu command-prompt compilation options, you edit the build.gradle file in the PolicyCenter configuration folder. You add the configuration options and values at the top of the file, similar to the following lines:

// Add custom project specific configuration here if needed
tasks.compileGosu.gosuOptions.failOnError = false

The following table lists and describes the available configuration options for Gosu compilation.

Configuration option

Default value

Description

tasks.compileGosu.gosuOptions.checkedArithmetic

false

Supports enabling checked arithmetic, which generates Gosu exceptions for nu.meric overflow errors

tasks.compileGosu.gosuOptions.failOnError

true

Supports terminating a compilation task if the number of errors exceeds the value that maxErrs specifies.

tasks.compileGosu.gosuOptions.maxErrs

100

Specifies the permitted number of compilation errors after which the compilation task fails if failOnError is set to true. The compilation task checks this value after compiling each file and terminates if the number of errors is greater than this value. If a file generates multiple compilation errors, the reported number of errors can be more than one greater than this option value.

tasks.compileGosu.gosuOptions.maxWarns

Integer.maxInt

Specifies the permitted number of compilation warnings after which the compilation task fails if warnings is set to true. The compilation task checks this value after compiling each file and terminates if the number of warnings is greater than this value. If a file generates multiple compilation warnings, the reported number of warnings can be more than one greater than this option value.

tasks.compileGosu.gosuOptions.verbose

false

Specifies whether to print a message to the log for every file that the task compiles.

tasks.compileGosu.options.warnings

false

Supports terminating a compilation task if the number of warnings exceeds the value that maxWarns specifies.

Examples

Each example stands alone. Remove the line or lines that you added for one example before you try the next example.

  • Add the following line to the top of the build.gradle file.
    tasks.compileGosu.gosuOptions.checkedArithmetic = true

    At the command prompt run the gwb compile command. When you run a compiled class that causes a numeric overflow, the class throws an arithmetic exception and terminates.

  • Add the following line to the top of the build.gradle file.
    tasks.compileGosu.gosuOptions.failOnError = false

    At the command prompt run the gwb compile command. Even if there are multiple compilation errors, the task ignores the maxErrs option and compiles all available Gosu classes. Output similar to the following lines appears.

      Error threshold of 10 exceeded; aborting compilation.
      gosuc completed with 12 errors. Warnings were disabled.
    
       :modules:configuration:compileGosu completed with errors, but ignoring as 'gosuO
      ptions.failOnError = false' was specified.
  • Add the following lines to the top of the build.gradle file.
      tasks.compileGosu.gosuOptions.failOnError = true
      tasks.compileGosu.gosuOptions.maxErrs = 10

    At the command prompt run the gwb compile command. If the number of compilation errors after completing compilation of any Gosu file is greater than maxErrs, the compilation task terminates. Output similar to the following lines appears.

      Error threshold of 10 exceeded; aborting compilation.
      gosuc completed with 12 errors. Warnings were disabled.
    
     
       :modules:configuration:compileGosu FAILED
    
       FAILURE: Build failed with an exception.
    
       * What went wrong:
      Execution failed for task ':modules:configuration:compileGosu'.
      > Compilation failed with exit code 1; see the compiler error output for details.
  • Add the following line to the top of the build.gradle file.
      tasks.compileGosu.options.warnings = true
      tasks.compileGosu.gosuOptions.maxWarns = 100

    At the command prompt run the gwb compile command. If the number of compilation warnings after completing compilation of any Gosu file is greater than maxWarns, the compilation task terminates. Output similar to the following lines appears.

      Warning threshold of 100 exceeded; aborting compilation.
      gosuc completed with 129 warnings and 0 errors.
    
     
       :modules:configuration:compileGosu FAILED
    
       FAILURE: Build failed with an exception.
    
       * What went wrong:
      Execution failed for task ':modules:configuration:compileGosu'.
      > Compilation failed with exit code 1; see the compiler error output for details.
  • Add the following line to the top of the build.gradle file.
    tasks.compileGosu.gosuOptions.verbose = true

    At the command prompt run the gwb compile command. Output similar to the following lines appears.

    gosuc: about to compile file: C:\Guidewire\PolicyCenter\modules\configuration\gsrc\gw\policy
            \PolicyPeriodSearchCriteria.gs
    gosuc: about to compile file: C:\Guidewire\PolicyCenter\modules\configuration\gsrc\gw\policy
            \PolicyPeriodSideBySideEnhancement.gsx

See also