Gradle multiproject define dependency on root project

喜欢而已 提交于 2019-12-04 18:21:03

问题


I have a multi project gradle build, configured in this way:

root
  |
  |---- projectA
  |
  |---- projectB

I want to declare in the root/build.gradle a dependency for all nested projects, this is the file:

subprojects {
      version = '1.0-SNAPSHOT'
      repositories {
           mavenLocal()
           mavenCentral()
           maven {
               url 'https://repository.jboss.org/nexus/content/groups/public-jboss/'
           }
       }
}

allprojects {
    dependencies {
        compile 'org.projectlombok:lombok:1.12.2'
    }
}

But when I execute the build, I have:

* What went wrong:

A problem occurred evaluating root project 'code'.

No signature of method:
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (java.lang.String) values: [org.projectlombok:lombok:1.12.2]

Possible solutions: module(java.lang.Object)

What I am doing wrong?


回答1:


compile method is part of the plugin you've been using (reference).

allprojects {

    apply plugin: 'java'
    //so that we can use 'compile', 'testCompile' for dependencies

    dependencies {
        compile 'org.projectlombok:lombok:1.12.2'
    }
}



回答2:


If you got the 'java' plugin has been applied, but it is not compatible with the Android plugins error, try this

subprojects {
    afterEvaluate {
        dependencies {
            implementation "YOUR DEPENDENCIES"
        }
    }
}


来源:https://stackoverflow.com/questions/19855979/gradle-multiproject-define-dependency-on-root-project

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