gradle-kotlin-dsl

How to add new sourceset with gradle kotlin-dsl

元气小坏坏 提交于 2019-12-03 11:02:10
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 You should try the following: java.sourceSets.create("src/gen/java") Hope it's what you need! The answer of @s1m0nw1 is correct to add a new sourceset. But to just add a new source-folder in an existing sourceset, this can be used: java.sourceSets["main"].java

How to add a maven repository by url using kotlinscript DSL (build.gradle.kts)

烂漫一生 提交于 2019-12-03 09:24:44
Whats the equivalent of the following code snippet from a build.gradle in a build.gradle.kts version? repositories { mavenCentral() maven { url '<MAVEN REPO URL>' } } As an addition to the other answers, in #kotlin-dsl/256 shortcut methods were added to the various repository methods to do something like the following: repositories { mavenCentral() maven(url = "<MAVEN REPO URL>") } According to the issue, this was added in the Kotlin DSL version 0.11.1 . The 0.11.x versions were included in the Gradle 4.2 release . To see the Gradle version you are running with your build when using the Gradle

ext in buildscript can not be recognised by Gradle Kotlin DSL

只谈情不闲聊 提交于 2019-12-03 01:24:21
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:kotlin-gradle-plugin:$kotlinVersion") and compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:

How to specify the entry point, Main-Class, for a FatJar using Gradle Kotlin DSL?

跟風遠走 提交于 2019-12-02 09:20:52
How do I specify the Main-Class attribute in the ShadowJar once it's imported ? import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { kotlin("jvm") version "1.2.51" id("com.github.johnrengelman.shadow") version "2.0.4" } group = "xxx.yyy" version = "1.0-SNAPSHOT" repositories { mavenCentral() } dependencies { implementation(kotlin("stdlib-jdk8")) } tasks.withType<KotlinCompile> { kotlinOptions.jvmTarget = "1.8" } tasks.withType<ShadowJar> { baseName = "app" classifier = "inajar" version = "9" //main-class = "foobar" }

how to break from lambda passed to recursive function when provided condition met

我的梦境 提交于 2019-12-02 08:32:58
I am writing a custom loop dsl and I want it's usage to look like below var counter1 = 0 var counter2 = 0 loop { counter1 += 1 println(counter1) stopIf(counter1 == 5) // loop should terminate here and not execute rest of the code if condition matches counter2 += 2 println(counter2) stopIf(counter2 == 8) // loop should terminate here and not execute rest of the code if condition matches } I have following code which does allows me to write stopIf any number of times and anywhere in the loop body but when condition matches it does not terminate immediately but executes rest of the loop body and

Build source jar with Gradle Kotlin DSL?

谁说胖子不能爱 提交于 2019-12-01 20:27:55
问题 This question asks how to build a SourceJar with Gradle. How can I do the same with the Gradle Kotlin DSL? The gradle code would be: task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives sourcesJar archives javadocJar } 回答1: The following will work: val sourcesJar by creating(Jar::class) { dependsOn(JavaPlugin.CLASSES

Can't use project extra properties in plugin block

旧时模样 提交于 2019-12-01 19:03:10
I have a multi-project build, and more often than not I find myself locking versions for artifacts across the board. So in my root project I define something like: project.extra.set("pkgVersions", mapOf( "kotlin" to "1.2.0", "jooq" to "3.10.2" )) val pkgVersions : Map<String, String> by project.extra plugins { base kotlin("jvm") version "1.2.0" apply false } While I can use pkgVersions anywhere, including other subprojects: val pkgVersions by rootProject.extra jooq { version = pkgVersions["jooq"] } I am not able to do so inside a plugin block: plugins { kotlin("jvm") version pkgVersions[

Build source jar with Gradle Kotlin DSL?

为君一笑 提交于 2019-12-01 18:42:42
This question asks how to build a SourceJar with Gradle. How can I do the same with the Gradle Kotlin DSL? The gradle code would be: task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives sourcesJar archives javadocJar } The following will work: val sourcesJar by creating(Jar::class) { dependsOn(JavaPlugin.CLASSES_TASK_NAME) classifier = "sources" from(sourceSets["main"].allSource) } val javadocJar by creating(Jar::class) {

How to build a runnable ShadowJar with a gradle script Kotlin build file?

99封情书 提交于 2019-11-30 19:38:12
Simplest possible Kotlin hello world for gradle script Kotlin : thufir@dur:~/github/gradleScriptKotlin$ thufir@dur:~/github/gradleScriptKotlin$ gradle clean shadowJar;java -jar build/libs/gradleScriptKotlin.jar > Task :compileKotlin Using Kotlin incremental compilation > Task :shadowJar A problem was found with the configuration of task ':shadowJar'. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0. - No value has been specified for property 'mainClassName'. The SimpleWorkResult type has been

Integration tests with Gradle Kotlin DSL

南楼画角 提交于 2019-11-30 13:47:42
I'm using this blog post to configure integration tests for a Spring Boot project, but I'm pretty stuck on declaring the source sets. I also found this post on StackOverflow , but I think I'm a bit further already. My project structure is project |_ src |_ main | |_ kotlin | |_ resources |_ testIntegration | |_ kotlin | |_ resources |_ test | |_ kotlin | |_ resources |_ build.gradle.kts |_ ... other files And build.gradle.kts import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { idea kotlin("jvm") id("org.springframework.boot") version "2.0.5.RELEASE" id("org.jetbrains.kotlin.plugin