this is my gradle ,I use kotlin plus graphql
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.7.5"
id("io.spring.dependency-management") version "1.0.15.RELEASE"
id("com.apollographql.apollo3").version("3.7.0")
kotlin("jvm") version "1.6.21"
kotlin("plugin.spring") version "1.6.21"
}
java.sourceCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test")
implementation("com.apollographql.apollo3:apollo-runtime:3.7.0")
implementation("org.reactivestreams:reactive-streams:1.0.3")
runtimeOnly("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.6.0")
}
apollo {
packageName.set("com.example")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
I go generateServiceApolloSchema
and in schema.graphqls file I see this error
Could not find a schema, make sure to add dependencies to the apolloSchema configuration
I have json file under src/main/graphql
Related
I'm trying to setup a micronaut project.
The project is using Gradle and Kotlin.
I'm using the Micronaut CLI to generate the project, but after the initial setup with the CLI I'm getting this warning:
> Task :kaptKotlin
warning: The following options were not recognized by any processor: '[micronaut.processing.incremental, micronaut.processing.module, kapt.kotlin.generated, micronaut.processing.annotations]'
The following options were not recognized by any processor: '[micronaut.processing.incremental, micronaut.processing.module, kapt.kotlin.generated, micronaut.processing.annotations]'
I've used this command to setup the project:
mn create-app com.my.example --build=gradle --lang=kotlin
build.gradle file:
plugins {
id("org.jetbrains.kotlin.jvm") version "1.4.32"
id("org.jetbrains.kotlin.kapt") version "1.4.32"
id("com.github.johnrengelman.shadow") version "7.0.0"
id("io.micronaut.application") version "1.5.3"
id("org.jetbrains.kotlin.plugin.allopen") version "1.4.32"
}
version = "0.1"
group = "com.my"
repositories {
mavenCentral()
}
micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("com.my.*")
}
}
dependencies {
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("javax.annotation:javax.annotation-api")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
runtimeOnly("ch.qos.logback:logback-classic")
implementation("io.micronaut:micronaut-validation")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
}
application {
mainClass.set("com.my.ApplicationKt")
}
java {
sourceCompatibility = JavaVersion.toVersion("14")
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "14"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "14"
}
}
}
Micronaut version: 2.5.8
Java version: 14
Gradle version: 7.0
Kotlin version: 1.4.32
Anyone knows what could be the problem?
I'm trying to simplify some of my Gradle builds. A typical build.gradle.kts looks like
plugins {
base
idea
java
id("biz.aQute.bnd.builder")
kotlin("jvm")
id("org.jetbrains.dokka")
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("org.osgi:osgi.annotation:7.0.0")
implementation("org.osgi:osgi.cmpn:7.0.0")
implementation("org.osgi:osgi.core:7.0.0")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.4.2")
}
tasks.compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
}
tasks.compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
}
version = "0.0.0"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.jar {
archiveBaseName.set("project.name.api")
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
I'm trying to reduce repetition, specifically with the tasks.compileKotlin and tasks.compileTestKotlin blocks.
I've read that I should use the buildSrc folder for defining simplifications like this. The structure of the folder is
buildSrc/
src/
main/
kotlin/
Example.kt
build.gradle.kts
Example.kt
import org.gradle.kotlin.dsl.KotlinBuildScript
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.kotlin
//import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
fun KotlinBuildScript.configureModule() {
tasks.named<KotlinCompile>("compileKotlin") {
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
}
}
buildSrc/build.gradle.kts
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}
But this setup just results in an Unresolved reference: kotlin error during the build.
I can't figure out what I need to change where in order to successfully reference the KotlinCompile class. I tried specifying the kotlin plugin, idea plugin, and tried adding dependencies to kotlin in the buildSrc/build.gradle.kts, but I haven't been able to find any examples on github or google on how to set this up.
I'd like to do the same for most of the build script as well, not just the KotlinCompile task, so any guidance on what or how I should search for these other task types would be appreciated.
Looks like you're creating an extension function on KotlinBuildScript which may or may not be the issue. Regardless, there's no need for extension functions since you can just use the DSL directly.
Gradle calls the shared build logic convention plugins: https://docs.gradle.org/current/samples/sample_convention_plugins.html#compiling_convention_plugins
So your Example.kt would become kotlin-conventions.gradle.kts:
// kotlin-conventions.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
}
}
Then inside your main Gradle build file, apply the convention plugin:
// build.gradle.kts
plugins {
`kotlin-conventions`
}
Credit goes to Francisco Mateo's answer, this exists only for a complete final product
One additional problem I was having, was that I was trying to use kotlin-gradle-plugin:1.4.31 in by buildSrc/build.gradle.kts file. There's some weird bug there, but downgrading slightly to 1.4.30 resolved the contributing issue.
My final configuration looks like
buildSrc/build.gradle.kts
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}
dependencies {
implementation("biz.aQute.bnd.builder:biz.aQute.bnd.builder.gradle.plugin:5.3.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20")
}
Each of the external plugins required in the subsequent plugin file need to be specified as dependencies in the buildSrc/build.gradle.kts file, as specified in the Applying an external plugin in precompiled script plugin section from the link in Francisco's answer.
The plugin file also needs the .gradle.kts extension (if using Kotlin), so my buildSrc/src/main/kotlin/hummingbird-conventions.gradle.kts file looks like
plugins {
base
idea
java
id("biz.aQute.bnd.builder")
id("org.jetbrains.dokka")
kotlin("jvm")
}
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("org.osgi:osgi.annotation:7.0.0")
implementation("org.osgi:osgi.cmpn:7.0.0")
implementation("org.osgi:osgi.core:7.0.0")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.4.2")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
}
named<Test>("test") {
useJUnitPlatform()
}
}
And I could apply this in the subproject's build.gradle.kts file like
plugins {
`hummingbird-conventions`
}
where the plugin id is the file name in the buildSrc src folder.
I just started using Micronaut, but I can't get a simple endpoint to work. I get this response for http://localhost:8901/game_compositions/
{
"message": "Page Not Found",
"_links": {
"self": {
"href": "/game_compositions/",
"templated": false
}
}
}
I have seen a few other questions here about the same response but none of them helped me. I have annotation processor activated for my build and I do not return null.
I assume I have some simple stupid mistake, but I can't find it. According to the sample projects I seem to have all I need.
This is my project:
Controller:
import io.micronaut.http.MediaType
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import io.micronaut.http.annotation.Produces
#Controller("/game_compositions")
class CompositionsController {
#Produces(MediaType.APPLICATION_JSON)
#Get(uri = "/")
fun getCompositions(): Iterable<String> {
return listOf("something")
}
}
Build.gradle (mostly autogenerated from the https://micronaut.io/launch/ site, so there might be some unnecessary stuff there for a simple service. Feel free to point it out)
plugins {
id("io.micronaut.application") version "1.2.0"
kotlin("jvm") version "1.4.10"
kotlin("kapt") version "1.4.10"
kotlin("plugin.allopen") version "1.4.10"
}
version = "0.1"
group = "com.example.backend"
val kotlinVersion=project.properties.get("kotlinVersion")
repositories {
mavenCentral()
jcenter()
}
micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("com.example.backend.*")
}
}
dependencies {
implementation("io.micronaut:micronaut-validation")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation("io.micronaut.sql:micronaut-hibernate-jpa")
runtimeOnly("org.mariadb.jdbc:mariadb-java-client")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
}
application {
mainClass.set("com.example.backend.ApplicationKt")
}
java {
sourceCompatibility = JavaVersion.toVersion("14")
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "14"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "14"
}
}
}
Application.yml (the database connection is so far unused untested)
micronaut:
application:
name: Backend
server:
port: 8901
datasources:
default:
url: jdbc:mysql://localhost:3306/db
username: root
password: root
driver-class-name: org.mariadb.jdbc.Driver
jpa:
default:
properties:
hibernate:
hbm2ddl:
auto: none
show_sql: true
Thanks to Jeff Scott Brown in the comments I have been able to determine that the order of the plugins is the problem. I was not aware that the order mattered in gradle. Apparently Micronaut requires the kapt plugin to be added first. Anyone with more insight in to this is welcome to post a better answer, for me it worked to change the start of my gradle file to this:
plugins {
kotlin("jvm") version "1.4.10"
kotlin("kapt") version "1.4.10"
id("io.micronaut.application") version "1.2.0"
kotlin("plugin.allopen") version "1.4.10"
}
Edit: An important note if anyone attempts to use my gradle file. It turns out kapt does not support java 14 and that caused some very hard to track down trouble for me. This is my current working gradle file:
plugins {
kotlin("jvm") version "1.4.10"
kotlin("kapt") version "1.4.10"
kotlin("plugin.allopen") version "1.4.10"
kotlin("plugin.jpa") version "1.4.10"
id("io.micronaut.application") version "1.2.0"
}
version = "0.1"
group = "com.example.backend"
val kotlinVersion: String by project
repositories {
mavenCentral()
jcenter()
}
micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("com.example.backend.*")
}
}
dependencies {
annotationProcessor("io.micronaut.data:micronaut-data-processor")
implementation("io.micronaut:micronaut-validation")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation("io.micronaut.sql:micronaut-hibernate-jpa")
implementation("io.micronaut.data:micronaut-data-hibernate-jpa")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
runtimeOnly("org.mariadb.jdbc:mariadb-java-client")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
}
application {
mainClass.set("com.example.backend.ApplicationKt")
}
java {
sourceCompatibility = JavaVersion.toVersion("11")
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
}
I downloaded from micronaut.lanch a simple grpc project and I can build it until I add Kotlin gRPC plugin.
Beyond the changes in build.gradle.kts, there is nothing else than the original scafolded project.
I edited in build.gradle.kts.
Firstly, in order to match IntelliJ Kotlin version
plugins {
id("org.jetbrains.kotlin.jvm") version "1.4.21"
id("org.jetbrains.kotlin.kapt") version "1.4.21"
id("org.jetbrains.kotlin.plugin.allopen") version "1.4.21"
Seconddly, added folder for kotlin grpc proto autogenerated files
sourceSets {
main {
java {
...
srcDirs ("build/generated/source/proto/main/grpckt")
And finally
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.14.0"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.33.1"
}
id("grpckt")
{ artifact = "io.grpc:protoc-gen-grpc-kotlin:0.1.2" }
}
generateProtoTasks {
ofSourceSet("main").forEach {
it.plugins {
// Apply the "grpc" plugin whose spec is defined above, without options.
id("grpc")
id("grpckt")
}
}
}
}
The result while building either from INtelliJ or straigh from command line is
C:\_d\toLearn\kafka-proto\build\tmp\kapt3\stubs\main\com\test\KafkaProtoServiceGrpcKt.java:35: error: incompatible types: NonExistentClass cannot be converted to Annotation
#error.NonExistentClass()
*** edited
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
dependsOn ="generateProto" //how add this ?????
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
}
*** EDIT 2
I tried another project. I started from scratch and I am stuck on same issue again.
Here is the build.gradle
plugins {
id("org.jetbrains.kotlin.jvm") version "1.4.10"
id("org.jetbrains.kotlin.kapt") version "1.4.10"
id("org.jetbrains.kotlin.plugin.allopen") version "1.4.10"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("io.micronaut.application") version "1.2.0"
id("com.google.protobuf") version "0.8.13"
}
version = "0.1"
group = "com.tolearn"
repositories {
mavenCentral()
jcenter()
}
micronaut {
testRuntime("junit5")
processing {
incremental(true)
annotations("com.tolearn.*")
}
}
//https://stackoverflow.com/a/55646891/4148175
//kapt {
// correctErrorTypes true
//}
dependencies {
//implementation("io.grpc:protoc-gen-grpc-kotlin:1.0.0")
implementation("io.micronaut:micronaut-validation")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut.grpc:micronaut-grpc-runtime")
implementation("javax.annotation:javax.annotation-api")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-tracing")
runtimeOnly("io.jaegertracing:jaeger-thrift")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
}
application {
mainClass.set("com.tolearn.ApplicationKt")
}
java {
sourceCompatibility = JavaVersion.toVersion("11")
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
dependsOn ':generateProto'
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
}
sourceSets {
main {
java {
srcDirs("build/generated/source/proto/main/grpc")
srcDirs 'build/generated/source/proto/main/grpckt'
srcDirs("build/generated/source/proto/main/java")
}
}
}
protobuf {
protoc { artifact = "com.google.protobuf:protoc:3.14.0" }
plugins {
grpc { artifact = "io.grpc:protoc-gen-grpc-java:1.33.1" }
grpckt { artifact = "io.grpc:protoc-gen-grpc-kotlin:1.0.0:jdk7#jar"}
}
generateProtoTasks {
all()*.plugins {
grpc {}
grpckt {}
}
}
}
The issue is raised on autogenerated stub
Here is the full code github
I fixed the issue by adding api("io.grpc:grpc-kotlin-stub:1.0.0") Thanks to https://github.com/grpc/grpc-kotlin/issues/220 help.
So my build.gradle is now:
plugins {
id("org.jetbrains.kotlin.jvm") version "1.4.10"
id("org.jetbrains.kotlin.kapt") version "1.4.10"
id("org.jetbrains.kotlin.plugin.allopen") version "1.4.10"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("io.micronaut.application") version "1.2.0"
id("com.google.protobuf") version "0.8.13"
}
version = "0.1"
group = "com.tolearn"
repositories {
mavenCentral()
jcenter()
}
micronaut {
testRuntime("junit5")
processing {
incremental(true)
annotations("com.tolearn.*")
}
}
//https://stackoverflow.com/a/55646891/4148175
//https://kotlinlang.org/docs/reference/kapt.html
//kapt {
// correctErrorTypes true
// useBuildCache = false
//}
dependencies {
implementation("io.grpc:protoc-gen-grpc-kotlin:1.0.0")
api("io.grpc:grpc-kotlin-stub:1.0.0")
implementation("io.micronaut:micronaut-validation")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut.grpc:micronaut-grpc-runtime")
implementation("javax.annotation:javax.annotation-api")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-tracing")
runtimeOnly("io.jaegertracing:jaeger-thrift")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
}
application {
mainClass.set("com.tolearn.ApplicationKt")
}
java {
sourceCompatibility = JavaVersion.toVersion("11")
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
dependsOn ':generateProto'
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
}
sourceSets {
main {
java {
srcDirs("build/generated/source/proto/main/grpc")
srcDirs 'build/generated/source/proto/main/grpckt'
srcDirs("build/generated/source/proto/main/java")
}
}
}
protobuf {
protoc { artifact = "com.google.protobuf:protoc:3.14.0" }
plugins {
grpc { artifact = "io.grpc:protoc-gen-grpc-java:1.33.1" }
grpckt { artifact = "io.grpc:protoc-gen-grpc-kotlin:1.0.0:jdk7#jar"}
}
generateProtoTasks {
all()*.plugins {
grpc {}
grpckt {}
}
}
}
I'm trying to create a runnable jar with Kotlin.
My gradle.build is this:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
}
group 'com.github.dynamik'
version '1.0-SNAPSHOT'
apply plugin: 'application'
apply plugin: 'kotlin'
mainClassName = "interpreter.Repl"
repositories {
mavenCentral()
maven { setUrl("https://dl.bintray.com/hotkeytlt/maven") }
}
configurations {
ktlint
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile 'com.github.h0tk3y.betterParse:better-parse-jvm:0.4.0-alpha-3'
// https://mvnrepository.com/artifact/junit/junit
testCompile group: 'junit', name: 'junit', version: '4.4'
ktlint "com.github.shyiko:ktlint:0.31.0"
implementation 'com.github.ajalt:clikt:1.7.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.0'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
run {
standardInput = System.in
}
jar {
manifest {
attributes 'Main-Class': 'interpreter.Repl'
}
}
(As it stands, when I do ./gradlew run, everything works as expected.)
I'm reading an article here on how to proceed, and it says to do: java -jar <MY_PROJECT_NAME>.jar.
I don't quite understand this -- where do we run this? I tried running it from my project root and I got an error:
Error: Unable to access jarfile <my_jarname>.jar
As of Gradle 5.4.1, a build.gradle.kts would need a section like this:
tasks.register<Jar>("uberJar") {
archiveClassifier.set("uber")
manifest {
attributes(
"Main-Class" to "mytest.AppKt",
"Implementation-Title" to "Gradle",
"Implementation-Version" to archiveVersion
)
}
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}
Ok, I figured it out :)
So, the way to create a jar is to go: ./gradlew build. This creates a jar in build/libs.
The problem is, when running that jar, one would run into an exception about java.lang.intrinsics because the kotlin stdlib hasn't been packed into the jar.
While there is a way to manually accomplish that, I found the easiest solution is to simply use the shadowjar plugin.
My build.gradle ended up looking like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
}
group 'com.github.dynamik'
version '1.0-SNAPSHOT'
apply plugin: 'application'
apply plugin: 'kotlin'
apply plugin: 'java'
mainClassName = "interpreter.Repl"
repositories {
mavenCentral()
jcenter()
maven { setUrl("https://dl.bintray.com/hotkeytlt/maven") }
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
configurations {
ktlint
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile 'com.github.h0tk3y.betterParse:better-parse-jvm:0.4.0-alpha-3'
// https://mvnrepository.com/artifact/junit/junit
testCompile group: 'junit', name: 'junit', version: '4.4'
ktlint "com.github.shyiko:ktlint:0.31.0"
implementation 'com.github.ajalt:clikt:1.7.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.0'
}
apply plugin: 'com.github.johnrengelman.shadow'
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
run {
standardInput = System.in
}
jar {
manifest {
attributes 'Main-Class': 'interpreter.Repl'
}
}
When using a Kotlin main class you need to add a Kt at the end of the class name while referencing it on MANIFEST.
So, if your main class is called interpreter.Repl, use:
jar {
manifest {
attributes 'Main-Class': 'interpreter.ReplKt'
}
}
instead of
jar {
manifest {
attributes 'Main-Class': 'interpreter.Repl'
}
}