diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..540437ff --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,82 @@ +# Contributing Code or Documentation to Micronaut + +Sign the [Contributor License Agreement (CLA)](https://cla-assistant.io/micronaut-projects/micronaut-graphql). This is required before any of your code or pull-requests are accepted. + +## Finding Issues to Work on + +If you are interested in contributing to Micronaut and are looking for issues to work on, take a look at the issues tagged with [help wanted](https://github.com/micronaut-projects/micronaut-graphql/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+help+wanted%22). + +## JDK Setup + +Micronaut GraphQL currently requires JDK 8. + +## IDE Setup + +Micronaut GraphQL can be imported into IntelliJ IDEA by opening the `build.gradle` file. + +## Docker Setup + +Micronaut GraphQL tests currently require Docker to be installed. + +## Running Tests + +To run the tests, use `./gradlew check`. + +## Building Documentation + +The documentation sources are located at `src/main/docs/guide`. + +To build the documentation, run `./gradlew publishGuide` (or `./gradlew pG`), then open `build/docs/index.html` + +To also build the Javadocs, run `./gradlew docs`. + +## Working on the code base + +If you use IntelliJ IDEA, you can import the project using the Intellij Gradle Tooling ("File / Import Project" and selecting the "settings.gradle" file). + +To get a local development version of Micronaut GraphQL working, first run the `publishToMavenLocal` task. + +``` +./gradlew pTML +``` + +You can then reference the version specified with `projectVersion` in `gradle.properties` in a test project's `build.gradle` or `pom.xml`. If you use Gradle, add the `mavenLocal` repository (Maven automatically does this): + +``` +repositories { + mavenLocal() + mavenCentral() +} +``` + +## Creating a pull request + +Once you are satisfied with your changes: + +- Commit your changes in your local branch +- Push your changes to your remote branch on GitHub +- Send us a [pull request](https://help.github.com/articles/creating-a-pull-request) + +## Checkstyle + +We want to keep the code clean, following good practices about organization, Javadoc, and style as much as possible. + +Micronaut GraphQL uses [Checkstyle](https://checkstyle.sourceforge.io/) to make sure that the code follows those standards. The configuration is defined in `config/checkstyle/checkstyle.xml`. To execute Checkstyle, run: + +``` +./gradlew :checkstyleMain +``` + +Before starting to contribute new code we recommended that you install the IntelliJ [CheckStyle-IDEA](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea) plugin and configure it to use Micronaut's checkstyle configuration file. + +IntelliJ will mark in red the issues Checkstyle finds. For example: + +![](https://github.com/micronaut-projects/micronaut-core/raw/master/src/main/docs/resources/img/checkstyle-issue.png) + +In this case, to fix the issues, we need to: + +- Add one empty line before `package` in line 16 +- Add the Javadoc for the constructor in line 27 +- Add an space after `if` in line 34 + +The plugin also adds a new tab in the bottom of the IDE to run Checkstyle and show errors and warnings. We recommend that you run the report and fix all issues before submitting a pull request. diff --git a/buildSrc/src/main/groovy/io.micronaut.build.internal.graphql-module.gradle b/buildSrc/src/main/groovy/io.micronaut.build.internal.graphql-module.gradle new file mode 100644 index 00000000..401cfa3c --- /dev/null +++ b/buildSrc/src/main/groovy/io.micronaut.build.internal.graphql-module.gradle @@ -0,0 +1,3 @@ +plugins { + id 'io.micronaut.build.internal.module' +} diff --git a/buildSrc/src/main/groovy/micronaut-graphql.example-conventions.gradle b/buildSrc/src/main/groovy/micronaut-graphql.example-conventions.gradle index f39b9d34..0dc05205 100644 --- a/buildSrc/src/main/groovy/micronaut-graphql.example-conventions.gradle +++ b/buildSrc/src/main/groovy/micronaut-graphql.example-conventions.gradle @@ -11,23 +11,16 @@ repositories { } dependencies { - annotationProcessor platform("io.micronaut:micronaut-bom:${micronautVersion}") - annotationProcessor "io.micronaut:micronaut-inject-java" - annotationProcessor "io.micronaut:micronaut-validation" - - implementation platform("io.micronaut:micronaut-bom:${micronautVersion}") implementation(project(":graphql")) + + annotationProcessor("io.micronaut:micronaut-http-validation") implementation("io.micronaut:micronaut-http-client") - implementation("io.micronaut:micronaut-http-server-netty") - implementation("io.micronaut:micronaut-inject") + implementation("io.micronaut:micronaut-jackson-databind") implementation("io.micronaut:micronaut-validation") implementation("io.micronaut:micronaut-runtime") - implementation platform("io.micronaut:micronaut-bom:${micronautVersion}") - implementation("io.micronaut:micronaut-inject-java") - - implementation platform("io.micronaut:micronaut-bom:${micronautVersion}") - implementation("ch.qos.logback:logback-classic") + runtimeOnly("ch.qos.logback:logback-classic") + compileOnly("org.graalvm.nativeimage:svm") } sourceCompatibility = "1.8" @@ -35,20 +28,13 @@ targetCompatibility = "1.8" mainClassName = "example.Application" -run.jvmArgs("-noverify", "-XX:TieredStopAtLevel=1") - -shadowJar { - mergeServiceFiles() -} - -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - options.compilerArgs.add("-parameters") +micronaut { + runtime("netty") } micronautBuild { resolutionStrategy { - force "com.graphql-java:graphql-java-extended-scalars:1.0.1" - force "com.graphql-java:graphql-java:$graphqlJavaVersion" + force "com.graphql-java:graphql-java-extended-scalars:${libs.managed.graphql.java.extended.scalars}" + force "com.graphql-java:graphql-java:${libs.versions.managed.graphql.java}" } } diff --git a/config/checkstyle/.rsync-filter b/config/checkstyle/.rsync-filter new file mode 100644 index 00000000..9080fe5d --- /dev/null +++ b/config/checkstyle/.rsync-filter @@ -0,0 +1,2 @@ +- suppressions.xml +- checkstyle.xml diff --git a/examples/chat/build.gradle b/examples/chat/build.gradle index cf57fbea..57c3fb4a 100644 --- a/examples/chat/build.gradle +++ b/examples/chat/build.gradle @@ -8,6 +8,6 @@ repositories { } dependencies { - implementation("com.graphql-java:graphql-java-extended-scalars:1.0.1") + implementation libs.managed.graphql.java.extended.scalars implementation 'io.projectreactor:reactor-core' } diff --git a/examples/jwt-security/src/main/resources/application.yml b/examples/jwt-security/src/main/resources/application.yml index 8fd75a72..eb92c869 100644 --- a/examples/jwt-security/src/main/resources/application.yml +++ b/examples/jwt-security/src/main/resources/application.yml @@ -1,6 +1,7 @@ micronaut: security: enabled: true + authentication: cookie token: jwt: enabled: true @@ -8,6 +9,9 @@ micronaut: enabled: false cookie: enabled: true + refresh: + cookie: + enabled: false intercept-url-map: - pattern: /** http-method: GET diff --git a/examples/todo-java-tools/build.gradle b/examples/todo-java-tools/build.gradle index 1891a4ae..eb069dbb 100644 --- a/examples/todo-java-tools/build.gradle +++ b/examples/todo-java-tools/build.gradle @@ -8,6 +8,6 @@ repositories { } dependencies { - implementation("com.graphql-java-kickstart:graphql-java-tools:${graphqlJavaToolsVersion}") - nativeImageCompileOnly("io.micronaut.kotlin:micronaut-kotlin-runtime") + implementation libs.managed.graphql.java.tools + nativeImageCompileOnly(mn.micronaut.kotlin.runtime) } diff --git a/examples/todo-spqr/build.gradle b/examples/todo-spqr/build.gradle index 9149fcba..d15f2b27 100644 --- a/examples/todo-spqr/build.gradle +++ b/examples/todo-spqr/build.gradle @@ -8,5 +8,5 @@ repositories { } dependencies { - implementation("io.leangen.graphql:spqr:${graphqlSpqrVersion}") + implementation libs.managed.graphql.spqr } diff --git a/gradle.properties b/gradle.properties index 7a3cf020..29b80d75 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,15 +8,9 @@ micronautTestVersion=3.4.0 groovyVersion=3.0.12 spockVersion=2.1-groovy-3.0 -cglibVersion=3.3.0 -graphqlJavaVersion=16.2 -graphqlJavaToolsVersion=11.0.1 -graphqlSpqrVersion=0.11.2 -kotlinVersion=1.6.0 - title=Micronaut GraphQL Integration projectDesc=Extensions to integrate Micronaut and GraphQL -projectUrl=http://micronaut.io +projectUrl=https://micronaut.io githubSlug=micronaut-projects/micronaut-graphql developers=Marcel Overdijk @@ -24,4 +18,5 @@ githubCoreBranch=4.0.x bomProperty=micronautGraphQLVersion org.gradle.caching=true +org.gradle.jvmargs=-Xmx1g org.gradle.parallel=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..d8452187 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,13 @@ +[versions] +managed-graphql-java = "16.2" +managed-graphql-java-extended-scalars = "1.0.1" +managed-graphql-java-tools = "11.0.1" +managed-graphql-spqr = "0.11.2" + +[libraries] +managed-graphql-java = { module = 'com.graphql-java:graphql-java', version.ref = 'managed-graphql-java' } +managed-graphql-java-extended-scalars = { module = 'com.graphql-java:graphql-java-extended-scalars', version.ref = 'managed-graphql-java-extended-scalars' } +managed-graphql-java-tools = { module = 'com.graphql-java-kickstart:graphql-java-tools', version.ref = 'managed-graphql-java-tools' } +managed-graphql-spqr = { module = 'io.leangen.graphql:spqr', version.ref = 'managed-graphql-spqr' } + +reactor-core = { module = 'io.projectreactor:reactor-core' } diff --git a/graphql-bom/build.gradle b/graphql-bom/build.gradle new file mode 100644 index 00000000..c6148647 --- /dev/null +++ b/graphql-bom/build.gradle @@ -0,0 +1,15 @@ +plugins { + id "io.micronaut.build.internal.bom" +} + +// First BOM release, this can be removed after a BOM is out +micronautBuild { + // Required as a workaround to https://github.com/micronaut-projects/micronaut-build/pull/376 + tasks.named("checkVersionCatalogCompatibility") { onlyIf { false } } +} + +micronautBom { + excludeProject.set({ p -> + p.name.contains('example') || p.name.contains('hello-world') + } as Spec) +} diff --git a/graphql/build.gradle b/graphql/build.gradle index d72c3b29..c1d739b3 100644 --- a/graphql/build.gradle +++ b/graphql/build.gradle @@ -1,5 +1,5 @@ plugins { - id "io.micronaut.build.internal.module" + id "io.micronaut.build.internal.graphql-module" } repositories { @@ -8,22 +8,17 @@ repositories { } dependencies { - annotationProcessor("io.micronaut:micronaut-validation") + api libs.managed.graphql.java - api("com.graphql-java:graphql-java:${graphqlJavaVersion}") - api("io.micronaut:micronaut-http") - api("io.micronaut:micronaut-http-server") - api("io.micronaut:micronaut-inject") + api mn.micronaut.http.server + api libs.reactor.core - implementation 'io.projectreactor:reactor-core' - - testImplementation("cglib:cglib-nodep:${cglibVersion}") - testImplementation("io.micronaut:micronaut-http-client") - testImplementation("io.micronaut:micronaut-http-server-netty") + testImplementation mn.micronaut.http.server.netty + testImplementation mn.micronaut.http.client } micronautBuild { resolutionStrategy { - force "com.graphql-java:graphql-java:$graphqlJavaVersion" + force "com.graphql-java:graphql-java:${libs.versions.managed.graphql.java}" } } diff --git a/settings.gradle b/settings.gradle index 3237d39b..fcf39782 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,9 +9,15 @@ plugins { id("io.micronaut.build.shared.settings") version "5.3.14" } +micronautBuild { + importMicronautCatalog() +} + rootProject.name = 'graphql-parent' include "graphql" +include "graphql-bom" + include 'docs-examples:hello-world-java' include 'docs-examples:hello-world-groovy' include 'docs-examples:hello-world-kotlin'