Skip to content

Commit

Permalink
feat: Adds BOM Module and Migrate to Gradle Version Catalog (#280)
Browse files Browse the repository at this point in the history
* Upgrade to Micronaut 3.3.4. Upgrade to the latest GraphQL libraries.

* Fixed graphql-java-extended-scalars version.

* graphql-java 18.0

* Fixed jwt-security example.

* Sync common files with https://github.com/micronaut-projects/micronaut-project-template

* Gradle 7.4.2.
io.micronaut.build.shared.settings 5.3.3.

* Migrate to Gradle Version Catalogs.

Co-authored-by: Alexey Zhokhov <[email protected]>
  • Loading branch information
sdelamo and donbeave committed Aug 16, 2022
1 parent 731c5fc commit 902885a
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 46 deletions.
82 changes: 82 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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 <module-name>: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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id 'io.micronaut.build.internal.module'
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,30 @@ 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"
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}"
}
}
2 changes: 2 additions & 0 deletions config/checkstyle/.rsync-filter
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- suppressions.xml
- checkstyle.xml
2 changes: 1 addition & 1 deletion examples/chat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
4 changes: 4 additions & 0 deletions examples/jwt-security/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
micronaut:
security:
enabled: true
authentication: cookie
token:
jwt:
enabled: true
bearer:
enabled: false
cookie:
enabled: true
refresh:
cookie:
enabled: false
intercept-url-map:
- pattern: /**
http-method: GET
Expand Down
4 changes: 2 additions & 2 deletions examples/todo-java-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion examples/todo-spqr/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ repositories {
}

dependencies {
implementation("io.leangen.graphql:spqr:${graphqlSpqrVersion}")
implementation libs.managed.graphql.spqr
}
9 changes: 2 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ 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

githubCoreBranch=4.0.x
bomProperty=micronautGraphQLVersion

org.gradle.caching=true
org.gradle.jvmargs=-Xmx1g
org.gradle.parallel=true
13 changes: 13 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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' }
15 changes: 15 additions & 0 deletions graphql-bom/build.gradle
Original file line number Diff line number Diff line change
@@ -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<String>)
}
19 changes: 7 additions & 12 deletions graphql/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "io.micronaut.build.internal.module"
id "io.micronaut.build.internal.graphql-module"
}

repositories {
Expand All @@ -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}"
}
}
6 changes: 6 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 902885a

Please sign in to comment.