From fca706d170dad89d8bd0e6e082e047d63053134a Mon Sep 17 00:00:00 2001 From: Alexandre Mommers <919982+ygdrasil-io@users.noreply.github.com> Date: Sat, 26 Aug 2023 14:02:48 +0200 Subject: [PATCH 1/2] improve documentation on no-arg-plugin.md - Provide a sample annotation to illustrate how the plugin should be used. - Explain how to utilize the plugin using Kotlin DSL in Gradle, as an alternative for Groovy. --- docs/topics/no-arg-plugin.md | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/docs/topics/no-arg-plugin.md b/docs/topics/no-arg-plugin.md index 8691bf43141..7a4dd25f466 100644 --- a/docs/topics/no-arg-plugin.md +++ b/docs/topics/no-arg-plugin.md @@ -7,16 +7,43 @@ The generated constructor is synthetic so it can't be directly called from Java This allows the Java Persistence API (JPA) to instantiate a class although it doesn't have the zero-parameter constructor from Kotlin or Java point of view (see the description of `kotlin-jpa` plugin [below](#jpa-support)). +## On your code + +Add new annotations to mark the code that need a zero-argument constructor + +```kotlin +package com.my + +annotation class Annotation + +``` + ## Gradle Add the plugin using Gradle's plugins DSL: + + + +```kotlin + +plugins { + kotlin("plugin.noarg") version "%kotlinVersion%" +} +``` + + + + ```groovy plugins { id "org.jetbrains.kotlin.plugin.noarg" version "%kotlinVersion%" } ``` + + + Then specify the list of no-arg annotations that must lead to generating a no-arg constructor for the annotated classes: ```groovy @@ -74,12 +101,28 @@ and [`@MappedSuperclass`](https://docs.oracle.com/javaee/7/api/javax/persistence Add the plugin using the Gradle plugins DSL: + + + +```kotlin + +plugins { + kotlin("plugin.jpa") version "%kotlinVersion%" +} +``` + + + + ```groovy plugins { id "org.jetbrains.kotlin.plugin.jpa" version "%kotlinVersion%" } ``` + + + In Maven, enable the `jpa` plugin: ```xml From 1bdbba8e1a5825ba14474a09c8905e26ace44f0a Mon Sep 17 00:00:00 2001 From: Andrey Polyakov Date: Wed, 30 Aug 2023 12:22:58 +0200 Subject: [PATCH 2/2] update: update no-arg-plugin.md updated wording applied code style --- docs/topics/no-arg-plugin.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/topics/no-arg-plugin.md b/docs/topics/no-arg-plugin.md index 7a4dd25f466..24ad11a5650 100644 --- a/docs/topics/no-arg-plugin.md +++ b/docs/topics/no-arg-plugin.md @@ -2,20 +2,19 @@ The *no-arg* compiler plugin generates an additional zero-argument constructor for classes with a specific annotation. -The generated constructor is synthetic so it can't be directly called from Java or Kotlin, but it can be called using reflection. +The generated constructor is synthetic, so it can't be directly called from Java or Kotlin, but it can be called using reflection. This allows the Java Persistence API (JPA) to instantiate a class although it doesn't have the zero-parameter constructor from Kotlin or Java point of view (see the description of `kotlin-jpa` plugin [below](#jpa-support)). -## On your code +## In your Kotlin file -Add new annotations to mark the code that need a zero-argument constructor +Add new annotations to mark the code that needs a zero-argument constructor: ```kotlin package com.my annotation class Annotation - ``` ## Gradle @@ -26,9 +25,8 @@ Add the plugin using Gradle's plugins DSL: ```kotlin - plugins { - kotlin("plugin.noarg") version "%kotlinVersion%" + kotlin("plugin.noarg") version "%kotlinVersion%" } ``` @@ -37,7 +35,7 @@ plugins { ```groovy plugins { - id "org.jetbrains.kotlin.plugin.noarg" version "%kotlinVersion%" + id "org.jetbrains.kotlin.plugin.noarg" version "%kotlinVersion%" } ``` @@ -105,9 +103,8 @@ Add the plugin using the Gradle plugins DSL: ```kotlin - plugins { - kotlin("plugin.jpa") version "%kotlinVersion%" + kotlin("plugin.jpa") version "%kotlinVersion%" } ``` @@ -116,7 +113,7 @@ plugins { ```groovy plugins { - id "org.jetbrains.kotlin.plugin.jpa" version "%kotlinVersion%" + id "org.jetbrains.kotlin.plugin.jpa" version "%kotlinVersion%" } ```