gradle-kotlin-dsl

Switching to Kotlin DSL Unresolved reference when trying to access other file

寵の児 提交于 2019-12-24 07:27:09
问题 I have an error when trying to use Kotlin DSL for my gradle files. In build.gradle(app) I have a function to retrieve an api key stored in an file keys.properties , the function in Groovy is the following: // Retrieve key api def getApiKey() { def keysFile = file("keys.properties") def keysProperties = new Properties() keysProperties.load(new FileInputStream(keysFile)) def apiKey = keysProperties['API_KEY'] return apiKey } When switching to Kotlin DSL I naively changed the function as follow:

How to conditionally accept Gradle build scan plugin terms of service in Kotlin DSL?

牧云@^-^@ 提交于 2019-12-24 00:38:39
问题 This basically extends this question to Kotlin DSL instead of Groovy DSL: How does the Groovy DSL solution of if (hasProperty('buildScan')) { buildScan { termsOfServiceUrl = 'https://gradle.com/terms-of-service' termsOfServiceAgree = 'yes' } } translate to Kotlin DSL? The problem I'm running is that the "buildScan" extension or the com.gradle.scan.plugin.BuildScanExtension class cannot statically be used as they are either present or not present depending on whether the --scan command line

How to configure AppEngine Gradle plugin using Kotlin DSL

寵の児 提交于 2019-12-23 10:15:13
问题 As documented on https://cloud.google.com/appengine/docs/standard/java/tools/gradle-reference the AppEngine Gradle plugin offers configuration like: appengine { // App Engine tasks configuration run { // local (dev_appserver) configuration (standard environments only) port = 8080 // default } deploy { // deploy configuration stopPreviousVersion = true // default - stop the current version promote = true // default - & make this the current version } } How should such a configuration look like

How do I overwrite a task in gradle kotlin-dsl

梦想与她 提交于 2019-12-22 10:28:08
问题 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 回答1: 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

How to get ext.* variables into plugins block in build.gradle.kts

点点圈 提交于 2019-12-22 01:42:44
问题 My build file looks like this: val nexusBaseUri: String by extra val gradle_version: String by extra val kotlin_version: String by extra buildscript { val nexusBaseUri by extra { "https://mynexusserver/nexus" } val gradle_version by extra { "4.1" } val kotlin_version by extra { "1.1.4-3" } val springBoot_version by extra { "2.0.0.M3" } repositories { maven { url = uri("$nexusBaseUri/repository/public") } jcenter() maven { url = uri("http://repo.spring.io/snapshot") } maven { url = uri("http:/

Adding integration tests to Kotlin project using the Kotlin Gradle DSL

做~自己de王妃 提交于 2019-12-21 12:32:50
问题 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

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

↘锁芯ラ 提交于 2019-12-21 03:23:22
问题 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>' } } 回答1: 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

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

陌路散爱 提交于 2019-12-18 22:20:24
问题 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. -

Unable to create debug or signed apk

老子叫甜甜 提交于 2019-12-13 09:47:38
问题 Can anyone guide me through this issue as I am unable to create apk through Android Studio ? Please.... ERROR: Program type already present: kotlin.StandardKt__SynchronizedKt > Task :app:multiDexListDebug FAILED Task :app:multiDexListDebug in app Finished :app:multiDexListDebug (Thread[Daemon worker Thread 2,5,main]) completed. Took 2.62 secs. AAPT2 aapt2-3.5.2-5435860-linux Daemon #0: shutdown FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app

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

无人久伴 提交于 2019-12-13 03:33:06
问题 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