Просмотр исходного кода

build: Extract common config to top-level build.gradle

We can inject plugin, repositories and dependencies directly from
the top-level build.gradle.

This extracts a common version of junit for all projects (and
updates anagram to use assertj, the junit matchers did not work
with 4.12).
Emil Sit 10 лет назад
Родитель
Сommit
3fdc2d1b9c

+ 0
- 11
_template/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
accumulate/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
allergies/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
anagram/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 14
- 15
anagram/src/test/java/AnagramTest.java Просмотреть файл

1
-import static org.hamcrest.CoreMatchers.*;
2
-import static org.junit.matchers.JUnitMatchers.*;
3
-import static org.junit.Assert.*;
1
+import static org.assertj.core.api.Assertions.assertThat;
4
 
2
 
5
-import java.util.*;
6
-import org.junit.*;
3
+import java.util.Arrays;
4
+import java.util.List;
5
+import org.junit.Test;
7
 
6
 
8
 public class AnagramTest {
7
 public class AnagramTest {
9
 
8
 
10
     @Test
9
     @Test
11
     public void testNoMatches() {
10
     public void testNoMatches() {
12
         Anagram detector = new Anagram("diaper");
11
         Anagram detector = new Anagram("diaper");
13
-        assertTrue(detector.match(Arrays.asList("hello", "world", "zombies", "pants")).isEmpty());
12
+        assertThat(detector.match(Arrays.asList("hello", "world", "zombies", "pants"))).isEmpty();
14
     }
13
     }
15
 
14
 
16
     @Test
15
     @Test
17
     public void testSimpleAnagram() {
16
     public void testSimpleAnagram() {
18
         Anagram detector = new Anagram("ant");
17
         Anagram detector = new Anagram("ant");
19
         List<String> anagram = detector.match(Arrays.asList("tan", "stand", "at"));
18
         List<String> anagram = detector.match(Arrays.asList("tan", "stand", "at"));
20
-        assertThat(anagram, hasItems("tan"));
19
+        assertThat(anagram).containsExactly("tan");
21
     }
20
     }
22
 
21
 
23
     @Test
22
     @Test
24
     public void testDetectMultipleAnagrams() {
23
     public void testDetectMultipleAnagrams() {
25
         Anagram detector = new Anagram("master");
24
         Anagram detector = new Anagram("master");
26
         List<String> anagrams = detector.match(Arrays.asList("stream", "pigeon", "maters"));
25
         List<String> anagrams = detector.match(Arrays.asList("stream", "pigeon", "maters"));
27
-        assertThat(anagrams, hasItems("maters", "stream"));
26
+        assertThat(anagrams).contains("maters", "stream");
28
     }
27
     }
29
 
28
 
30
     @Test
29
     @Test
31
     public void testDoesNotConfuseDifferentDuplicates() {
30
     public void testDoesNotConfuseDifferentDuplicates() {
32
         Anagram detector = new Anagram("galea");
31
         Anagram detector = new Anagram("galea");
33
         List<String> anagrams = detector.match(Arrays.asList("eagle"));
32
         List<String> anagrams = detector.match(Arrays.asList("eagle"));
34
-        assertTrue(anagrams.isEmpty());
33
+        assertThat(anagrams).isEmpty();
35
     }
34
     }
36
 
35
 
37
     @Test
36
     @Test
38
     public void testIdenticalWordIsNotAnagram() {
37
     public void testIdenticalWordIsNotAnagram() {
39
         Anagram detector = new Anagram("corn");
38
         Anagram detector = new Anagram("corn");
40
         List<String> anagrams = detector.match(Arrays.asList("corn", "dark", "Corn", "rank", "CORN", "cron", "park"));
39
         List<String> anagrams = detector.match(Arrays.asList("corn", "dark", "Corn", "rank", "CORN", "cron", "park"));
41
-        assertEquals(anagrams, Arrays.asList("cron"));
40
+        assertThat(anagrams).containsExactly("cron");
42
     }
41
     }
43
 
42
 
44
     @Test
43
     @Test
45
     public void testEliminateAnagramsWithSameChecksum() {
44
     public void testEliminateAnagramsWithSameChecksum() {
46
         Anagram detector = new Anagram("mass");
45
         Anagram detector = new Anagram("mass");
47
-        assertTrue(detector.match(Arrays.asList("last")).isEmpty());
46
+        assertThat(detector.match(Arrays.asList("last")).isEmpty());
48
     }
47
     }
49
 
48
 
50
     @Test
49
     @Test
51
     public void testEliminateAnagramSubsets() {
50
     public void testEliminateAnagramSubsets() {
52
         Anagram detector = new Anagram("good");
51
         Anagram detector = new Anagram("good");
53
-        assertTrue(detector.match(Arrays.asList("dog", "goody")).isEmpty());
52
+        assertThat(detector.match(Arrays.asList("dog", "goody"))).isEmpty();
54
     }
53
     }
55
 
54
 
56
     @Test
55
     @Test
57
     public void testDetectAnagrams() {
56
     public void testDetectAnagrams() {
58
         Anagram detector = new Anagram("listen");
57
         Anagram detector = new Anagram("listen");
59
         List<String> anagrams = detector.match(Arrays.asList("enlists", "google", "inlets", "banana"));
58
         List<String> anagrams = detector.match(Arrays.asList("enlists", "google", "inlets", "banana"));
60
-        assertThat(anagrams, hasItems("inlets"));
59
+        assertThat(anagrams).contains("inlets");
61
     }
60
     }
62
 
61
 
63
     @Test
62
     @Test
64
     public void testMultipleAnagrams() {
63
     public void testMultipleAnagrams() {
65
         Anagram detector = new Anagram("allergy");
64
         Anagram detector = new Anagram("allergy");
66
         List<String> anagrams = detector.match(Arrays.asList("gallery", "ballerina", "regally", "clergy", "largely", "leading"));
65
         List<String> anagrams = detector.match(Arrays.asList("gallery", "ballerina", "regally", "clergy", "largely", "leading"));
67
-        assertThat(anagrams, hasItems("gallery", "largely", "regally"));
66
+        assertThat(anagrams).contains("gallery", "largely", "regally");
68
     }
67
     }
69
 
68
 
70
     @Test
69
     @Test
71
     public void testAnagramsAreCaseInsensitive() {
70
     public void testAnagramsAreCaseInsensitive() {
72
         Anagram detector = new Anagram("Orchestra");
71
         Anagram detector = new Anagram("Orchestra");
73
         List<String> anagrams = detector.match(Arrays.asList("cashregister", "Carthorse", "radishes"));
72
         List<String> anagrams = detector.match(Arrays.asList("cashregister", "Carthorse", "radishes"));
74
-        assertThat(anagrams, hasItems("Carthorse"));
73
+        assertThat(anagrams).contains("Carthorse");
75
     }
74
     }
76
 
75
 
77
 }
76
 }

