Build.gradle: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Replaced content with "=Internal=")
Line 1: Line 1:
 
=Internal=
 
 
=Respond to Build Lifecycle Events=
 
Example of how to respond to [[Gradle_Concepts_ToDeplete#Build_Phases|project build lifecycle events]].
 
<syntaxhighlight lang='groovy'>
allprojects {
      afterEvaluate { project ->
          if (project.hasTests) {
              println "Adding test task to $project"
              project.task('test') {
                  doLast {
                        println "running tests for $project"
                  }
              }
          }
    }
}
</syntaxhighlight>
 
<syntaxhighlight lang='groovy'>
gradle.afterProject {project, projectState ->
      if (projectState.failure) {
          println "Evaluation of $project FAILED"
      } else {
          println "Evaluation of $project succeeded"
      }
}
</syntaxhighlight>

Revision as of 20:37, 23 September 2020

Internal