mirror of
https://github.com/ysoftdevs/gradle-training.git
synced 2026-04-11 03:07:11 +02:00
add sample for debugging gradle script
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'pmd'
|
apply plugin: 'pmd'
|
||||||
apply plugin: 'checkstyle'
|
apply plugin: 'checkstyle'
|
||||||
|
|
||||||
|
// Documentation: http://www.gradle.org/docs/current/dsl/org.gradle.api.plugins.quality.FindBugsExtension.html
|
||||||
apply plugin: 'findbugs'
|
apply plugin: 'findbugs'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
15
16-stop-build/build.gradle
Normal file
15
16-stop-build/build.gradle
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
task workingTask {
|
||||||
|
description 'Task that works'
|
||||||
|
doLast {
|
||||||
|
println 'Everything is ok'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task failingTask {
|
||||||
|
description 'Task that fails'
|
||||||
|
doLast {
|
||||||
|
throw new GradleException("Problem detected. Build failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
9
17-testng-groovy/build.gradle
Normal file
9
17-testng-groovy/build.gradle
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
apply plugin: 'groovy'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile gradleApi()
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useTestNG()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.ysoft.training
|
||||||
|
|
||||||
|
class Calculator {
|
||||||
|
int add(x, y) {
|
||||||
|
return x+y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import com.ysoft.training.Calculator
|
||||||
|
|
||||||
|
import org.testng.annotations.Test
|
||||||
|
import org.testng.Assert
|
||||||
|
|
||||||
|
class CalculatorTest {
|
||||||
|
@Test
|
||||||
|
void stitchInTimeSavesNine() {
|
||||||
|
def calculator = new Calculator()
|
||||||
|
Assert.assertEquals(calculator.add(4,5), 9)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
21
README.md
21
README.md
@@ -164,7 +164,25 @@ Plugin is just counting lines in build.gradle file in current directory.
|
|||||||
gradle tasks
|
gradle tasks
|
||||||
gradle countLines
|
gradle countLines
|
||||||
|
|
||||||
## 16-debug-gradle-script
|
## 16-stop-build
|
||||||
|
|
||||||
|
It is possible to stop build by throwing exception.
|
||||||
|
|
||||||
|
gradle workingTask
|
||||||
|
gradle failingTask
|
||||||
|
|
||||||
|
|
||||||
|
## 17-testng-groovy
|
||||||
|
|
||||||
|
Example combines usage of TestNG for testing and tests written in Groovy.
|
||||||
|
It is necessary to declare 'useTestNG()' in test configuration.
|
||||||
|
Otherwise tests won't be executed.
|
||||||
|
|
||||||
|
gradle test
|
||||||
|
|
||||||
|
Reports are stored in build/reports/tests/index.html
|
||||||
|
|
||||||
|
## 18-debug-gradle-script
|
||||||
|
|
||||||
Do not run in daemon mode.
|
Do not run in daemon mode.
|
||||||
Set environment variable GRADLE_OPTS to
|
Set environment variable GRADLE_OPTS to
|
||||||
@@ -178,3 +196,4 @@ Start gradle task
|
|||||||
Attach remote debugger from Ide.
|
Attach remote debugger from Ide.
|
||||||
|
|
||||||
More information: http://georgik.sinusgear.com/2014/06/23/how-to-debug-gradle-script/
|
More information: http://georgik.sinusgear.com/2014/06/23/how-to-debug-gradle-script/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user