Getting 403 error when trying to push library to maven repository

Viewed 804

I want to publish my kotlin library to maven repository but i always get this error

Execution failed for task ':publishMavenPublicationToTestRepository'.
> Failed to publish publication 'maven' to repository 'test'
   > Could not PUT 'https://mymavenrepo.com/repo/oeXkQu5cUtNHmcWwJd1R/com/test/public/commons/1.0.0/commons-1.0.0.jar'. Received status code 403 from server: Forbidden

This is my gradle file

plugins {
    kotlin("jvm") version "1.5.20"
    `maven-publish`
    `java-library`
    signing
}

group = "com.test.public"
version = "1.0.0"
java.sourceCompatibility = JavaVersion.VERSION_11

repositories {
    mavenCentral()
}

dependencies {
    // My dependencies
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict", "-Xopt-in=kotlin.RequiresOptIn")
        jvmTarget = "1.8"
    }
}

publishing {
    publications {
        create<MavenPublication>("maven") {
            groupId = "com.test.public"
            artifactId = "commons"
            version = "1.0.0"
            from(components["java"])
        }
    }
    repositories {
        maven {
            name = "test"
            url = uri("https://mymavenrepo.com/repo/oeXkQu5cUtNHmcWwJd1R/")
            credentials { 
                username = "xxx"
                password = "xxx"
            }
        }
    }
}

This error happens when i try to publish to maven repository, but when i try to publish it to maven local everything works.

What is the problem with my configuration and how to solve it?

0 Answers
Related