Class Groovy.Script

  • Enclosing class:
    Groovy

    public abstract static class Groovy.Script
    extends java.lang.Object
    Methods for working with Groovy scripts as application components.
    • Field Detail

      • DEFAULT_HANDLERS_PATH

        public static final java.lang.String DEFAULT_HANDLERS_PATH
        "handlers.groovy"
        See Also:
        Constant Field Values
      • DEFAULT_BINDINGS_PATH

        public static final java.lang.String DEFAULT_BINDINGS_PATH
        "bindings.groovy"
        See Also:
        Constant Field Values
      • DEFAULT_APP_PATH

        public static final java.lang.String DEFAULT_APP_PATH
        "ratpack.groovy"
        See Also:
        Constant Field Values
    • Method Detail

      • checkGroovy

        public static void checkGroovy()
        Asserts that the version of Groovy on the classpath meets the minimum requirement for Ratpack.
      • app

        public static Action<? super RatpackServerSpec> app​(boolean compileStatic)
        Creates an application defining action from a Groovy script named "ratpack.groovy".

        This method returns an action that can be used with RatpackServer.of(Action) to create an application.

        The script should call the Groovy.ratpack(Closure) method.

        Parameters:
        compileStatic - whether to statically compile the script
        Returns:
        an application definition action
      • app

        public static Action<? super RatpackServerSpec> app​(java.nio.file.Path script)
        Creates an application defining action from a Groovy script.

        This method returns an action that can be used with RatpackServer.of(Action) to create an application.

        The script should call the Groovy.ratpack(Closure) method.

        Parameters:
        script - the script
        Returns:
        an application definition action
      • app

        public static Action<? super RatpackServerSpec> app​(boolean compileStatic,
                                                            java.nio.file.Path script)
        Creates an application defining action from a Groovy script.

        This method returns an action that can be used with RatpackServer.of(Action) to create an application.

        The script should call the Groovy.ratpack(Closure) method.

        Parameters:
        compileStatic - whether to statically compile the script
        script - the script
        Returns:
        an application definition action
      • app

        public static Action<? super RatpackServerSpec> app​(boolean compileStatic,
                                                            java.lang.String... scriptPaths)
        Creates an application defining action from a Groovy script.

        This method returns an action that can be used with RatpackServer.of(Action) to create an application.

        The script should call the Groovy.ratpack(Closure) method.

        Parameters:
        compileStatic - whether to statically compile the script
        scriptPaths - the potential paths to the scripts (first existing is used)
        Returns:
        an application definition action
      • appWithArgs

        public static Action<? super RatpackServerSpec> appWithArgs​(java.lang.String... args)
        Creates an application defining action from a Groovy script named "ratpack.groovy"

        This method returns an action that can be used with RatpackServer.of(Action) to create an application.

        The script should call the Groovy.ratpack(Closure) method.

        Parameters:
        args - args to make available to the script via the args variable
        Returns:
        an application definition action
        Since:
        1.1
      • appWithArgs

        public static Action<? super RatpackServerSpec> appWithArgs​(boolean compileStatic,
                                                                    java.nio.file.Path script,
                                                                    java.lang.String... args)
        Creates an application defining action from a Groovy script.

        This method returns an action that can be used with RatpackServer.of(Action) to create an application.

        The script should call the Groovy.ratpack(Closure) method.

        Parameters:
        compileStatic - whether to statically compile the script
        script - the script
        args - args to make available to the script via the args variable
        Returns:
        an application definition action
        Since:
        1.1
      • appWithArgs

        public static Action<? super RatpackServerSpec> appWithArgs​(boolean compileStatic,
                                                                    java.lang.String[] scriptPaths,
                                                                    java.lang.String... args)
        Creates an application defining action from a Groovy script.

        This method returns an action that can be used with RatpackServer.of(Action) to create an application.

        The script should call the Groovy.ratpack(Closure) method.

        Parameters:
        compileStatic - whether to statically compile the script
        scriptPaths - the potential paths to the scripts (first existing is used)
        args - args to make available to the script via the args variable
        Returns:
        an application definition action
        Since:
        1.1
      • handlersWithArgs

        public static Function<Registry,​Handler> handlersWithArgs​(boolean compileStatic,
                                                                        java.lang.String scriptPath,
                                                                        java.lang.String... args)
        Creates a handler defining function from a Groovy script.

        This method returns a function that can be used with RatpackServerSpec.handler(Function) when bootstrapping.

        The script should call the Groovy.ratpack(Closure) method, and only invoke the Groovy.Ratpack.handlers(Closure) method.

        Parameters:
        compileStatic - whether to statically compile the script
        scriptPath - the path to the script
        args - args to make available to the script via the args variable
        Returns:
        a handler definition function
        Since:
        1.1
      • bindingsWithArgs

        public static Function<Registry,​Registry> bindingsWithArgs​(boolean compileStatic,
                                                                         java.lang.String scriptPath,
                                                                         java.lang.String... args)
        Creates a registry building function from a Groovy script.

        This method returns a function that can be used with RatpackServerSpec.registry(Function) when bootstrapping.

        The script should call the Groovy.ratpack(Closure) method, and only invoke the Groovy.Ratpack.bindings(Closure) method.

        Parameters:
        compileStatic - whether to statically compile the script
        scriptPath - the path to the script
        args - args to make available to the script via the args variable
        Returns:
        a registry definition function
        Since:
        1.1