In Gradle, how to print out a message in the console / Event Log?

后端 未结 3 1230
难免孤独
难免孤独 2021-02-02 05:15

I\'m trying to verify that my source and target paths are properly setup when I execute a deploy command.

See the example below:
(copied from: http://eppz.eu/blog/u

相关标签:
3条回答
  • 2021-02-02 05:47

    Basically you can print out a message by this gradle script -

     println "This is a simple gradle message"
    

    but if you want to print a variable in the message then you can do it by the following code

    def variable = "This is a simple variable"
    
    println "Message: ${variable}"
    
    0 讨论(0)
  • 2021-02-02 05:53

    Gradle scripts are written in Groovy language. It is possible to log into console your own messages.

    If your Gradle version of your project is 3.2.1 or above then there is a simple option for logging in your build file which is to write messages to standard output. Gradle redirects anything written to standard output to it's logging system.

    Example

    println 'A message which is logged at QUIET level'
    

    Gradle logging system allows us to log message into multiple log levels (LIFECYCLE, QUIET, INFO, DEBUG )

    Please go through below link for detailed study

    https://docs.gradle.org/current/userguide/logging.html

    0 讨论(0)
  • 2021-02-02 05:58

    Gradle utilizes a logging framework. You can log messages to that. By default, only log level lifecycle and above are shown, but you can log at other levels such as debug and info.

    To log at debug level (visible with builds using gradle --debug or lower)

    project.logger.debug('my debug message')
    

    To log at info level (visible with gradle --info builds and lower)

    project.logger.info('my info message')
    

    To log at lifecycle level (visible by default)

    project.logger.lifecycle('my message visible by default')
    
    0 讨论(0)
提交回复
热议问题