Skip to content

Commit 6ab9929

Browse files
author
EtienneSF
committed
First build runs ok (with junit and log4j for the plugin)
1 parent b50a8ac commit 6ab9929

File tree

11 files changed

+444
-44
lines changed

11 files changed

+444
-44
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ build
88
.settings/
99
.classpath
1010
.project
11+
bin/

build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,12 @@ dependencies {
2525
implementation 'com.google.guava:guava:27.0.1-jre'
2626

2727
// Use JUnit test framework
28-
testImplementation 'junit:junit:4.12'
28+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.0")
29+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.5.0")
30+
}
31+
32+
test {
33+
// We're using JUnit 5
34+
useJUnitPlatform()
35+
systemProperty 'java.util.logging.manager', 'org.apache.logging.log4j.jul.LogManager'
2936
}

graphql-gradle-plugin/build.gradle

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,35 @@
66
* User Manual available at https://docs.gradle.org/5.4/userguide/java_library_plugin.html
77
*/
88

9+
910
plugins {
1011
// Apply the java-library plugin to add support for Java Library
1112
id 'java-library'
1213
}
1314

15+
repositories {
16+
// mavenLocal is used to get snapshot of the com.graphql-java-generator maven plugin, and relatives dependencies
17+
mavenLocal()
18+
mavenCentral()
19+
}
20+
1421
dependencies {
1522
// Let's reuse the logic already implemented in our maven plugin
1623
implementation 'com.graphql-java-generator:graphql-maven-plugin-project:1.0.0-RC1'
17-
18-
// Use JUnit test framework
19-
testImplementation 'junit:junit:4.12'
24+
25+
// Logging with log4j2
26+
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.12.0'
27+
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.0'
28+
29+
// Use JUnit test framework
30+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.0")
31+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.5.0")
32+
testRuntimeOnly("org.apache.logging.log4j:log4j-jul:2.12.0")
33+
2034
}
2135

22-
// A sample plugin, just to try
23-
24-
25-
class GreetingPlugin implements Plugin<Project> {
26-
void apply(Project project) {
27-
project.task('hello') {
28-
doLast {
29-
println 'Hello from the ' + project.name
30-
}
31-
}
32-
}
36+
test {
37+
// We're using JUnit 5
38+
useJUnitPlatform()
39+
systemProperty 'java.util.logging.manager', 'org.apache.logging.log4j.jul.LogManager'
3340
}
34-
35-
// Apply the plugin
36-
apply plugin: GreetingPlugin
37-

graphql-gradle-plugin/src/main/java/graphql/graphqlplugin/GraphqlGradlePlugin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
package graphql.graphqlplugin;
55

66
/**
7-
* @author VJ2053
7+
* @author EtienneSF
88
*
99
*/
1010
public class GraphqlGradlePlugin {
1111

12+
int plus(int a, int b) {
13+
return a + b;
14+
};
15+
1216
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
*
3+
*/
4+
package graphql.graphqlplugin;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
8+
import org.junit.jupiter.api.BeforeEach;
9+
import org.junit.jupiter.api.Test;
10+
11+
/**
12+
* @author EtienneSF
13+
*
14+
*/
15+
class GraphqlGradlePluginTest {
16+
17+
GraphqlGradlePlugin graphqlGradlePlugin;
18+
19+
@BeforeEach
20+
public void setup() {
21+
graphqlGradlePlugin = new GraphqlGradlePlugin();
22+
}
23+
24+
/**
25+
* Test method for {@link graphql.graphqlplugin.GraphqlGradlePlugin#plus(int, int)}.
26+
*/
27+
@Test
28+
void testPlus() {
29+
assertEquals(8, graphqlGradlePlugin.plus(3, 5));
30+
}
31+
32+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
*
3+
* @author EtienneSF
4+
*
5+
*/
6+
package graphql.graphqlplugin;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Configuration status="WARN">
3+
4+
<Appenders>
5+
<Console name="Console" target="SYSTEM_OUT">
6+
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
7+
</Console>
8+
<File name="File" fileName="target/JUnit-tests.log4j.log">
9+
<PatternLayout>
10+
<pattern>%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</pattern>
11+
</PatternLayout>
12+
</File>
13+
</Appenders>
14+
15+
<Loggers>
16+
<Logger name="graphql.gradleplugin" level="debug" />
17+
<Root level="info">
18+
<AppenderRef ref="Console" />
19+
<AppenderRef ref="File" />
20+
</Root>
21+
</Loggers>
22+
23+
</Configuration>

graphql-gradle-plugin/target/JUnit-tests.log4j.log

Whitespace-only changes.

graphql-java-generator (eclipse code formatter).xml

Lines changed: 348 additions & 0 deletions
Large diffs are not rendered by default.

src/main/java/graphql/gradle/plugin/project/Library.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/test/java/graphql/gradle/plugin/project/LibraryTest.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)