Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Gradle Version Catalog and upgrade to use latest stable versions #247

Closed
wants to merge 15 commits into from
Closed
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.
10 changes: 5 additions & 5 deletions MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ follow a slightly different strategy.

All Micronaut repos have 2 dependency upgrade checking mechanism:

1. Dependabot: it has the advantage that it performs dependency upgrades not only on build dependencies, but also on
1. Renovate: it has the advantage that it performs dependency upgrades not only on build dependencies, but also on
GitHub Actions workflows. On the other hand, its biggest downside is that it's unable to find newer versions for
those defined in `gradle.properties`. It will also send different PRs for the same version upgrade if the artifact ID
is different. For example, if you have `com.example:client:1.0` and `com.example:server:1.0`, and a new 1.1 version
Expand All @@ -99,9 +99,9 @@ All Micronaut repos have 2 dependency upgrade checking mechanism:
during weekdays.

The consequence of having both approaches in place is that we get multiple dependency upgrade PRs: one created by
`micronaut-build` via our automation, and one or many (one per dependency) created by Dependabot. When merging those, it
`micronaut-build` via our automation, and one or many (one per dependency) created by Renovate. When merging those, it
is better to prefer the `micronaut-build` ones, if possible, for 2 reasons: a) they attempt to upgrade multiple dependencies
in a single PR, which creates less noise in the Git history; b) Once you merge that, Dependabot will react and automatically
in a single PR, which creates less noise in the Git history; b) Once you merge that, Renovate will react and automatically
close its own PRs if the dependecy is up-to-date.

When an upgrade to a new version arrives, we need to be careful when merging, so that we don't introduce an
Expand All @@ -111,7 +111,7 @@ information.

Note that if a new version arrives and we are not ready yet to do the upgrade, you need to
[pin the old version](https://github.com/micronaut-projects/micronaut-build/#configuration-options), because otherwise,
Dependabot and our workflow will keep sending PRs. You should also create an issue to upgrade so that it's not forgotten.
Renovate and our workflow will keep sending PRs. You should also create an issue to upgrade so that it's not forgotten.

#### Files sync

Expand All @@ -126,7 +126,7 @@ template repo will get propagated automatically. The files propagated are:
* `gradle.yml`.
* `release.yml`.
* `release-notes.yml`.
* Dependabot configuration (`.github/dependabot.yml`).
* Renovate configuration (`.github/renovate.json`).
* Gradle wrapper.
* `.gitignore`.
* `ISSUE_TEMPLATE.md`, `LICENSE`, `MAINTAINING.md`, `config/HEADER` and `config/spotless.license.java`.
Expand Down
5 changes: 3 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repositories {
}

dependencies {
implementation("io.micronaut.gradle:micronaut-gradle-plugin:3.2.1")
implementation("io.micronaut.gradle:micronaut-gradle-plugin:3.4.0")
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
}
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
}
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
4 changes: 2 additions & 2 deletions docs-examples/hello-world-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "org.jetbrains.kotlin.jvm" version "${kotlinVersion}"
id "org.jetbrains.kotlin.kapt" version "${kotlinVersion}"
id "org.jetbrains.kotlin.jvm"
id "org.jetbrains.kotlin.kapt"
id("micronaut-graphql.docs-examples-conventions")
}

Expand Down
2 changes: 1 addition & 1 deletion examples/chat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ plugins {
}

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: 3 additions & 1 deletion examples/todo-java-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ plugins {
}

dependencies {
implementation("com.graphql-java-kickstart:graphql-java-tools:${graphqlJavaToolsVersion}")
implementation libs.managed.graphql.java.tools

implementation("io.micronaut.kotlin: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 @@ -3,5 +3,5 @@ plugins {
}

dependencies {
implementation("io.leangen.graphql:spqr:${graphqlSpqrVersion}")
implementation libs.managed.graphql.spqr
}
22 changes: 9 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
projectVersion=3.1.0-SNAPSHOT
projectVersion=3.2.0-SNAPSHOT
projectGroup=io.micronaut.graphql

micronautDocsVersion=2.0.0
micronautVersion=3.2.0
micronautTestVersion=3.0.4

groovyVersion=3.0.9
micronautVersion=3.4.3
micronautTestVersion=3.1.1
groovyVersion=3.0.10
spockVersion=2.0-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=3.3.x
# Micronaut core branch for BOM pull requests
githubCoreBranch=3.5.x

bomProperty=micronautGraphQLVersion

org.gradle.caching=true
org.gradle.jvmargs=-Xmx1g
org.gradle.parallel=true
17 changes: 17 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[versions]
managed-graphql-java = "18.1"
managed-graphql-java-extended-scalars = "18.0"
managed-graphql-java-tools = "12.0.2"
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' }

micronaut-http-server = { module = 'io.micronaut:micronaut-http-server' }
micronaut-http-server-netty = { module = 'io.micronaut:micronaut-http-server-netty' }
micronaut-http-client = { module = 'io.micronaut:micronaut-http-client' }

reactor-core = { module = 'io.projectreactor:reactor-core' }
9 changes: 9 additions & 0 deletions graphql-bom/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id "io.micronaut.build.internal.bom"
}

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,24 +1,19 @@
plugins {
id "io.micronaut.build.internal.module"
id "io.micronaut.build.internal.graphql-module"
}

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 libs.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 libs.micronaut.http.server.netty
testImplementation libs.micronaut.http.client
}

micronautBuild {
resolutionStrategy {
force "com.graphql-java:graphql-java:$graphqlJavaVersion"
force "com.graphql-java:graphql-java:${libs.versions.managed.graphql.java}"
}
}
4 changes: 3 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ pluginManagement {
}

plugins {
id("io.micronaut.build.shared.settings") version "5.3.2"
id("io.micronaut.build.shared.settings") version "5.3.3"
}

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