代码之家  ›  专栏  ›  技术社区  ›  Chris F

路径为的项目:在根项目“gradle tutorial”中找不到projecta

  •  1
  • Chris F  · 技术社区  · 8 年前

    我是刚认识Gradle的人,正在关注这个 Gradle tutorial 它给出了下面的例子,在我的/GooLeTeal/Budio.GooLLE文件中复制/粘贴

    project(':projectA') {
       task hello
    }
    task hello
    
    println tasks.getByPath('hello').path
    println tasks.getByPath(':hello').path
    println tasks.getByPath('projectA:hello').path
    println tasks.getByPath(':projectA:hello').path
    

    当我奔跑

    $ gradle -q hello
    

    我明白了

    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '/Users/myuser/gradle-tutorial/build.gradle' line: 1
    
    * What went wrong:
    A problem occurred evaluating root project 'gradle-tutorial'.
    > Project with path ':projectA' could not be found in root project 'gradle-tutorial'.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    

    我确实创建了一个~~/GoeldTeal/StudioA/Budio.GoeLLE文件,但仍然有同样的错误。

    我错过了什么?

    我找到的笔记 Project with path ':mypath' could not be found in root project 'myproject' 但不知道如何使这个答案适用于我的简单的一个文件/一个目录案例。

    1 回复  |  直到 8 年前
        1
  •  1
  •   nickb    8 年前

    此错误表示您的settings.gradle文件丢失或无效。在其中,您需要对要包含在生成中的子项目的目录进行引用,如下所示:

    include 'projectA'
    

    对于projecta子目录中的build.gradle文件,不需要任何内容,因为根build.gradle文件已经通过包含 project(':projectA'){ } 封锁。如果您想将该块的内容移动到子项目的Buff.GeDLE,则功能将是等价的。

    推荐文章