`You cannot mix different URL schemes for a single repository. Please declare separate repositories.` when adding an ivy repository with artefact pattern to my plugin


(Jasmin Börsig) #1


I am writing a task for my custom plugin which has a zip file dependency. I want to add the repository to my plugin so the users of my plugin do not have to add the repository themselves (I want to keep the build.gradle as simple as possible for them).

I am doing this in my plugin to add the repository:

project.repositories.ivy {
    layout("pattern") {

However, when using my plugin in a project’s build.gradle I get the following error message:

You cannot mix different URL schemes for a single repository. Please declare separate repositories.

When I do not add the repository in my plugin and instead add it to the build.gradle file of the project that is using my plugin like below it works alright:

ivy {
    url 'https://bitbucket.org/'
    layout 'pattern', {
        artifact '/[organisation]/[module]/get/[revision].[ext]'

I am using ivy with a custom pattern because the zip file dependency is in a public Bitbucket Repository.

I am not adding any other ivy repositories in my plugin.
If I omit the artifactPattern line when adding the repository it works fine (but my zip file cannot be resolved).
Running the dependency task in the project I am applying my plugin to, I cannot find any other dependencies that seem to be resolved from bitbucket via ivy. Removing all repositories in the project I am applying my plugin to did not resolve the error either.

Does anybody know why I am getting this error message and how I can fix it?
I could not find anything on this error message in the Gradle Docs.

(Alexander Volanis) #2

I consider a plugin that adds a repository an anti-pattern and I would not use your plugin in my projects unless it was possible to configure an alternate repository and not inject a repository outside of my control.

Having said that it seems to me that you are adding the new repository incorrectly in your plugin.

You are using the artifactPattern method which is not part of the repository layout but is part of IvyRepository. Your build.gradle in contrast uses the correct method artifact.

(Jasmin Börsig) #3

I completely agree about it being an anti-pattern if we develop a plugin for a developer to use, however the plugin we are developing is not meant for developers in general but only for partners of the company I am working for. They use it to develop apps for an ERP system and have to include this repository to get the right css styling etc. for their documentation. Most of the people using our plugin do not have any software development background, therefore we want it to be as simple as possible for them.

Regarding the artifactPattern vs artifact, it worked. I just had to cast the RepositoryLayout I get within the layout closure to an IvyPatternRepositoryLayout since only this class has the artifact method.