|
1 |
| -package com.diffplug.atplug.tooling.gradle |
2 |
| - |
3 |
| -import com.diffplug.atplug.tooling.PlugGeneratorTest |
4 |
| -import java.io.File |
5 |
| -import java.nio.charset.StandardCharsets |
6 |
| -import java.nio.file.Files |
7 |
| -import org.junit.jupiter.api.Test |
8 |
| - |
9 |
| -class PlugPluginTest : GradleIntegrationHarness() { |
10 |
| - @Test |
11 |
| - fun test() { |
12 |
| - val runtimeJar = PlugGeneratorTest.findRuntimeJar().canonicalPath.replace('\\', '/') |
13 |
| - setFile("build.gradle") |
14 |
| - .toContent( |
15 |
| - """ |
16 |
| - plugins { |
17 |
| - id 'org.jetbrains.kotlin.jvm' version '1.8.0' |
18 |
| - id 'com.diffplug.atplug' |
19 |
| - } |
20 |
| - repositories { |
21 |
| - mavenCentral() |
22 |
| - } |
23 |
| - dependencies { |
24 |
| - implementation files("$runtimeJar") |
25 |
| - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1" |
26 |
| - } |
27 |
| - """ |
28 |
| - .trimIndent()) |
29 |
| - |
30 |
| - val copy = { str: String -> |
31 |
| - val src = File("../atplug-runtime/src/test/java/com/diffplug/atplug/$str") |
32 |
| - setFile("src/main/java/com/diffplug/atplug/$str") |
33 |
| - .toContent(String(Files.readAllBytes(src.toPath()), StandardCharsets.UTF_8)) |
34 |
| - } |
35 |
| - copy("Fruit.kt") |
36 |
| - copy("Shape.java") |
37 |
| - |
38 |
| - gradleRunner().withArguments("jar", "--stacktrace").build() |
39 |
| - |
40 |
| - assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Apple.json") |
41 |
| - .hasContent( |
42 |
| - "{\n" + |
43 |
| - " \"implementation\": \"com.diffplug.atplug.Apple\",\n" + |
44 |
| - " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + |
45 |
| - " \"properties\": {\n" + |
46 |
| - " \"id\": \"Apple\"\n" + |
47 |
| - " }\n" + |
48 |
| - "}") |
49 |
| - assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Orange.json") |
50 |
| - .hasContent( |
51 |
| - "{\n" + |
52 |
| - " \"implementation\": \"com.diffplug.atplug.Orange\",\n" + |
53 |
| - " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + |
54 |
| - " \"properties\": {\n" + |
55 |
| - " \"id\": \"Orange\"\n" + |
56 |
| - " }\n" + |
57 |
| - "}") |
58 |
| - assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json") |
59 |
| - .hasContent( |
60 |
| - "{\n" + |
61 |
| - " \"implementation\": \"com.diffplug.atplug.Shape\$Circle\",\n" + |
62 |
| - " \"provides\": \"com.diffplug.atplug.Shape\",\n" + |
63 |
| - " \"properties\": {\n" + |
64 |
| - " \"id\": \"Circle\"\n" + |
65 |
| - " }\n" + |
66 |
| - "}") |
67 |
| - assertFile("src/main/resources/META-INF/MANIFEST.MF") |
68 |
| - .hasContentIgnoreWhitespace( |
69 |
| - "Manifest-Version: 1.0\n" + |
70 |
| - "AtPlug-Component: ATPLUG-INF/com.diffplug.atplug.Apple.json,ATPLUG-INF/com.d\n" + |
71 |
| - " iffplug.atplug.Orange.json,ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json\n" + |
72 |
| - " ,ATPLUG-INF/com.diffplug.atplug.Shape\$Square.json") |
73 |
| - } |
74 |
| -} |
| 1 | +package com.diffplug.atplug.tooling.gradle |
| 2 | + |
| 3 | +import com.diffplug.atplug.tooling.PlugGeneratorTest |
| 4 | +import java.io.File |
| 5 | +import java.nio.charset.StandardCharsets |
| 6 | +import java.nio.file.Files |
| 7 | +import org.junit.jupiter.api.Test |
| 8 | + |
| 9 | +class PlugPluginTest : GradleIntegrationHarness() { |
| 10 | + @Test |
| 11 | + fun test() { |
| 12 | + val runtimeJar = PlugGeneratorTest.findRuntimeJar().canonicalPath.replace('\\', '/') |
| 13 | + setFile("build.gradle") |
| 14 | + .toContent( |
| 15 | + """ |
| 16 | + plugins { |
| 17 | + id 'org.jetbrains.kotlin.jvm' version '1.8.0' |
| 18 | + id 'com.diffplug.atplug' |
| 19 | + } |
| 20 | + repositories { |
| 21 | + mavenCentral() |
| 22 | + } |
| 23 | + dependencies { |
| 24 | + implementation files("$runtimeJar") |
| 25 | + implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1" |
| 26 | + } |
| 27 | + """ |
| 28 | + .trimIndent()) |
| 29 | + |
| 30 | + val copy = { str: String -> |
| 31 | + val src = File("../atplug-runtime/src/test/java/com/diffplug/atplug/$str") |
| 32 | + setFile("src/main/java/com/diffplug/atplug/$str") |
| 33 | + .toContent(String(Files.readAllBytes(src.toPath()), StandardCharsets.UTF_8)) |
| 34 | + } |
| 35 | + copy("Fruit.kt") |
| 36 | + copy("Shape.java") |
| 37 | + |
| 38 | + gradleRunner().withArguments("jar", "--stacktrace").build() |
| 39 | + |
| 40 | + assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Apple.json") |
| 41 | + .hasContent( |
| 42 | + "{\n" + |
| 43 | + " \"implementation\": \"com.diffplug.atplug.Apple\",\n" + |
| 44 | + " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + |
| 45 | + " \"properties\": {\n" + |
| 46 | + " \"id\": \"Apple\"\n" + |
| 47 | + " }\n" + |
| 48 | + "}") |
| 49 | + assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Orange.json") |
| 50 | + .hasContent( |
| 51 | + "{\n" + |
| 52 | + " \"implementation\": \"com.diffplug.atplug.Orange\",\n" + |
| 53 | + " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + |
| 54 | + " \"properties\": {\n" + |
| 55 | + " \"id\": \"Orange\"\n" + |
| 56 | + " }\n" + |
| 57 | + "}") |
| 58 | + assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json") |
| 59 | + .hasContent( |
| 60 | + "{\n" + |
| 61 | + " \"implementation\": \"com.diffplug.atplug.Shape\$Circle\",\n" + |
| 62 | + " \"provides\": \"com.diffplug.atplug.Shape\",\n" + |
| 63 | + " \"properties\": {\n" + |
| 64 | + " \"id\": \"Circle\"\n" + |
| 65 | + " }\n" + |
| 66 | + "}") |
| 67 | + assertFile("src/main/resources/META-INF/MANIFEST.MF") |
| 68 | + .hasContentIgnoreWhitespace( |
| 69 | + "Manifest-Version: 1.0\n" + |
| 70 | + "AtPlug-Component: ATPLUG-INF/com.diffplug.atplug.Apple.json,ATPLUG-INF/com.d\n" + |
| 71 | + " iffplug.atplug.Orange.json,ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json\n" + |
| 72 | + " ,ATPLUG-INF/com.diffplug.atplug.Shape\$Square.json") |
| 73 | + } |
| 74 | +} |
0 commit comments