Include of buildscript repository definition fails

牧云@^-^@ 提交于 2019-12-11 04:49:35

问题


I have multiple files in my gradle build. In one file, I define my repositories. For example, repos.gradle looks like:

buildscript {
    repositories {
        maven {
            url "nexus url"
        }
    }
}

Now, in my projects build script, my project.gradle looks like:

apply from: "repos.gradle"

buildscript {
    dependencies {
        classpath "some:library:version"
    }
}

This fails to build, with an error along the lines of unable to add dependency because no repositories are defined. If I define everything in the project.gradle file, everything works.

How can I inherit the repository definition? I have many many projects, and want to use the one definition in case it changes.


回答1:


The buildscript information can't be put into a separate file (here repos.gradle) and then imported, it's a special block.

What you can do on the other hand is to put your buildscript block into the top level build.gradle file and then all other build files from subprojects/inclusion will inherit this block.



来源:https://stackoverflow.com/questions/49893822/include-of-buildscript-repository-definition-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!