如何为没有物理根的平面项目进行Gradle设置 [英] How to do a Gradle setup for flat projects with no physical root

查看:124
本文介绍了如何为没有物理根的平面项目进行Gradle设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

。 。我们正在迁移到Rational Team Concert(RTC)并希望利用其组件定义。

 在流中使用的组件导致本地scm工作空间是平坦的,其物理根目录不在scm中,如下所示:

| - 工作区名称
| component1
| component2
< empty>

源代码中的文件仅存在于组件文件夹中, workspace-name 只是一个文件系统的父项,所以除非在构建时将代码复制到那里,否则它不包含构建文件或代码。



我发现了很多很好的问题和答案,例如,平面项目布局通用组件布局以及Gradle的工作原理优秀的入门书重新:逻辑vs物理布局。这些仍然没有解决我的困惑。



我正在尝试做的是:

  |  - 工作区名称
| component1
| component2
| buildSrc

我在 buildSrc / settings.gradle

  includeFlat'../component1/compa','../component2'

马上就会发现我的自定义任务错误(定义在 buildSrc\src\main \groovy\CustomTask.groovy )不存在(无法在项目':component1 / compa'>上找到属性'CustomTask')。



我相信这是因为projectroot目录本身中 buildSrc 应该是通过 gradle docs ),例如:

  |  - 工作区名称
| component1
| component2
| buildSrc

这让我想到,也许我需要一个虚拟组件,它同时也是逻辑父项作为buildSrc父项。



我的问题是,如果我没有物理根目录,那么放置我的 settings.gradle 文件?每个组件都需要自定义任务的代码来构建,所以我也在寻找最好的地方(如果不在虚拟组件中)。谢谢!

Andy

code> buildSrc 每个版本,并将其放在正确的位置。然而, buildSrc 是它自己的版本,并且它包含主版本的项目是无意义的(正如你明显尝试的那样)。另外, includeFlat 的参数不是文件路径。不太清楚你想在这里实现什么。



至于主版本的 settings.gradle ,如果你无法将其放入根目录中,另一种选择是将其放入名为 master 的目录中。 (这是一个内置的约定,不能重新配置。)


. . We are migrating to Rational Team Concert (RTC) and want to leverage its 'component' definitions. Components used in a stream result in a local scm workspace which is flat and its physical root is not in scm, like this:

|- workspace-name
   | component1
   | component2
   <empty>

Files in source code only exist in component folders, workspace-name is just a filesystem parent so unless I copied code into there at build time, it is empty of build files or code.

I found numerous good questions and answers on, e.g., flat project layouts, generic component layout, and an excellent primer on how Gradle works re: logical vs physical layouts. These still didn't quite address my confusion.

What I'm trying to do is this:

|- workspace-name
   | component1
   | component2
   | buildSrc

I have this in buildSrc/settings.gradle:

includeFlat '../component1/compa','../component2'

Right off the bat it gives me error that my custom task (defined in buildSrc\src\main\groovy\CustomTask.groovy) does not exist (could not find property 'CustomTask' on project ':component1/compa').

I believe that's because buildSrc should be in the projectroot directory itself (as implied by gradle docs) , e.g.:

|- workspace-name
   | component1
   | component2
     | buildSrc

Which leads me to think that maybe I need a dummy component which becomes both the logical parent as well as the buildSrc parent.

My question is, if I have no physical root, what's the "best" place to put my settings.gradle file? Each component will need code from the custom tasks to build so I'm also looking for the best place for that (if not in the dummy component). Thank you!

Andy

解决方案

There can only be one buildSrc per build, and you put it in the right place. However, buildSrc is its own build, and it doesn't make sense to make it include projects of the main build (as you apparently tried). Also the argument to includeFlat isn't a file path. Not quite sure what you are trying to achieve here.

As for the main build's settings.gradle, if you can't put it into the root directory, the other option is to put it into a directory named master. (This is a built-in convention and cannot be reconfigured.)

这篇关于如何为没有物理根的平面项目进行Gradle设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