Could not find method uploadArchives() for arguments in build.gradle

Viewed 7417

I updated the gradle version to the 7.0.4 (com.android.tools.build:gradle:7.0.4)

And now in some of my modules I am solving the problem with maven.

So i replace apply plugin: 'maven' on apply plugin: 'maven-publish'

But I don't understand how to rewrite this section of code correctly:

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: uri("${rootProject.projectDir}/maven-repo"))
        }
    }
}

uploadArchives.dependsOn sourcesJar

Because when I start, I get the following error:

Could not find method uploadArchives() for arguments [build_ejkqjjnby5fggiavovparsecy$_run_closure5@c0f0c25] on project ':authenticator_sdk' of type org.gradle.api.Project

2 Answers

After I have read the documentation in more detail here and here,

I was able to rewrite my problematic code section as follows:

publishing {
    repositories {
        maven {
            url = uri("${rootProject.projectDir}/maven-repo")
        }
    }
}

I have got the error when I am bumping some old gradle project on 6.. to 7.4.*. So renaming uploadArchives to publishing helped me. Also I got other error where old code was referring to compile and testCompile but I learned that those need to be chged as "compile" --> "implementation" and "testCompile" --> "testImplementation" under dependencies. After these changes my build is successful. I hope this helps.

Related