Hi guys, is it possible to set a breakpoint on a b...
# gradle
g
Hi guys, is it possible to set a breakpoint on a build.gradle.kts file? So we could inpect what is happening on IntelliJ? I was able to do something like that with
build.gradle
but not
build.gradle.kts
, but maybe I missing something.
n
there is a Action in idea called
Debug Build Process
, it is disabled on each restart i think i am not sure you can set breakpoints directly in the build.gradle.kts file but maybe as firs action you could call to some .kt file in
buildSrc
and set a breakpoint there i hav not tried that yet but i know it works for debugging annotation processors
just tested and yes it works to set a breakpoint i nthe buildscript:

https://i.imgur.com/My2IRLl.png

1. double tap shift, search for Debug Build Process and enable it 2. set breakpoints 3. run any gradle task as debug
i tried this i nthe plugins block and there the breakpoint got hit but i nthe rest of the project t seems to not work
e
breakpoints on top level statements are ignored unfortunately, but you can make it work by adding your breakpoint on non-top-level statements see https://youtrack.jetbrains.com/issue/KT-23526
g
Hum, I didn’t know that, thanks @eskatos.
@Nikky, thanks for this tip too. Indeed I tried to do as you but I haven’t success yet. I tried to put breakpoints in several parts of my main build.gradle.kts where I put on a place similar to yours. I tried to dispatch on a debug mode a gradle task in the
run configurations
, are you running the build process this way?
Even with the top level limitation I was hoping to activate at least one breakpoint
my build.gradle.kts is like the following:
Copy code
plugins {
	kotlin("multiplatform") version "1.3.20"
}

group = "com.example"
version = "0.0.1"

allprojects {
	// Workaround to avoid downloading dependencies every time.
	repositories {
		mavenLocal().apply { //I tried to put here
			content { // also here
				excludeGroup("Kotlin/Native")
			}
		}
		maven { //here
			url = uri("<https://dl.bintray.com/soywiz/soywiz>") // here
			content { // and here too
				includeGroup("com.soywiz")
				excludeGroup("Kotlin/Native")
			}
		}
		jcenter() {
			content {
				excludeGroup("Kotlin/Native")
			}
		}
		google().apply {
			content {
				excludeGroup("Kotlin/Native")
			}
		}
	}
}
@Nikky, did you do something more to get the breakpoints working (even if not all works is ok). I tried to enable the “Debug Build Process” in the double shift option. Then I inserted various debugs in the
build.gradle.kts
file and also in some internal classes like
ProjectExtensions
. Then I created a
Gradle
run configuration with the
build
as the task and started this run configuration in debug mode. But it is still not working. Am I missing something? I’m very needing this. Thanks in advance.
n
nah thats exactly what i did, i do not remember doing anything more worst case you can always debug via loads of
logger::lifecycle
calls