fwcd / fwcd/kotlin-debug-adapter
Debug a library
- Dominant language
- Kotlin
- Stars
- 150
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
1/ When you build a gradle project with a library I cannot find a way to debug the library. In the default project this is utilities. My pointer to an approach below
2/ It is also a tad annoying to have to quite rightly specify the /app in the configuration. It is the well named just easy to forget when context switching.
```
"version": "0.2.0",
"configurations": [
{
"type": "kotlin",
"request": "launch",
"name": "Kotlin Launch",
"projectRoot": "${workspaceFolder}/app",
"dependantProjectRoots": "utilities;list",
"mainClass": "test.app.AppKt",
}
]
```
Looking at the code it appears that the sourcesRootsOf does not add the dependant project so it cannot find the source. I may well be wrong :) about my approach
```
private fun sourcesRootsOf(projectRoot: Path, dependantProjectRoots: String): Set {
var paths = projectRoot.resolve("src")
.let(Files::list) // main, test
.filter { Files.isDirectory(it) }
.flatMap(Files::list) // kotlin, java
.filter { Files.isDirectory(it) }
.collect(Collectors.toSet())
val projectRootNames = dependantProjectRoots.split(';');
for(projectRootName in projectRootNames) {
val path = Paths.get(projectRoot.getParent().toString(),projectRootName)
val dependantProjectPaths = path.resolve("src")
.let(Files::list) // main, test
.filter { Files.isDirectory(it) }
.flatMap(Files::list) // kotlin, java
.filter { Files.isDirectory(it) }
.collect(Collectors.toSet())
paths = paths.plus(dependantProjectPaths)
}
return paths
}
```
I have modified mine to take a semicolon delimited list to pass the project names and it appears to work. Probably could write better code but just wanted to not use the slowness the is Android Studio.
Any chance you could clarify my findings.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the sourcesRootsOf function and how projectRoot and dependantProjectRoots are supplied from the Kotlin launch configuration. Reproduce debugging a Gradle app that depends on the utilities library, then verify whether dependency source directories are discovered and whether projectRoot can be inferred. Done means the library can be debugged without manually supplying an incorrect or easily forgotten path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100