diff --git a/01-build-and-test/build.gradle b/01-build-and-test/build.gradle new file mode 100644 index 0000000..88a6244 --- /dev/null +++ b/01-build-and-test/build.gradle @@ -0,0 +1,15 @@ +apply plugin: 'java' + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'org.testng', name: 'testng', version: '6.+' +} + +test { + useTestNG() +} + + diff --git a/01-build-and-test/src/main/java/Calculator.java b/01-build-and-test/src/main/java/Calculator.java new file mode 100644 index 0000000..b079414 --- /dev/null +++ b/01-build-and-test/src/main/java/Calculator.java @@ -0,0 +1,19 @@ +public class Calculator { + + /** Internal counter */ + private int counter; + + Calculator() { + counter = 0; + } + + + public int getCounter() { + return counter; + } + + void add(int i) { + counter += i; + } +} + diff --git a/01-build-and-test/src/test/java/TestCalculator.java b/01-build-and-test/src/test/java/TestCalculator.java new file mode 100644 index 0000000..31a9f61 --- /dev/null +++ b/01-build-and-test/src/test/java/TestCalculator.java @@ -0,0 +1,13 @@ + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class TestCalculator { + + @Test + public void testAdd() { + Calculator calc = new Calculator(); + calc.add(1); + Assert.assertEquals(calc.getCounter(), 1); + } +} diff --git a/02-pmd/build.gradle b/02-pmd/build.gradle new file mode 100644 index 0000000..7df7a21 --- /dev/null +++ b/02-pmd/build.gradle @@ -0,0 +1,20 @@ +apply plugin: 'java' +apply plugin: 'pmd' + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'org.testng', name: 'testng', version: '6.+' +} + +test { + useTestNG() +} + +pmdMain { + ruleSets = [ "basic", "strings" ] + ignoreFailures = true +} + diff --git a/02-pmd/src/main/java/Calculator.java b/02-pmd/src/main/java/Calculator.java new file mode 100644 index 0000000..a72a831 --- /dev/null +++ b/02-pmd/src/main/java/Calculator.java @@ -0,0 +1,24 @@ +public class Calculator { + + /** Internal counter */ + private int counter; + + Calculator() { + counter = 0; + } + + + public int getCounter() { + return counter; + } + + void add(int i) { + + // Generate PMD warning + if (i==1) { + } + + counter += i; + } +} + diff --git a/02-pmd/src/test/java/TestCalculator.java b/02-pmd/src/test/java/TestCalculator.java new file mode 100644 index 0000000..31a9f61 --- /dev/null +++ b/02-pmd/src/test/java/TestCalculator.java @@ -0,0 +1,13 @@ + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class TestCalculator { + + @Test + public void testAdd() { + Calculator calc = new Calculator(); + calc.add(1); + Assert.assertEquals(calc.getCounter(), 1); + } +} diff --git a/03-checkstyle/build.gradle b/03-checkstyle/build.gradle new file mode 100644 index 0000000..b524138 --- /dev/null +++ b/03-checkstyle/build.gradle @@ -0,0 +1,24 @@ +apply plugin: 'java' +apply plugin: 'pmd' +apply plugin: 'checkstyle' + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'org.testng', name: 'testng', version: '6.+' +} + +test { + useTestNG() +} + +pmdMain { + ruleSets = [ "basic", "strings" ] + ignoreFailures = true +} + +tasks.withType(Checkstyle) { + ignoreFailures = true +} diff --git a/03-checkstyle/config/checkstyle/checkstyle.xml b/03-checkstyle/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000..693f8de --- /dev/null +++ b/03-checkstyle/config/checkstyle/checkstyle.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/03-checkstyle/src/main/java/com/ysoft/training/Calculator.java b/03-checkstyle/src/main/java/com/ysoft/training/Calculator.java new file mode 100644 index 0000000..37f5c4f --- /dev/null +++ b/03-checkstyle/src/main/java/com/ysoft/training/Calculator.java @@ -0,0 +1,29 @@ +package com.ysoft.training; + +// Generate Checkstyle warning - unused import +import java.util.Date; + +public class Calculator { + + /** Internal counter */ + private int counter; + + Calculator() { + counter = 0; + } + + + public int getCounter() { + return counter; + } + + void add(int i) { + + // Generate PMD warning + if (i==1) { + } + + counter += i; + } +} + diff --git a/03-checkstyle/src/test/java/com/ysoft/training/TestCalculator.java b/03-checkstyle/src/test/java/com/ysoft/training/TestCalculator.java new file mode 100644 index 0000000..61962c4 --- /dev/null +++ b/03-checkstyle/src/test/java/com/ysoft/training/TestCalculator.java @@ -0,0 +1,16 @@ +package com.ysoft.training; + +import com.ysoft.training.Calculator; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class TestCalculator { + + @Test + public void testAdd() { + Calculator calc = new Calculator(); + calc.add(1); + Assert.assertEquals(calc.getCounter(), 1); + } +} diff --git a/04-findbugs/build.gradle b/04-findbugs/build.gradle new file mode 100644 index 0000000..6423bdb --- /dev/null +++ b/04-findbugs/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'java' +apply plugin: 'pmd' +apply plugin: 'checkstyle' +apply plugin: 'findbugs' + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'org.testng', name: 'testng', version: '6.+' +} + +test { + useTestNG() +} + +pmdMain { + ruleSets = [ "basic", "strings" ] + ignoreFailures = true +} + +tasks.withType(Checkstyle) { + ignoreFailures = true +} + +tasks.withType(FindBugs) { + reports { + xml.enabled false + html.enabled true + } + ignoreFailures = true + reportLevel = 'low' +} + diff --git a/04-findbugs/config/checkstyle/checkstyle.xml b/04-findbugs/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000..693f8de --- /dev/null +++ b/04-findbugs/config/checkstyle/checkstyle.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/04-findbugs/src/main/java/com/ysoft/training/Calculator.java b/04-findbugs/src/main/java/com/ysoft/training/Calculator.java new file mode 100644 index 0000000..37f5c4f --- /dev/null +++ b/04-findbugs/src/main/java/com/ysoft/training/Calculator.java @@ -0,0 +1,29 @@ +package com.ysoft.training; + +// Generate Checkstyle warning - unused import +import java.util.Date; + +public class Calculator { + + /** Internal counter */ + private int counter; + + Calculator() { + counter = 0; + } + + + public int getCounter() { + return counter; + } + + void add(int i) { + + // Generate PMD warning + if (i==1) { + } + + counter += i; + } +} + diff --git a/04-findbugs/src/test/java/com/ysoft/training/TestCalculator.java b/04-findbugs/src/test/java/com/ysoft/training/TestCalculator.java new file mode 100644 index 0000000..61962c4 --- /dev/null +++ b/04-findbugs/src/test/java/com/ysoft/training/TestCalculator.java @@ -0,0 +1,16 @@ +package com.ysoft.training; + +import com.ysoft.training.Calculator; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class TestCalculator { + + @Test + public void testAdd() { + Calculator calc = new Calculator(); + calc.add(1); + Assert.assertEquals(calc.getCounter(), 1); + } +} diff --git a/05-jdepend/build.gradle b/05-jdepend/build.gradle new file mode 100644 index 0000000..16c6340 --- /dev/null +++ b/05-jdepend/build.gradle @@ -0,0 +1,21 @@ +apply plugin: 'java' +apply plugin: 'jdepend' + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'org.testng', name: 'testng', version: '6.+' +} + +test { + useTestNG() +} + +tasks.withType(JDepend) { + reports { + xml.enabled false + text.enabled true + } +} diff --git a/05-jdepend/src/main/java/com/ysoft/circle/Circulator.java b/05-jdepend/src/main/java/com/ysoft/circle/Circulator.java new file mode 100644 index 0000000..1de414b --- /dev/null +++ b/05-jdepend/src/main/java/com/ysoft/circle/Circulator.java @@ -0,0 +1,14 @@ +package com.ysoft.circle; + +// Create circular dependency for JDepend +import com.ysoft.training.Calculator; + +public class Circulator { + + public int compute() { + Calculator calc = new Calculator(); + calc.add(1); + return calc.getCounter(); + } +} + diff --git a/05-jdepend/src/main/java/com/ysoft/training/Calculator.java b/05-jdepend/src/main/java/com/ysoft/training/Calculator.java new file mode 100644 index 0000000..814d588 --- /dev/null +++ b/05-jdepend/src/main/java/com/ysoft/training/Calculator.java @@ -0,0 +1,37 @@ +package com.ysoft.training; + +// Generate Checkstyle warning - unused import +import java.util.Date; + +// Circular dependency for JDepend +import com.ysoft.circle.Circulator; + +public class Calculator { + + /** Internal counter */ + private int counter; + + public Calculator() { + counter = 0; + } + + + public int getCounter() { + return counter; + } + + public int getCirculator() { + Circulator circ = new Circulator(); + return circ.compute(); + } + + public void add(int i) { + + // Generate PMD warning + if (i==1) { + } + + counter += i; + } +} + diff --git a/05-jdepend/src/test/java/com/ysoft/training/TestCalculator.java b/05-jdepend/src/test/java/com/ysoft/training/TestCalculator.java new file mode 100644 index 0000000..61962c4 --- /dev/null +++ b/05-jdepend/src/test/java/com/ysoft/training/TestCalculator.java @@ -0,0 +1,16 @@ +package com.ysoft.training; + +import com.ysoft.training.Calculator; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class TestCalculator { + + @Test + public void testAdd() { + Calculator calc = new Calculator(); + calc.add(1); + Assert.assertEquals(calc.getCounter(), 1); + } +} diff --git a/06-maven-deployer/build.gradle b/06-maven-deployer/build.gradle new file mode 100644 index 0000000..367e6e0 --- /dev/null +++ b/06-maven-deployer/build.gradle @@ -0,0 +1,28 @@ +apply plugin: 'java' +apply plugin: 'maven' + +version = '0.1-SNAPSHOT' +group = 'com.sinusgear.training' + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'org.testng', name: 'testng', version: '6.+' +} + +test { + useTestNG() +} + +uploadArchives { + repositories { + mavenDeployer { + repository(url: "file:///idea/training/repo") + // use timestamp, e.g.: 06-maven-deployer-0.1-20140408.195954-2 + uniqueVersion = true + } + } +} + diff --git a/06-maven-deployer/src/main/java/com/ysoft/training/Calculator.java b/06-maven-deployer/src/main/java/com/ysoft/training/Calculator.java new file mode 100644 index 0000000..37f5c4f --- /dev/null +++ b/06-maven-deployer/src/main/java/com/ysoft/training/Calculator.java @@ -0,0 +1,29 @@ +package com.ysoft.training; + +// Generate Checkstyle warning - unused import +import java.util.Date; + +public class Calculator { + + /** Internal counter */ + private int counter; + + Calculator() { + counter = 0; + } + + + public int getCounter() { + return counter; + } + + void add(int i) { + + // Generate PMD warning + if (i==1) { + } + + counter += i; + } +} + diff --git a/06-maven-deployer/src/test/java/com/ysoft/training/TestCalculator.java b/06-maven-deployer/src/test/java/com/ysoft/training/TestCalculator.java new file mode 100644 index 0000000..61962c4 --- /dev/null +++ b/06-maven-deployer/src/test/java/com/ysoft/training/TestCalculator.java @@ -0,0 +1,16 @@ +package com.ysoft.training; + +import com.ysoft.training.Calculator; + +import org.testng.Assert; +import org.testng.annotations.Test; + +public class TestCalculator { + + @Test + public void testAdd() { + Calculator calc = new Calculator(); + calc.add(1); + Assert.assertEquals(calc.getCounter(), 1); + } +}