jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to Resolve Kotlin Lint Plugin

VahidGarousi opened this issue · comments

Description:
I'm facing an issue when trying to build my project using Gradle. The build fails with the following error message:

Plugin [id: 'org.jmailen.kotlinte', version: '3.16.0'] was not found in any of the following sources:

I have verified that my Gradle configuration is correct, and the plugin repository is accessible. However, the plugin doesn't seem to be resolving correctly. I'm using Gradle version 8.1.1 and Kotlin version 1.9.10.

Steps to Reproduce:

Expected Behavior:
The Kotlin Lint plugin should be resolved correctly, and the build should succeed.

Actual Behavior:
The build fails with the error mentioned above.

i want to mention that:

plugins {
    libs.plugins.apply {
        alias(android.application) apply false
        alias(kotlin.parcelize) apply false
        alias(android.library) apply false
        alias(kotlin.android) apply false
        alias(hilt.android) apply false
        alias(kapt) apply false
//        id("org.jmailen.kotlinter") version "3.16.0" apply false   // Works fine!
        alias(org.jmailen.kotlinter) // Build failed
        alias(libs.plugins.detekt) apply false
    }
}

Environment:

Operating System: [Windows 11]
Gradle Version: [ 8.1.1]
Kotlin Version: [1.9.10]
Additional Information:
I've checked the plugin repository availability, and my internet connection is working fine.

Please let me know if there's any additional information or steps I can provide to help resolve this issue.

The error message at least shows an 'r' missing on the end of the artifact id.

You are right, but i fixed this issue and try more and more but i got another error:

build-logic/build.gradle.kts

plugins {
    `kotlin-dsl`
}

group = "ir.buildlogic"

// Configure the build-logic plugins to target JDK 17
// This matches the JDK used to build the project, and is not related to what is running on device.
java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

dependencies {
    compileOnly(libs.android.gradlePlugin)
    compileOnly(libs.kotlin.gradlePlugin)
    compileOnly(libs.detekt.gradlePlugin)
    compileOnly(libs.ktlint.kotlinter)  // when i add this line i got error as follows
}

gradlePlugin {
    plugins {
        register("androidApplication") {
            id = "composenews.android.application"
            implementationClass = "AndroidApplicationConventionPlugin"
        }
        register("androidApplicationCompose") {
            id = "composenews.android.application.compose"
            implementationClass = "AndroidApplicationComposeConventionPlugin"
        }

        register("androidHilt") {
            id = "composenews.android.hilt"
            implementationClass = "AndroidHiltConventionPlugin"
        }
        register("androidLibrary") {
            id = "composenews.android.library"
            implementationClass = "AndroidLibraryConventionPlugin"
        }
        register("androidLibraryCompose") {
            id = "composenews.android.library.compose"
            implementationClass = "AndroidLibraryComposeConventionPlugin"
        }
        register("androidFeature") {
            id = "composenews.android.feature"
            implementationClass = "AndroidFeatureConventionPlugin"
        }
        register("androidRoom") {
            id = "composenews.android.room"
            implementationClass = "AndroidRoomConventionPlugin"
        }
        register("androidDetekt") {
            id = "composenews.android.detekt"
            implementationClass = "AndroidDetektConventionPlugin"
        }
        register("androidKtlint") {
            id = "composenews.android.ktlint"
            implementationClass = "AndroidKtlintConventionPlugin"
        }
    }
}

ktlint-kotlinter = { group = "org.jmailen.gradle", name = "kotlinter-gradle", version = "kotlinter" }

Error :

Execution failed for task ':build-logic:convention:compileKotlin'.
> Could not resolve all files for configuration ':build-logic:convention:compileClasspath'.
   > Could not find org.jmailen.gradle:kotlinter-gradle:kotlinter.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jmailen/gradle/kotlinter-gradle/kotlinter/kotlinter-gradle-kotlinter.pom
       - https://repo.maven.apache.org/maven2/org/jmailen/gradle/kotlinter-gradle/kotlinter/kotlinter-gradle-kotlinter.pom
       - https://plugins.gradle.org/m2/org/jmailen/gradle/kotlinter-gradle/kotlinter/kotlinter-gradle-kotlinter.pom
     Required by:
         project :build-logic:convention

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html


build-logic -> settings.gradle.kts

/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("https://plugins.gradle.org/m2/")
        }
    }
    versionCatalogs {
        create("libs") {
            from(files("../gradle/libs.versions.toml"))
        }
    }
}

rootProject.name = "build-logic"
include(":convention")

any idea?

I believe the error you've got is fairly clear:

Could not find org.jmailen.gradle:kotlinter-gradle:kotlinter.

and based on it, I'm guessing the solution is to use proper maven coordinates, in your case:

ktlint-kotlinter = { group = "org.jmailen.gradle", name = "kotlinter-gradle", version = "3.16.0" }

or using a version reference.

ktlint-kotlinter = { group = "org.jmailen.gradle", name = "kotlinter-gradle", version.ref = "kotlinter" }