Configure MavenDeployer programmatically

Hi,

I am trying to build a custom plugin which will configure the uploadArchives task. This is what i tried and i am getting an error around missing mavenDeployer method.

I am calling below piece of code in my custom task.

project.uploadArchives {
      project.repositories {
        mavenDeployer{
            repository(url:"file://localhost/tmp/myRepo/")
            pom.version='1.0Maven'
            pom.artifactId='myMavenName'
            pom.packaging='aar'
        }
    }
}

Error:

 Could not find method mavenDeployer() for arguments [......UploadTask$_configRepo_closure1$_closure2$_closure3@6fa2a006] on project ':app'.

I do have maven plugin in my app where i use this plugin. Will appreciate any pointers in this regard.

You will need to apply the ‘maven’ plugin.

Thanks Mark for the response. I did apply the maven plugin using the below code.

    project.plugins.apply('maven')
    project.getTasks().create([name: 'uploadArtifacts', type: UploadTask, overwrite: true, dependsOn: ['configure'] as String[], group: 'Upload'])

And the UploadTask is where i configure the maven properties (as detailed in my first query). Looks to me i am missing some thing, but not sure what that is. Will appreciate any inputs in this regard.

Thanks

I just saw the issue. You should not be referring to project.repositories in your Upload task. The task has it’s own repositories { } block to be configured. That is, we separate where to download dependencies from and where to publish dependencies to. The task should instead look something like:

project.uploadArchives {
      repositories {
        mavenDeployer{
            repository(url:"file://localhost/tmp/myRepo/")
            pom.version='1.0Maven'
            pom.artifactId='myMavenName'
            pom.packaging='aar'
        }
    }
}
1 Like

Thanks Mark that resolved my problem.

Hi,

I’m facing the same issue too. I do not have project.repositories in my upload task. Here is what my upload task looks like:

uploadArchives {
repositories {
mavenDeployer {
repository(url: ‘https://martifactory.io/release-mvn/’)
snapshotRepository(url: ‘https://martifactory.io/dev-mvn/’)
pom.artifactId = “titan-retry”
}
}
}

The error message is:

Could not find method mavenDeployer() for arguments [build_15i9c45h051nli48dzvw5o7sl$_run_closure3$_closure7$_closure8@fd7d8d5] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.

Thanks for your response.

1 Like

I too got the same issue, Can anyone suggest me the solution