Hello everyone, Help! The `kotlin.test` dependency...
# test
o
Hello everyone, Help! The
kotlin.test
dependency in my local maven repository seems to get lost when I switch between projects (some of them use
maven
builds, some use
gradle
builds). the project prompts that
kotlin.test
is not found, and refresh gradle dependencies doesn't fix it, the only way I can fix it is by deleting the
~/.m2/org/jetbrains /kotlin/kotlin-test
folder and reloading the gradle project to fix it. Both my partner and I are experiencing the same issue when running a few specific projects. Has anyone else encountered this or have any ideas on how to resolve it, it's been bugging me for a long time 😞.
👀 1
c
Hi! Gradle shouldn't interact with
~/.m2
at all by default. Dependencies downloaded by Gradle are stored in
~/.gradle/caches
. Can you check if you use something that looks like this anywhere in your projects?
Copy code
repositories {
    mavenLocal()
}
Then, remove the
mavenLocal()
call (keep other repositories). If you had a good reason to have those, it will break elsewhere, but I can't help without knowing why it was done this way.
K 1
o
Our project does introduce mavenLocal, because we have some gradle plugins that we created ourselves and have not been published to the Maven center. We need to build and publish them to the mavenLocal and introduce them.
c
Alternatively, you can use
includeBuild
to link to another Gradle build that isn't published. Depending on what you want to include, it's slightly different. To include another plugin, use something like this with the path of the plugin: https://gitlab.com/opensavvy/automation/gradle-conventions/-/blob/main/settings.gradle.kts?ref_type=heads#L18-L21 You need no other configuration, and as a bonus, it is also recognized by IntelliJ, meaning you will be able to navigate into the plugin etc just like if it was part of the current projet. You don't need to have a specific version of the plugin etc, it will automatically use the version that's available at that path.
o
Thank you very much for your reply and examples! This is the
setting.gradle.kts
before I changed it: https://github.com/Kronos-orm/Kronos-orm/blob/main/settings.gradle.kts I tried deleting
mavenLocal()
in
setting.gradle.kts
and adding
includeBuild("./kronos-gradle-plugin")
, but it seems that the gradle build cannot run after doing this. I know that there is something wrong with my organization of gradle projects, but this is really too difficult for me. Actually, all I want to do is enable a gradle plugin subproject(
kronos-gradle-plugin
) in another subproject (
kronos-testing
) in the root project. I know that publishing to mavenLocal is not a good choice, but I really haven't found a better way. Can
includeBuild
be used for this scenario, or are there other improvements I should make?
c
but it seems that the gradle build cannot run after doing this.
I can't help you without an error message
It looks like
kronos-gradle-plugin
is in the same build: that folder doesn't have a
settings.gradle.kts
. Plugins cannot be used in the same build as they are declared in. You should have a separate
settings.gradle.kts
file in
kronos-gradle-plugin
, then it will work. You can keep it very simple. So, 1. Create
kronos-gradle-plugin/settings.gradle.kts
with the contents:
Copy code
rootProject.name = "kronos-gradle-plugin"

dependencyResolutionManagement {
	repositories {
		mavenCentral()
	}
}
2. Remove
include("kronos-gradle-plugin")
from your root
settings.gradle.kts
3. Include the plugin in your root
settings.gradle.kts
:
Copy code
pluginManagement {
	includeBuild("./kronos-gradle-plugin")
}
o
> I can't help you without an error message > Thanks. The error msg is just like "cannot find kotlin-jvm in following plugin repositories.". I will try your suggestion now. At the same time, I would like to express my great gratitude to you again❤️
c
No problem, I know firsthand how hard it is to understand when you get started 😅 I promise, it gets easier
o
Hello, I'm really sorry to bother you again. As mentioned in: https://github.com/Kronos-orm/Kronos-orm/blob/main/kronos-gradle-plugin/build.gradle.kts, after splitting the project, there are three problems that bother me 1. The plugin dependency
<http://com.vanniktech.maven.publish.xxx|com.vanniktech.maven.publish.xxx>
cannot be found 2.
api(project(xxx))
is no longer effective 3. And the public functions in the outermost buildSrc cannot be read Is there any good solution? Do I need to add some settings
c
Can you create a github issue/pr that describes the problem and ping me there (
@clovis-ai
) ? It's quite a large thing, it's hard to answer via slack
o
Can you create a github issue/pr that describes the problem and ping me there (
@clovis-ai
) ? It's quite a large thing, it's hard to answer via slack
Ok, I'll build a minimal repro as soon as possible
c
kronos-orm is the real project you're having this on, right? It's open source? If so, just create an issue there that details what you want
bonus point: mark it as hacktoberfest 🙂
o
Ok, I'll create an issue now.