Questions tagged [gradle-kotlin-dsl]
Kotlin language support for Gradle build scripts.
928
questions
0
votes
0
answers
5
views
shadowJar minimize() removes all class files
I'm using shadowJar in my Gradle-built Kotlin project and the fat jar it produces seems to work fine. When I enable minimization though, the produced jar has no class files in it.
Here's how it's ...
0
votes
0
answers
14
views
How to make annotationProcessor transitive from custom lib
I'm using my own lib, which configuring core dependencies and other stuff for micro-service product (some kind of custom starter).
To make dependencies transitive (auto-import in inherited projects) i'...
0
votes
1
answer
54
views
gRPC UnsupportedAddressTypeException, but only when packaged with shadowJar
I have a simple gRPC client packaged in a jar by Gradle with shadowJar. When I run the main() with IntelliJ, the RPC is sent successfully. When I run it with java -jar, I get an exception:
Update: I ...
0
votes
0
answers
16
views
Add files from build directory to jar using gradle kotlin
I have some files in directory build/schema and I want them to be included in the jar file formed with gradle build kotlin file. How can this be acheived?
1
vote
0
answers
56
views
+50
Add files to jar in gradle kotlin
My usecase is to copy files from another dependency and add it to the jar. For a build.gradle file it is done as
task copyConfiguration(type: Copy) {
from("${brazilGradle.path('[ABC]pkg.src')}&...
0
votes
1
answer
48
views
JaCoCo with Gradle Kotlin multi-module Android project - what does isTestCoverageEnabled actually do?
I'm configuring an Android multi-module Gradle project that uses Kotlin for both the app AND the Gradle build files (gradle.build.kts).
I'm using Gradle 7.3.3.
First I add the Jacoco plugin to the ...
0
votes
1
answer
20
views
How to setup arch unit in a multi module project
I am currently developing an Android app (= multi module gradle project).
I am trying to introduce ArchUnit, but I have problems accessing the test sourceset of all other modules....
As I am using ...
1
vote
1
answer
29
views
How to import local .aar file to gradle.kts with exclusion?
I'd like to import a local .aar to my Android project, and want to exclude a few transitive dependencies from it.
In Groovy I can do
implementation(name: "abc", ext: "aar") {
...
0
votes
1
answer
30
views
Executing task on its own is working but not when executed from another one
I have three Gradle tasks if I execute them one by one on its own then its working. But when I execute them from another task then its not working. Here is how my task looks like
import com.github....
0
votes
1
answer
28
views
Multi module gradle: how to run module A before compiling modules B in a multi module project
We have a multi-module project in gradle. We have a "data" module that needs to be compiled (simple java 11 app) then run.
When we run java -jar data.jar after compiling the data module ...
1
vote
1
answer
99
views
Gradle build failed at :compileJava: `No matching variant`
I'm trying making a library for Minecraft Bukkit (Paper) plugin. I'm trying to build a jar file, but Gradle gives me this error:
Execution failed for task ':compileJava'.
> Could not resolve all ...
0
votes
1
answer
31
views
Can't reference import org.springframework.data.redis even though I have correct dependency
I'm new to IntelliJ/Kotlin; in my .kts file:
plugins {
id("java")
id("io.spring.dependency-management") version "1.0.12.RELEASE"
id("org.springframework....
0
votes
1
answer
35
views
Code for different Java versions in same Gradle Project
Is it possible to create a Gradle Project in a way so that the major part can be used with one Java version (e.g. Java 11) while some parts rely on a higher Java version (e.g. Java 17) and can only be ...
1
vote
0
answers
27
views
In a Kotlin multi-platform (or JS) project, (how) can one pass custom command line arguments to Node.js?
I'm working on a Kotlin multi-platform project, and I need my JS tests to run on Node.js but with custom command line arguments (specifically I need node to run with the --expose-gc flag, because some ...
0
votes
0
answers
44
views
KMM how can I add custom value to Bundle.main.infoDictionary
I have kotlin multiplatform project.
I know that I can read from infoDictionary (infoplist) data in runtime with:
val value = NSBundle.mainBundle.infoDictionary?.get("customValue")
My ...
0
votes
0
answers
59
views
How to include the source set output of one subproject into another?
I have the following project structure where all three subprojects use the java-library plugin and the root project only has an allprojects block that sets the group and version information.
Root ...
0
votes
0
answers
25
views
How to write custom Gradle task to have custom test commands
I'm dealing with a Gradle project with lots of unit tests and a very slow CI pipeline.
I was thinking of improving that by running the tests in parallel in CI, but because of some issues, it seems ...
1
vote
2
answers
132
views
dependency url keeps getting appened to the end of our nexus respository
Migrated to Kotlin .kts and now I'm getting some build issues.
These are some of the errors:
> Could not resolve all files for configuration ':app:stagingNewDesignDebugRuntimeClasspath'.
> ...
2
votes
4
answers
153
views
Converting some code snippet from groovy to kotlin KTS in my build.gradle.kts file
I have the following code in my build.gradle.kts. I have now migrated to kotlin KTS. And need help on translating this code from groovy to kotlin script.
fun getVersionFromGit(fallback: String): ...
0
votes
0
answers
13
views
how can I go from groggy to kotlin Dsl protobuf
I am applying Proto DataStore and I am applying protobuf in my Kotlin Dsl gradle but I can't implement it correctly. enter the code here.
plugins {
id("com.android.library")
id("...
0
votes
2
answers
18
views
TeamCity CI integration between local projects
I have two projects A,B with their own build chains defined in their local .teamcity folders. In addition, A contains a dependency on B which I want to test. How do I set up a build chain that ...
0
votes
0
answers
28
views
facing issue in converting gradle to kotlin dsl
How to convert this to kotlin dsl?
buildTypes {
debug {
minifyEnabled false
}
staging {
debuggable true
minifyEnabled true
...
1
vote
1
answer
89
views
define alias for gradle task with custom argument
I want to run
./gradlew extractMyDeps
instead of
./gradlew :app:dependencies --configuration productionDebugRuntimeClasspath
but I can't pass args to this task via dependOn
How to achieve my goal?
...
1
vote
0
answers
55
views
LibraryExtension not found when using catalog version and kotlin dsl
I'm having trouble using Catalog Version in gradle, which I'm trying to apply to my project. I took an example from here https://github.com/android/nowinandroid but when I get an error like in :
...
0
votes
0
answers
72
views
Could not resolve com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5
The app was built in API level 28. Current Android Studio version is 2021.2.1.
Now I have migrated the old code to Androidx. Gradle plugin and all the dependencies are updated properly but getting ...
1
vote
0
answers
29
views
How can I set a project as trusted when using the gradle :runIde task during IntelliJ Plugin Development
the documentation shows that I can configure this via the gui here: https://www.jetbrains.com/help/idea/project-security.html
Each time I have gradle perform :runIde it launches a new IDE instance and ...
0
votes
0
answers
14
views
How to retrieve the number of available Gradle workers in the build script?
How to retrieve the number of available Gradle workers in the build script?
I would like to use this number to adjust maxParallelForks for my test configuration.
0
votes
1
answer
229
views
#Kotlin Could not resolve all files for configuration ':app:debugRuntimeClasspath'
I searched a lot, but I don't have a solution for this error:
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files ...
4
votes
0
answers
155
views
KMM Project: Expected class has no actual declaration in module for JVM
I have a KMM project that is working perfectly except Android Studio gives an error on every expect function/value in my project complaining the actual version of it doesn't exist for JVM.
The A in a ...
0
votes
0
answers
57
views
Gradle publishing same artifact with different classifier
This is a follow up for:
https://github.com/gradle/gradle/issues/21038
gradle publish jars with different classifiers, dependency missing
demo repo: https://gitlab.com/knyttl/kotlin-1.6.20-publishing-...
0
votes
1
answer
53
views
Unable to apply plugin in gradle init script
Here is my gradle init script.
initscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-...
1
vote
1
answer
341
views
"Unresolved reference: sourceCompatibility" after upgrading Gradle build to Kotlin 1.7.0
Following some answers at Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 I have a Kotlin Gradle DSL script containing
tasks.compileKotlin {
...
2
votes
0
answers
63
views
Gradle Settings plugin extension
I want to create a settings plugin (not project plugin) to simplify some stuff, but I cannot get the configuration clause to work.
This is my plugin (Java code)
public class SettingsPlugin implements ...
1
vote
2
answers
151
views
Using flutter module in kotlin multiplatform app
I created an application with kotlin multiplatform and I want now to use flutter to develop the UI once. I followed the tutorial to integrate flutter in an already existing Android app and I choose ...
0
votes
2
answers
30
views
how to config jmockit javaagent in gradle-kotin-dsl
How do i config jmokit javaagent in gradle-kotin-dsl.
I tried the follow example,but it doesn't work.
In file build.gradle.kts,the follow syntax to config javaagent is wrong.
tasks {
test {
...
1
vote
1
answer
172
views
How can I apply a plugin to itself using Kotlin DSL?
We have an existing plugin project which configures various things (including static analysis), where we want to apply the plugin to the project itself.
The way this currently works for plugins ...
1
vote
1
answer
88
views
Use enforcePlatform in Kotlin multiplatform [duplicate]
How can I use enforcePlatform function in Kotlin multiplatform?
This works well:
plugins {
kotlin("js")
}
dependencies {
fun kotlinw(target: String): String =
"org....
0
votes
0
answers
67
views
buildSrc not considering distribution url from gradle-wrapper.properties
I'm using compose for android development. I have configured private repo path for the distribution url in gradle-wrapper.properties file.
I have been using kotlin-dsl for the gradle scripts and ...
0
votes
0
answers
79
views
In gradle, how to access build profile properties in buildSrc from settings.gradle.kts?
In this tutorial, a mechanism was proposed to call functions under buildSrc directory in build.gradle.kts file:
(under buildSrc)
class Versions(properties: Map<String, *>) {
// access ...
1
vote
1
answer
32
views
A gradle project compiles successfully, how to replicate this success if it is included in another project?
The project I intend to include is the latest version of splain:
https://github.com/tek/splain
Which is built with gradle, and has the following extra task definition (in gradle kts):
// invoke
...
0
votes
0
answers
138
views
Gradle plugins DSL block plugins not working for buildSrc
I am discovering the new plugins declaration in Gradle. First applying below in the root Gradle file
plugins {
id("com.android.application") version "7.2" apply false
id(&...
0
votes
1
answer
142
views
How can I use a maven dependency package that has been published to GitLab with Gradle Kotlin?
(for reference I am using: IntelliJ as my IDE, Kotlin as the language, and Gradle Kotlin for build)
The package is successfully published to the GitLab Project's Package Registry, it is listed as a ...
0
votes
0
answers
59
views
Maven Publish KTS - SourceSet with name 'main' not found
I want to create a script for publish a library on kotlin.
I am trying to convert this gradle config to gradle-kotlin (kts) following the gradle documentation (https://docs.gradle.org/current/...
0
votes
0
answers
35
views
Debugging Gradle exclusion of transitive dependency
How can I debug exclusion of dependencies in Gradle 7 when using Kotlin?
This problem is driving me nuts: Some exclusions are considered, others are simply ignored.
I tried the usual
plugins {
`...
1
vote
1
answer
124
views
Set different schema for different build types in Apollo v3 Android
I have 2 GraphQl schemas for debug and prod versions of my app. Also I have 2 build types: debug and release. Obviously, I want to use the debug-schema with the debug build-type, and the production-...
1
vote
1
answer
117
views
How do I add new type-safe accessors to a Gradle Project?
We have a plugin which defines additional properties and adds them as extension properties, like:
project.extra["copyright"] = "Copyright ..."
Then in the build scripts, I can ...
0
votes
0
answers
223
views
All .kts files become unresolved after upgrading to gradle 7.42, how can I solve this problem?
When I upgrade gradle version from 7.33 to 7.41 or higher. Every line in every gradle.kts become unresolved. I tried to replace all lines(except namespace) in corresponding files of a new project ...
0
votes
0
answers
48
views
How can I refer to libraries defined in a shared Gradle build plugin from another build script?
I'm trying to define libraries in a common location. So in an our.libraries.gradle.kts script in a shared build plugin, I have this:
inner class Libraries {
val junit get() = ...
val ...
0
votes
0
answers
167
views
UnmarshalException: Error unmarshaling return header
When ever I run backend server in Spring boot, I'm getting this error:
Compilation with Kotlin compile daemon was not successful
java.rmi.UnmarshalException: Error unmarshaling return header; nested ...
0
votes
0
answers
31
views
Using Static Build Config Values With Debug Build Clarification
I needed a sanity check on the Android documentation's recommendation to Use static build config values with your debug build
An engineer on my team is insisting that the versionName and versionCode ...