Gradle-Kotlin Code Contributions

#1

It’s taking me an embarrassing amount of time and effort to create the JPA (Point) Tutorial with Gradle and Kotlin (build.gradle.kts specifically) as a new Gradle-Kotlin user.

(The Tutorial is straight forward using the native IntelliJ build system.)

First, I’d be tremendously grateful if someone has a Tutorial build.gradle.kts file and would post a copy.

Second, I thought it might be valuable to have a thread where people could post and find Gradle-Kotlin code potentially useful to ObjectDB projects.

The following Tutorial Gradle-Kotlin looks okay to me so far:

Ron

plugins {
    id("java")
}

group = "tutorial"
version = "1.0-SNAPSHOT"


repositories {
    mavenCentral()
}

dependencies {
    testImplementation(platform("org.junit:junit-bom:5.10.0"))

    testImplementation("org.junit.jupiter:junit-jupiter")

}
tasks.jar {
    manifest {
        attributes["Main-Class"] = "tutorial.Main"
    }
}

tasks.test {
    useJUnitPlatform()
}

 

#2

Currently we support only Java and Maven so if you prepare and publish a complete Kotlin version of the tutorial and/or full instructions on how to use ObjectDB with Gradle, it may be useful to other users.

ObjectDB Support
#3

The script below seems to be the minimal build.gradle.kts able to produce the executable JPA (Point) Tutorial.

However, it is incomplete in that it lacks a task to enhance the compiled classes. Deprecated Gradle features incompatible with Gradle 9.0 must also be corrected. The other build tasks will have to be added as well.

I intend to invest the time to learn these tools and I’ll post what I think I’ve learnt for scrutiny.

Please post anything you think might be useful to me or anyone else.

 
plugins {
    id("java")
}
repositories {
    mavenCentral()
    // Custom Maven repository
    maven {
        url = uri("https://m2.objectdb.com")
    }
}
dependencies {
    implementation("com.objectdb:objectdb:2.9.0")
}
#4

This is the minimum build file (build.gradle.kts) you will need to create a competent (enhanced) ObjectDB JPA (Point) Tutorial with Gradle-Kotlin. IntelliJ Idea (free Community Edition) is the compelling IDE choice when working with Gradle-Kotlin. - Ron

plugins {
    id("java")
}
repositories {
    mavenCentral()
    // Custom Maven repository
    maven {
        url = uri("https://m2.objectdb.com")
    }
}
dependencies {
    implementation("com.objectdb:objectdb:2.9.0")
}
tasks.register<JavaExec>("enhance") {
    group = "customTasks"
    mainClass = "com.objectdb.Enhancer"
    classpath = sourceSets["main"].runtimeClasspath
    args = listOf(
        "-cp",
        "build/classes/java/main/tutorial/*"
    )
}
tasks.named("compileJava") { finalizedBy("enhance") }

 

Reply