gradle-kotlin-dsl

execute JavaExec task using gradle kotlin dsl

跟風遠走 提交于 2019-12-11 12:45:05
问题 I've created simple build.gradle.kts file group = "com.lapots.breed" version = "1.0-SNAPSHOT" plugins { java } java { sourceCompatibility = JavaVersion.VERSION_1_8 } repositories { mavenCentral() } dependencies {} task<JavaExec>("execute") { main = "com.lapots.breed.Application" classpath = java.sourceSets["main"].runtimeClasspath } In src/main/java/com.lapots.breed I created Application class with main method package com.lapots.breed; public class Application { public static void main(String

how to import the ShadowJar plugin for Kotlin (Gradle) builds?

徘徊边缘 提交于 2019-12-11 04:47:44
问题 Build failed: thufir@dur:~/NetBeansProjects/kotlin_dsl$ thufir@dur:~/NetBeansProjects/kotlin_dsl$ gradle clean run > Configure project : e: /home/thufir/NetBeansProjects/kotlin_dsl/build.gradle.kts:4:12: Unresolved reference: github FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'kotlin_dsl'. > Could not open cache directory 74ykawxta6db3b2bfk9grjikp (/home/thufir/.gradle/caches/4.3.1/gradle-kotlin-dsl/74ykawxta6db3b2bfk9grjikp). >

How to add new sourceset with gradle kotlin-dsl

我是研究僧i 提交于 2019-12-09 08:51:59
问题 I want to add a sourceset src/gen/java . With groovy this is rather easy and already described in https://discuss.gradle.org/t/how-to-use-gradle-with-generated-sources/9401/5 sourceSets { gen { java.srcDir "src/gen/java" } } But I stuck with the kotlin-dsl to add a new one. All I've got is: java { sourceSets { } } Can anyone help here to 回答1: You should try the following: java.sourceSets.create("src/gen/java") Hope it's what you need! 回答2: The answer of @s1m0nw1 is correct to add a new

Gradle Kotlin DSL: Define Kotlin version in unique place

故事扮演 提交于 2019-12-09 08:27:27
问题 For describing Gradle build scripts, we can use Kotlin via build.gradle.kts files. It's a common problem to globally define the Kotlin version to be used, both in the dependencies and also in the build plugin section (It's rather uncommon to have different versions in use for the given case). Consider the following code (Gradle 4.3.1): plugins { var pluginVersion = "1.2.30" kotlin("jvm").version(kotlinVersion) // more } var dependencyVersion = "1.2.30" dependencies { compile(kotlin("stdlib",

ext in buildscript can not be recognised by Gradle Kotlin DSL

[亡魂溺海] 提交于 2019-12-09 04:32:24
问题 In these days, I am trying to write some codes to experience the Spring reactive features and kotlin extension in Spring 5, and I also prepared a gradle Kotlin DSL build.gradle.kt to configure the gradle build. The build.gradle.kt is converted from Spring Boot template codes generated by http://start.spring.io. But the ext in the buildscript can not be detected by Gradle. buildscript { ext { } } The ext will cause Gradle build error. To make the variables in classpath("org.jetbrains.kotlin

How to run kotlintest tests using the Gradle Kotlin DSL?

£可爱£侵袭症+ 提交于 2019-12-08 19:44:28
问题 What do I want? I want to run my tests using kotlintest, and I succeeded in running them from IntelliJ by clicking the icon next to the test class. I also have JUnit 5 tests in my project. I am now starting to use the Gradle Kotlin DSL, and I managed to run the Gradle task check which executed the JUnit 5 tasks. What is the problem? The kotlintest test is not run! It is not discovered by Gradle it seems, as a failing test lets the Gradle task succeed. So, How to run kotlintest tests using the

How do I overwrite a task in gradle kotlin-dsl

北城以北 提交于 2019-12-06 00:52:40
In Groovy, I overwrite a task like this: task jar(overwrite: true) { ... } How do I do that with Kotlin-dsl? I know that I can create a task like this: tasks { val jar by creating { ... } } but I can't find the equivalent way to declare it as overwrite, this leads to an error By opening an issue on the kotlin-dsl github I found the correct syntax: tasks.replace("jar") { ... } However, this is the old way and does not work within a tasks { } block, so this issue will be further tracked here 来源: https://stackoverflow.com/questions/48553029/how-do-i-overwrite-a-task-in-gradle-kotlin-dsl

How are gradle extra properties set in the Kotlin DSL?

拟墨画扇 提交于 2019-12-05 16:17:01
问题 I'm trying to organize my build files as I would in groovy, by having values in a separate file to reuse. But I cannot understand the syntax to do the same thing in the kotlin DSL. Here's what I'm using in root build.gradle.kts: applyFrom("config.gradle.kts") buildscript { repositories { google() jcenter() } dependencies { val test = project.extra["minSdkVer"] classpath("com.android.tools.build:gradle:3.0.0-alpha4") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-5") // NOTE: Do

Adding integration tests to Kotlin project using the Kotlin Gradle DSL

旧城冷巷雨未停 提交于 2019-12-04 07:27:23
I would like to add an additional "source set" to a Kotlin project that will contain integration tests. I have seen a few posts that talk about doing it for either a vanilla Java project or for Kotlin but using Groovy rather than the Kotlin Gradle DSL. In summary, using the Kotlin Gradle DSL: how to add an additional "source set" that can contain Kotlin code, Java code & resources for the purpose of separating integration tests from regular unit tests? how to add an additional task and configuration to run the integration tests separately from unit tests? I would expect the directory structure

How are gradle extra properties set in the Kotlin DSL?

 ̄綄美尐妖づ 提交于 2019-12-04 01:48:00
I'm trying to organize my build files as I would in groovy, by having values in a separate file to reuse. But I cannot understand the syntax to do the same thing in the kotlin DSL. Here's what I'm using in root build.gradle.kts: applyFrom("config.gradle.kts") buildscript { repositories { google() jcenter() } dependencies { val test = project.extra["minSdkVer"] classpath("com.android.tools.build:gradle:3.0.0-alpha4") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-5") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files