diff --git a/.github/workflows/github-actions.yaml b/.github/workflows/github-actions.yaml new file mode 100644 index 0000000..74a89f5 --- /dev/null +++ b/.github/workflows/github-actions.yaml @@ -0,0 +1,134 @@ +name: Build, Test & Publish +on: + push: + tags: + - '*' + branches: + - '**' +jobs: + Build-Test: + runs-on: ubuntu-latest + if: "!startsWith(github.ref, 'refs/tags/')" + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Java + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + cache: 'gradle' + - name: Make gradlew executable + run: | + chmod +x ./bee.persistent/gradlew + chmod +x ./bee.functional/gradlew + chmod +x ./bee.buzz/gradlew + chmod +x ./bee.generative/gradlew + chmod +x ./bee.fetched/gradlew + chmod +x ./bee.fetched.test/gradlew + chmod +x ./example/application/gradlew + - name: Build & Test bee.persistent + working-directory: ./bee.persistent + run: ./gradlew build + - name: Build & Test bee.functional + working-directory: ./bee.functional + run: ./gradlew build + - name: Build & Test bee.buzz + working-directory: ./bee.buzz + run: ./gradlew build + - name: Build & Test bee.generative + working-directory: ./bee.generative + run: ./gradlew build + - name: Build & Test bee.fetched + run: | + cd ./bee.fetched/ + ./gradlew build + cd ../bee.fetched.test/ + ./gradlew build + - name: Build & Test example application + working-directory: ./example/application + run: ./gradlew build + + Build-Test-Publish: + runs-on: ubuntu-latest + if: "startsWith(github.ref, 'refs/tags/')" + env: + JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }} + JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }} + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Remove -SNAPSHOT suffix from bee-built version + run: sed -i '/bee-built/ s/-SNAPSHOT//g' ./gradle/libs.versions.toml + - name: Setup Java + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + cache: 'gradle' + - name: Make gradlew executable + run: | + chmod +x ./bee.persistent/gradlew + chmod +x ./bee.functional/gradlew + chmod +x ./bee.buzz/gradlew + chmod +x ./bee.generative/gradlew + chmod +x ./bee.fetched/gradlew + chmod +x ./bee.fetched.test/gradlew + chmod +x ./example/application/gradlew + - name: Build & Test bee.persistent + working-directory: ./bee.persistent + run: ./gradlew build + - name: Build & Test bee.functional + working-directory: ./bee.functional + run: ./gradlew build + - name: Build & Test bee.buzz + working-directory: ./bee.buzz + run: ./gradlew build + - name: Build & Test bee.generative + working-directory: ./bee.generative + run: ./gradlew build + - name: Build & Test bee.fetched + run: | + cd ./bee.fetched/ + ./gradlew build + cd ../bee.fetched.test/ + ./gradlew build + - name: Build & Test example application + working-directory: ./example/application + run: ./gradlew build + + - name: Publish bee.persistent + continue-on-error: true + working-directory: ./bee.persistent + run: | + ./gradlew publish + ./gradlew jreleaserDeploy + - name: Publish bee.functional + continue-on-error: true + working-directory: ./bee.functional + run: | + ./gradlew publish + ./gradlew jreleaserDeploy + - name: Publish bee.buzz + continue-on-error: true + working-directory: ./bee.buzz + run: | + ./gradlew publish + ./gradlew jreleaserDeploy + - name: Publish bee.generative + continue-on-error: true + working-directory: ./bee.generative + run: | + ./gradlew publish + ./gradlew jreleaserDeploy + - name: Publish bee.fetched + continue-on-error: true + working-directory: ./bee.fetched + run: | + ./gradlew publish + ./gradlew jreleaserDeploy + diff --git a/README.md b/README.md index 5fc223d..0b8679a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Extend DGS: Some changes are currently being made: * `bee.persistent` - Easier data handling for GraphQL + JPA, [documentation](./lib.data/README.md) + Easier data handling for GraphQL + JPA, [documentation](./bee.persistent/README.md) * `bee.functional` Functional kotlin bindings, integration with DGS, `bee.persistent` & more * `bee.buzz` diff --git a/bee.buzz/build.gradle.kts b/bee.buzz/build.gradle.kts index cc5cb0f..5ef28d4 100644 --- a/bee.buzz/build.gradle.kts +++ b/bee.buzz/build.gradle.kts @@ -1,14 +1,19 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jreleaser.model.Active plugins { alias(libs.plugins.kotlin.jvm) alias(libs.plugins.spring.boot).apply(false) alias(libs.plugins.spring.dependencymanagement) + alias(libs.plugins.jreleaser) + `maven-publish` + signing java } group = "com.beeproduced" version = libs.versions.bee.built.get() +description = "Simple event manager based on the mediator pattern." java.sourceCompatibility = JavaVersion.VERSION_17 java.targetCompatibility = JavaVersion.VERSION_17 tasks.withType().configureEach { @@ -41,13 +46,17 @@ sourceSets { } java { + withSourcesJar() + withJavadocJar() registerFeature("simple") { usingSourceSet(sourceSets["simple"]) + withSourcesJar() + withJavadocJar() } } dependencies { - implementation("com.beeproduced:bee.functional") + implementation("com.beeproduced:bee.functional:$version") implementation(libs.kotlin.stdlib) implementation(libs.spring.boot.starter.web) testImplementation(libs.junit.api) @@ -57,3 +66,85 @@ dependencies { tasks.withType { useJUnitPlatform() } + +// Based on https://www.tschuehly.de/posts/guide-kotlin-gradle-publish-to-maven-central/#51-generate-javadocs-and-sources-jars +publishing { + publications { + create("Maven") { + from(components["java"]) + description = project.description + } + withType { + pom { + packaging = "jar" + name.set(project.name) + description.set(project.description) + url.set("https://github.com/bee-produced/bee-built") + licenses { + license { + name.set("MIT license") + url.set("https://opensource.org/licenses/MIT") + } + } + developers { + developer { + id.set("kurbaniec") + name.set("Kacper Urbaniec") + email.set("kacper.urbaniec@beeproduced.com") + } + } + scm { + connection.set("scm:git:git@github.com:bee-produced/bee-built.git") + developerConnection.set("scm:git:ssh:git@github.com:bee-produced/bee-built.git") + url.set("https://github.com/bee-produced/bee-built") + } + } + } + } + repositories { + maven { + url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI() + } + } +} + +jreleaser { + project { + copyright.set("bee produced") + } + gitRootSearch.set(true) + signing { + active.set(Active.ALWAYS) + armored.set(true) + } + deploy { + maven { + nexus2 { + create("maven-central") { + active.set(Active.ALWAYS) + url.set("https://s01.oss.sonatype.org/service/local") + closeRepository.set(true) + releaseRepository.set(true) + stagingRepositories.add("build/staging-deploy") + } + } + } + } +} + +// Invalid pom is produced when using both the dependency management plugin and Gradle's bom support +// See: https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/257#issuecomment-895790557 +tasks.withType().all { + doLast { + val file = file("${layout.buildDirectory.get().asFile.toURI()}/publications/Maven/pom-default.xml") + var text = file.readText() + val regex = "(?s)(.+?)(.+?)(.+?)".toRegex() + val matcher = regex.find(text) + if (matcher != null) { + text = regex.replaceFirst(text, "") + val firstDeps = matcher.groups[2]!!.value + text = regex.replaceFirst(text, "$1$2$firstDeps$3") + } + file.writeText(text) + } +} \ No newline at end of file diff --git a/bee.fetched/README.md b/bee.fetched/README.md index 77341cb..a589fde 100644 --- a/bee.fetched/README.md +++ b/bee.fetched/README.md @@ -15,7 +15,7 @@ In addition, these types of data fetchers can be quite easily overlooked during This code generation library attempts to solve this problem by automatically generating such nested data fetches from DGS DTOs and data loader definitions. `bee.fetched` is based on `ksp` for lightweight, idiomatic code generation. -Note that this library builds upon [DGS](https://netflix.github.io/dgs/) and is not intended for use with only `graphql-java`. +Note that this library builds upon [DGS](https://netflix.github.io/dgs/) and is not intended for use with only `graphql-java`. ## 🚀 Quickstart @@ -23,6 +23,22 @@ Note that this library builds upon [DGS](https://netflix.github.io/dgs/) and is The following shows the easiest way to incorporate `bee.fetched` into a project. +`settings.gradle.kts` + +```kotlin +pluginManagement { + resolutionStrategy { + eachPlugin { + when (requested.id.id) { + "bee.generative" -> useModule("com.beeproduced:bee.generative:") + } + } + } +} +``` + +> ⚠️ As `bee.generative` is currently not published to the gradle plugin portal, the publication on maven central has no [plugin marker](https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers) and thus requires this [workaround](https://github.com/GoogleCloudPlatform/app-gradle-plugin/issues/397#issuecomment-1484070866). + `build.gradle.kts`: ```kotlin @@ -32,7 +48,7 @@ plugins { } dependencies { - beeGenerative("com.beeproduced:bee.fetched") + beeGenerative("com.beeproduced:bee.fetched:") } // DGS codegen @@ -107,9 +123,9 @@ class WaldoDataLoader : MappedBatchLoaderWithContext { } ``` -> ⚠️ Please do not forget to annotate the data loader with `@BeeFetched` if one wants to utilise code generation. +> ⚠️ Please do not forget to annotate the data loader with `@BeeFetched` if one wants to utilise code generation. -> 🪧 The `@BeeFetched` annotation will be explained in the following step by step. +> 🪧 The `@BeeFetched` annotation will be explained in the following step by step. With the help of `bee.fetched` all of the corresponding nested data fetchers including their data loader invocations can be automatically generated. @@ -119,9 +135,9 @@ In the following schema `waldo` and `waldos` are the fields that should be loade A simple approach is used: -* Entities like `waldo` => Search for `waldoId` +* Entities like `waldo` => Search for `waldoId` * Collections like `waldos` => Search for `waldoIds` or `waldosIds` -* Not modelled but possible: A collection called `waldo` => Search for `waldoIds` or `waldosIds` +* Not modelled but possible: A collection called `waldo` => Search for `waldoIds` or `waldosIds` ```crystal type Foo { @@ -215,7 +231,7 @@ type Corge { } ``` -To do so, one must provide a `FetcherMapping` via `@BeeFetched` that maps `Corge`'s `waldo` field to the id `corgeToWaldoId`. +To do so, one must provide a `FetcherMapping` via `@BeeFetched` that maps `Corge`'s `waldo` field to the id `corgeToWaldoId`. ```kotlin @BeeFetched( @@ -290,7 +306,7 @@ In these cases, one must provide a `FetcherInternalType` via `@BeeFetched` that class WaldoDataLoader : MappedBatchLoaderWithContext ``` -> 🪧 If `Grault` would have another field `waldo2: Waldo` the library would use the `Grault` DTO and not the `TestController.MyGrault` internal type as it is only configured for `DgsConstants.GRAULT.Waldo`. Leaving `DgsConstants.GRAULT.Waldo` empty or adding an additional `FetcherInternalType` for `DgsConstants.GRAULT.Waldo2` would result in usage of the internal type. +> 🪧 If `Grault` would have another field `waldo2: Waldo` the library would use the `Grault` DTO and not the `TestController.MyGrault` internal type as it is only configured for `DgsConstants.GRAULT.Waldo`. Leaving `DgsConstants.GRAULT.Waldo` empty or adding an additional `FetcherInternalType` for `DgsConstants.GRAULT.Waldo2` would result in usage of the internal type. This results in following generated code. @@ -377,7 +393,7 @@ class WaldoDataLoader : MappedBatchLoaderWithContext #### Safety first - Do not load what is already present -By default, `bee.fetched` generates nested data fetcher with an early return when data is already present for the requested field. This feature is called `safeMode` and can be illustrated as follows. +By default, `bee.fetched` generates nested data fetcher with an early return when data is already present for the requested field. This feature is called `safeMode` and can be illustrated as follows. ```kotlin @DgsData( @@ -438,4 +454,4 @@ class WaldoDataLoader : MappedBatchLoaderWithContext ## 🧪 Example & Tests -An example on which this documentation is based on can be found under `bee.fetched.test` in the root project. The tests for this library reside also in this example project. \ No newline at end of file +An example on which this documentation is based on can be found under `bee.fetched.test` in the root project. The tests for this library reside also in this example project. \ No newline at end of file diff --git a/bee.fetched/build.gradle.kts b/bee.fetched/build.gradle.kts index f02e33c..9d5dedf 100644 --- a/bee.fetched/build.gradle.kts +++ b/bee.fetched/build.gradle.kts @@ -1,12 +1,17 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jreleaser.model.Active plugins { alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.jreleaser) + `maven-publish` + signing java } group = "com.beeproduced" version = libs.versions.bee.built.get() +description = "Automatically generate nested data fetchers for usage with data loaders." java.sourceCompatibility = JavaVersion.VERSION_17 java.targetCompatibility = JavaVersion.VERSION_17 tasks.withType().configureEach { @@ -32,8 +37,12 @@ sourceSets { } java { + withSourcesJar() + withJavadocJar() registerFeature("processor") { usingSourceSet(sourceSets["processor"]) + withSourcesJar() + withJavadocJar() } } @@ -42,13 +51,76 @@ dependencies { testImplementation(libs.kotlin.test) testImplementation(libs.junit.api) testRuntimeOnly(libs.junit.engine) - - - "processorImplementation"("com.beeproduced:bee.generative") + "processorImplementation"("com.beeproduced:bee.generative:$version") "processorImplementation"(sourceSets.main.get().output) "processorImplementation"(libs.dgs.spring.starter) } tasks.withType { useJUnitPlatform() +} + +// Based on https://www.tschuehly.de/posts/guide-kotlin-gradle-publish-to-maven-central/#51-generate-javadocs-and-sources-jars +publishing { + publications { + create("Maven") { + from(components["java"]) + description = project.description + } + withType { + pom { + packaging = "jar" + name.set(project.name) + description.set(project.description) + url.set("https://github.com/bee-produced/bee-built") + licenses { + license { + name.set("MIT license") + url.set("https://opensource.org/licenses/MIT") + } + } + developers { + developer { + id.set("kurbaniec") + name.set("Kacper Urbaniec") + email.set("kacper.urbaniec@beeproduced.com") + } + } + scm { + connection.set("scm:git:git@github.com:bee-produced/bee-built.git") + developerConnection.set("scm:git:ssh:git@github.com:bee-produced/bee-built.git") + url.set("https://github.com/bee-produced/bee-built") + } + } + } + } + repositories { + maven { + url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI() + } + } +} + +jreleaser { + project { + copyright.set("bee produced") + } + gitRootSearch.set(true) + signing { + active.set(Active.ALWAYS) + armored.set(true) + } + deploy { + maven { + nexus2 { + create("maven-central") { + active.set(Active.ALWAYS) + url.set("https://s01.oss.sonatype.org/service/local") + closeRepository.set(true) + releaseRepository.set(true) + stagingRepositories.add("build/staging-deploy") + } + } + } + } } \ No newline at end of file diff --git a/bee.functional/build.gradle.kts b/bee.functional/build.gradle.kts index 6956d6b..5852f53 100644 --- a/bee.functional/build.gradle.kts +++ b/bee.functional/build.gradle.kts @@ -1,14 +1,19 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jreleaser.model.Active plugins { alias(libs.plugins.kotlin.jvm) - java alias(libs.plugins.spring.boot).apply(false) alias(libs.plugins.spring.dependencymanagement) + alias(libs.plugins.jreleaser) + `maven-publish` + signing + java } group = "com.beeproduced" version = libs.versions.bee.built.get() +description = "Functional kotlin bindings, integration with DGS, `bee.persistent` & more." java.sourceCompatibility = JavaVersion.VERSION_17 java.targetCompatibility = JavaVersion.VERSION_17 tasks.withType().configureEach { @@ -61,11 +66,17 @@ sourceSets { } java { + withSourcesJar() + withJavadocJar() registerFeature("dgs") { usingSourceSet(sourceSets["dgs"]) + withSourcesJar() + withJavadocJar() } registerFeature("persistent") { usingSourceSet(sourceSets["persistent"]) + withSourcesJar() + withJavadocJar() } } @@ -100,3 +111,85 @@ tasks.withType { // } // // tasks.check { dependsOn(dgsTestTask) } + +// Based on https://www.tschuehly.de/posts/guide-kotlin-gradle-publish-to-maven-central/#51-generate-javadocs-and-sources-jars +publishing { + publications { + create("Maven") { + from(components["java"]) + description = project.description + } + withType { + pom { + packaging = "jar" + name.set(project.name) + description.set(project.description) + url.set("https://github.com/bee-produced/bee-built") + licenses { + license { + name.set("MIT license") + url.set("https://opensource.org/licenses/MIT") + } + } + developers { + developer { + id.set("kurbaniec") + name.set("Kacper Urbaniec") + email.set("kacper.urbaniec@beeproduced.com") + } + } + scm { + connection.set("scm:git:git@github.com:bee-produced/bee-built.git") + developerConnection.set("scm:git:ssh:git@github.com:bee-produced/bee-built.git") + url.set("https://github.com/bee-produced/bee-built") + } + } + } + } + repositories { + maven { + url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI() + } + } +} + +jreleaser { + project { + copyright.set("bee produced") + } + gitRootSearch.set(true) + signing { + active.set(Active.ALWAYS) + armored.set(true) + } + deploy { + maven { + nexus2 { + create("maven-central") { + active.set(Active.ALWAYS) + url.set("https://s01.oss.sonatype.org/service/local") + closeRepository.set(true) + releaseRepository.set(true) + stagingRepositories.add("build/staging-deploy") + } + } + } + } +} + +// Invalid pom is produced when using both the dependency management plugin and Gradle's bom support +// See: https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/257#issuecomment-895790557 +tasks.withType().all { + doLast { + val file = file("${layout.buildDirectory.get().asFile.toURI()}/publications/Maven/pom-default.xml") + var text = file.readText() + val regex = "(?s)(.+?)(.+?)(.+?)".toRegex() + val matcher = regex.find(text) + if (matcher != null) { + text = regex.replaceFirst(text, "") + val firstDeps = matcher.groups[2]!!.value + text = regex.replaceFirst(text, "$1$2$firstDeps$3") + } + file.writeText(text) + } +} \ No newline at end of file diff --git a/bee.generative/build.gradle.kts b/bee.generative/build.gradle.kts index 541db8b..b076289 100644 --- a/bee.generative/build.gradle.kts +++ b/bee.generative/build.gradle.kts @@ -1,7 +1,11 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jreleaser.model.Active plugins { alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.jreleaser) + `maven-publish` + signing java `java-gradle-plugin` `kotlin-dsl` @@ -9,6 +13,7 @@ plugins { group = "com.beeproduced" version = libs.versions.bee.built.get() +description = "Plugin for the `bee-built` platform." java.sourceCompatibility = JavaVersion.VERSION_17 java.targetCompatibility = JavaVersion.VERSION_17 tasks.withType().configureEach { @@ -26,10 +31,17 @@ gradlePlugin { register("bee.generative") { id = "bee.generative" implementationClass = "com.beeproduced.bee.generative.BeeGenerativePlugin" + displayName = project.name + description = project.description } } } +java { + withSourcesJar() + withJavadocJar() +} + dependencies { // implementation(kotlin("gradle-plugin")) api(libs.ksp.api) @@ -43,4 +55,95 @@ dependencies { tasks.withType { useJUnitPlatform() +} + +val generateResources by tasks.registering { + val propFile = file("${layout.buildDirectory.get().asFile.toURI()}/generated/bee.generative.properties") + outputs.file(propFile) + doLast { + propFile.parentFile.mkdirs() + propFile.writeText("version=${project.version}") + } +} + +tasks.named("processResources") { + from(generateResources) +} + +// Based on https://www.tschuehly.de/posts/guide-kotlin-gradle-publish-to-maven-central/#51-generate-javadocs-and-sources-jars +publishing { + publications { + create("Maven") { + from(components["java"]) + description = project.description + } + withType { + pom { + packaging = "jar" + name.set(project.name) + description.set(project.description) + url.set("https://github.com/bee-produced/bee-built") + licenses { + license { + name.set("MIT license") + url.set("https://opensource.org/licenses/MIT") + } + } + developers { + developer { + id.set("kurbaniec") + name.set("Kacper Urbaniec") + email.set("kacper.urbaniec@beeproduced.com") + } + } + scm { + connection.set("scm:git:git@github.com:bee-produced/bee-built.git") + developerConnection.set("scm:git:ssh:git@github.com:bee-produced/bee-built.git") + url.set("https://github.com/bee-produced/bee-built") + } + } + } + } + repositories { + maven { + url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI() + } + } +} + +jreleaser { + project { + copyright.set("bee produced") + } + gitRootSearch.set(true) + signing { + active.set(Active.ALWAYS) + armored.set(true) + } + deploy { + maven { + nexus2 { + create("maven-central") { + active.set(Active.ALWAYS) + url.set("https://s01.oss.sonatype.org/service/local") + closeRepository.set(true) + releaseRepository.set(true) + stagingRepositories.add("build/staging-deploy") + } + } + } + } +} + +// Required as plugin markers are only relevant for gradle plugin portal +// https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers +tasks.register("removePluginMetadata") { + doLast { + val dirToRemove = file("${layout.buildDirectory.get().asFile.toURI()}/staging-deploy/bee") + dirToRemove.deleteRecursively() + } +} + +tasks.named("publish") { + finalizedBy("removePluginMetadata") } \ No newline at end of file diff --git a/bee.generative/src/main/kotlin/com/beeproduced/bee/generative/BeeGenerativePlugin.kt b/bee.generative/src/main/kotlin/com/beeproduced/bee/generative/BeeGenerativePlugin.kt index 70fa6f8..03b150f 100644 --- a/bee.generative/src/main/kotlin/com/beeproduced/bee/generative/BeeGenerativePlugin.kt +++ b/bee.generative/src/main/kotlin/com/beeproduced/bee/generative/BeeGenerativePlugin.kt @@ -5,11 +5,10 @@ import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.api.artifacts.dsl.DependencyHandler import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency import org.gradle.kotlin.dsl.closureOf -import org.gradle.kotlin.dsl.getByType +import java.util.Properties /** * @@ -27,9 +26,10 @@ open class BeeGenerativePluginExtension { } open class BeeDependencies(private val dependencies: DependencyHandler) { - operator fun invoke(dependencyNotation: String): Pair { + operator fun invoke(dependencyNotation: String): Triple { val main = dependencies.add("implementation", dependencyNotation) - val processor = dependencies.add("ksp", dependencyNotation, closureOf { + val processorMain = dependencies.add("ksp", dependencyNotation) + val processorCapability = dependencies.add("ksp", dependencyNotation, closureOf { val capabilityNotation = if (version != null) { "$group:$name-processor:$version" } else "$group:$name-processor" @@ -37,23 +37,21 @@ open class BeeDependencies(private val dependencies: DependencyHandler) { requireCapability(capabilityNotation) } }) - return Pair(main, processor) + return Triple(main, processorMain, processorCapability) } } class BeeGenerativePlugin : Plugin{ override fun apply(project: Project) { - // Get version https://discuss.gradle.org/t/version-catalog-access-from-plugin/43629/4 - val version = project.rootProject - .extensions - .getByType() - .named("libs") - .findVersion("bee-built") - .get() - .displayName + // Get version https://discuss.gradle.org/t/how-can-a-custom-gradle-plugin-determine-its-own-version/36761/3 + val props = Properties() + val propStream = javaClass.classLoader.getResourceAsStream("bee.generative.properties") + propStream?.use { props.load(it) } + val version = props.getProperty("version") + // Adds bee generative to ksp context project.dependencies.add("ksp", "com.beeproduced:bee.generative:$version") - // Allows importing bee generative features easily via `bee´ in dependencies block + // Allows importing bee generative features easily via `beeGenerative´ in dependencies block project.dependencies.extensions.add( "beeGenerative", BeeDependencies(project.dependencies) ) diff --git a/bee.persistent/build.gradle.kts b/bee.persistent/build.gradle.kts index 8129184..4bf0e4a 100644 --- a/bee.persistent/build.gradle.kts +++ b/bee.persistent/build.gradle.kts @@ -1,15 +1,19 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jreleaser.model.Active plugins { alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlin.jpa) alias(libs.plugins.kotlin.spring) + alias(libs.plugins.jreleaser) + `maven-publish` + signing java - // id("org.hibernate.orm") version "6.1.7.Final" } group = "com.beeproduced" version = libs.versions.bee.built.get() +description = "Easier data handling for GraphQL + JPA" java.sourceCompatibility = JavaVersion.VERSION_17 java.targetCompatibility = JavaVersion.VERSION_17 tasks.withType().configureEach { @@ -44,11 +48,17 @@ sourceSets { } java { + withSourcesJar() + withJavadocJar() registerFeature("dgs") { usingSourceSet(sourceSets["dgs"]) + withSourcesJar() + withJavadocJar() } registerFeature("jpa") { usingSourceSet(sourceSets["jpa"]) + withSourcesJar() + withJavadocJar() } } @@ -113,9 +123,67 @@ allOpen { annotation("javax.persistence.Entity") } -// hibernate { -// enhancement { -// enableLazyInitialization(true) -// enableExtendedEnhancement(true) -// } -// } +// Based on https://www.tschuehly.de/posts/guide-kotlin-gradle-publish-to-maven-central/#51-generate-javadocs-and-sources-jars +publishing { + publications { + create("Maven") { + from(components["java"]) + description = project.description + } + withType { + pom { + packaging = "jar" + name.set(project.name) + description.set(project.description) + url.set("https://github.com/bee-produced/bee-built") + licenses { + license { + name.set("MIT license") + url.set("https://opensource.org/licenses/MIT") + } + } + developers { + developer { + id.set("kurbaniec") + name.set("Kacper Urbaniec") + email.set("kacper.urbaniec@beeproduced.com") + } + } + scm { + connection.set("scm:git:git@github.com:bee-produced/bee-built.git") + developerConnection.set("scm:git:ssh:git@github.com:bee-produced/bee-built.git") + url.set("https://github.com/bee-produced/bee-built") + } + } + } + } + repositories { + maven { + url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI() + } + } +} + +jreleaser { + project { + copyright.set("bee produced") + } + gitRootSearch.set(true) + signing { + active.set(Active.ALWAYS) + armored.set(true) + } + deploy { + maven { + nexus2 { + create("maven-central") { + active.set(Active.ALWAYS) + url.set("https://s01.oss.sonatype.org/service/local") + closeRepository.set(true) + releaseRepository.set(true) + stagingRepositories.add("build/staging-deploy") + } + } + } + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cf9493d..cfe862f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -bee-built = "0.3.0-SNAPSHOT" +bee-built = "0.3.1-SNAPSHOT" springboot-base = "3.1.4" springboot-dependencymanagement = "1.1.3" kotlin-base = "1.9.10" @@ -85,4 +85,5 @@ spring-boot = { id = "org.springframework.boot", version.ref = "springboot-base" spring-dependencymanagement = { id = "io.spring.dependency-management", version.ref = "springboot-dependencymanagement" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin-base" } dgs-codegen = { id = "com.netflix.dgs.codegen", version.ref = "dgs-codegen" } -ksp = { id = "com.google.devtools.ksp", version.ref = "ksp-base"} \ No newline at end of file +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp-base"} +jreleaser = { id = "org.jreleaser", version = "1.8.0" } \ No newline at end of file