+ 0
- 11
atbash-cipher/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
binary/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
bob/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 11
- 0
build.gradle Просмотреть файл

1
 subprojects { project ->
1
 subprojects { project ->
2
   apply plugin: "java"
2
   apply plugin: "java"
3
+  apply plugin: "eclipse"
4
+  apply plugin: "idea"
5
+
6
+  repositories {
7
+    mavenCentral()
8
+  }
9
+
10
+  dependencies {
11
+    testCompile "junit:junit:4.12"
12
+    testCompile 'org.assertj:assertj-core:2.2.0'
13
+  }
3
 
14
 
4
   sourceSets {
15
   sourceSets {
5
     // Verify that the tests are working by running them against the example code.
16
     // Verify that the tests are working by running them against the example code.

+ 0
- 11
crypto-square/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 9
etl/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
 dependencies {
1
 dependencies {
10
-  testCompile "junit:junit:4.10"
11
   testCompile "org.easytesting:fest-assert-core:2.0M10"
2
   testCompile "org.easytesting:fest-assert-core:2.0M10"
12
   testCompile "com.google.guava:guava:16+"
3
   testCompile "com.google.guava:guava:16+"
13
 }
4
 }

+ 0
- 11
gigasecond/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 9
grade-school/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
 dependencies {
1
 dependencies {
10
-  testCompile "junit:junit:4.10"
11
   testCompile "org.easytesting:fest-assert-core:2.0M10"
2
   testCompile "org.easytesting:fest-assert-core:2.0M10"
12
 }
3
 }

+ 0
- 11
hamming/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 12
hello-world/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}
12
-

+ 0
- 11
luhn/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 9
meetup/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
 dependencies {
1
 dependencies {
10
   compile "joda-time:joda-time:2.3+"
2
   compile "joda-time:joda-time:2.3+"
11
-  testCompile "junit:junit:4.10"
12
   testCompile "org.easytesting:fest-assert-core:2.0M10"
3
   testCompile "org.easytesting:fest-assert-core:2.0M10"
13
 }
4
 }

+ 0
- 9
nucleotide-count/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
 dependencies {
1
 dependencies {
10
-  testCompile "junit:junit:4.10"
11
   testCompile "org.easytesting:fest-assert-core:2.0M10"
2
   testCompile "org.easytesting:fest-assert-core:2.0M10"
12
 }
3
 }

+ 0
- 11
octal/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
pangram/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
pascals-triangle/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
phone-number/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
pig-latin/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 12
prime-factors/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.12"
11
-}
12
-

+ 0
- 11
raindrops/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
rna-transcription/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 12
robot-name/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}
12
-

+ 0
- 11
roman-numerals/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
scrabble-score/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
sieve/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
simple-cipher/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
space-age/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
strain/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
triangle/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
trinary/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}

+ 0
- 11
word-count/build.gradle Просмотреть файл

1
-apply plugin: "java"
2
-apply plugin: "eclipse"
3
-apply plugin: "idea"
4
-
5
-repositories {
6
-  mavenCentral()
7
-}
8
-
9
-dependencies {
10
-  testCompile "junit:junit:4.10"
11
-}