gradle-kotlin-dsl

Configure Jacoco with gradle and kotlin DSL

拟墨画扇 提交于 2020-05-11 18:56:13
问题 I'm trying to configure Jacoco to exclude some classes from analysis but can't find any working example :( I found some samples with afterEvaluate but no success 回答1: src/main/java/org/example/A.java : package org.example; class A { } src/main/java/org/example/B.java : package org.example; class B { } src/test/java/org/example/ExampleTest.java : package org.example; public class ExampleTest { @org.junit.Test public void test() { new A(); new B(); } } build.gradle.kts : plugins { java jacoco }

Include scripts with Gradle Kotlin DSL

那年仲夏 提交于 2020-05-10 04:32:06
问题 I'm trying to start using Kotlin DSL with gradle in the project with the following restrictions: Project has different modules (moreover: sometimes these modules use different plugins, however if two projects uses the same plugin then version of the plugins are the same). Project has internal corporate repositories only (e.g. we don't use jcenter directly, we use proxy for it). What we have with Groovy: Some common configurations items are excluded to the separate scripts. Please check the

How to migrate from Kotlin 1.2 to 1.3 with the kotlin-dsl Gradle plugin?

房东的猫 提交于 2020-03-23 15:37:20
问题 I am currently using the kotlin-dsl Gradle plugin 0.18.2, Kotlin 1.2.51 and Gradle 4.10.2 in my Android project (take a look at the temporary project-setup branch). I like to migrate to Kotlin 1.3 . However, I have difficulties in finding out which combination of version works. I raised the dependencies to their latest version: // in build.gradle.kts: id("org.gradle.kotlin.kotlin-dsl") version "1.0.4" ... // in build.gradle: org.jetbrains.kotlin:kotlin-stdlib:1.3.10 As soon as I run a Gradle

How to migrate from Kotlin 1.2 to 1.3 with the kotlin-dsl Gradle plugin?

徘徊边缘 提交于 2020-03-23 15:37:20
问题 I am currently using the kotlin-dsl Gradle plugin 0.18.2, Kotlin 1.2.51 and Gradle 4.10.2 in my Android project (take a look at the temporary project-setup branch). I like to migrate to Kotlin 1.3 . However, I have difficulties in finding out which combination of version works. I raised the dependencies to their latest version: // in build.gradle.kts: id("org.gradle.kotlin.kotlin-dsl") version "1.0.4" ... // in build.gradle: org.jetbrains.kotlin:kotlin-stdlib:1.3.10 As soon as I run a Gradle

How to import a helper class in buildSrc/build.gradle.kts, settings.gradle.kts, and build.gradle.kts?

故事扮演 提交于 2020-03-21 06:43:49
问题 I'd like to create a class to help me loading different types of properties ( local.properties , gradle.properties , $GRADLE_HOME/gradle.properties , environment variables, system properties, and custom properties files (maybe in other formats like yml , xml , etc.). Also, I'd like to use this in my buildSrc/build.gradle.kts , settings.gradle.kts , and build.gradle.kts . Please consider that we are using Gradle 6.+ . A simple implementation of this class would be (the full implementation

How to set different applicationId for each flavor combination using flavorDimensions when using Gradle Kotlin-DSL?

杀马特。学长 韩版系。学妹 提交于 2020-03-04 20:34:34
问题 I am converting an Android app to the Gradle Kotlin-DSL by using Kotlinscript files. I have a problem converting our applicationId logic. We don't use the defaultConfiguration with applicationId plus various applicationIdSuffix for our flavors but a custom logic. The logic is described in this SO answer, here is the groovy code: flavorDimensions "price", "dataset" productFlavors { free { dimension "price" } paid { dimension "price" } dataset1 { dimension "dataset" } dataset2 { dimension

Gradle Kotlin DSL: how to configure subprojects using typesafe api

浪子不回头ぞ 提交于 2020-02-22 05:29:44
问题 Gradle 6.1.1 I have been trying to convert my projects' Gradle files using Kotlin DSL in a type-safe manner but so far failed. All my projects are multi-project builds in Java. The idea is to factorize/deduplicate the common configurations of the submodules (whether in the 'subprojects' block of the root module or in a separate 'kts' file I don't care). The official documentation states that it is not possible to have type-safe with 'subprojects' and apply(from = 'shared.gradle.kts') (https:/

Kotlin not able to convert gradle's Action class to a lambda

本小妞迷上赌 提交于 2020-02-02 12:06:36
问题 So, while this is quite a kotlin-dsl for gradle specific issue, I think it overall applies to the kotlin language itself, so I am not going to use that tag. In the gradle API, the class Action<T> is defined as: @HasImplicitReceiver public interface Action<T> { /** * Performs this action against the given object. * * @param t The object to perform the action on. */ void execute(T t); } So ideally, this should work in kotlin (because it is a class with a SAM): val x : Action<String> = { println

Kotlin not able to convert gradle's Action class to a lambda

大兔子大兔子 提交于 2020-02-02 12:06:09
问题 So, while this is quite a kotlin-dsl for gradle specific issue, I think it overall applies to the kotlin language itself, so I am not going to use that tag. In the gradle API, the class Action<T> is defined as: @HasImplicitReceiver public interface Action<T> { /** * Performs this action against the given object. * * @param t The object to perform the action on. */ void execute(T t); } So ideally, this should work in kotlin (because it is a class with a SAM): val x : Action<String> = { println

kotlin DSL retrieving keys from other file

ぐ巨炮叔叔 提交于 2020-01-16 08:35:28
问题 I am trying to switch my gradle files to Kotlin DSL. My project is making call to an API. In build.gradle(app) I had a function to retrieve an api key stored in an other file keys.properties . After some problem (for example) I rewrote the function to get the key. I wrote the following function in build.gradle.kts : import import java.io.File fun readFileLineByLineUsingForEachLine2(fileName: String): HashMap<String, String>{ val items = HashMap<String, String>() File(fileName).forEachLine {