Gradle中的Settings和SourceSet

news/2024/5/20 2:51:25 标签: gradle, settings, sourceset

文章目录

  • Settings
  • SourceSet

Settings

Settings 的核心作用就是决定我们项目的哪些工程是要被gradle处理的。

Settings.java部分源码:

@HasInternalProtocol
public interface Settings extends PluginAware, ExtensionAware {
    /**
     * <p>The default name for the settings file.</p>
     */
    String DEFAULT_SETTINGS_FILE = "settings.gradle";

    /**
     * <p>Adds the given projects to the build. Each path in the supplied list is treated as the path of a project to
     * add to the build. Note that these path are not file paths, but instead specify the location of the new project in
     * the project hierarchy. As such, the supplied paths must use the ':' character as separator (and NOT '/').</p>
     *
     * <p>The last element of the supplied path is used as the project name. The supplied path is converted to a project
     * directory relative to the root project directory. The project directory can be altered by changing the 'projectDir'
     * property after the project has been included (see {@link ProjectDescriptor#setProjectDir(File)})</p>
     *
     * <p>As an example, the path {@code a:b} adds a project with path {@code :a:b}, name {@code b} and project
     * directory {@code $rootDir/a/b}. It also adds the a project with path {@code :a}, name {@code a} and project
     * directory {@code $rootDir/a}, if it does not exist already.</p>
     *
     * <p>Some common examples of using the project path are:</p>
     *
     * <pre class='autoTestedSettings'>
     *   // include two projects, 'foo' and 'foo:bar'
     *   // directories are inferred by replacing ':' with '/'
     *   include 'foo:bar'
     *
     *   // include one project whose project dir does not match the logical project path
     *   include 'baz'
     *   project(':baz').projectDir = file('foo/baz')
     *
     *   // include many projects whose project dirs do not match the logical project paths
     *   file('subprojects').eachDir { dir -&gt;
     *     include dir.name
     *     project(":${dir.name}").projectDir = dir
     *   }
     * </pre>
     *
     * @param projectPaths the projects to add.
     */
    void include(String... projectPaths);

最重要的就是include方法,将我们新建的子工程引入进来,这样gradle才会把它当做一个工程去处理。

gradle的初始化阶段就完成在执行settings.gradle中的内容


SourceSet

SourceSet决定了代码、资源、第三方库等要存放的位置

约定:
java目录–>
res目录–>

gradle-core-2.2.2.jar / com / android / build / gradle / api /AndroidSourceSet.class

gradle-core-2.2.2.jar / com / android / build / gradle / api /AndroidSourceDirectorySet.class


资源文件分模块
创建两个资源文件夹res-ad和res-player

在app的build.gradle中修改sourceSets

  sourceSets {
        main {
            jniLibs.srcDirs = ['libs'] //修改so库存放位置

            res.srcDirs = ['src/main/res',
                           'src/main/res-ad',
                           'src/main/res-player']
        }
    }

http://www.niftyadmin.cn/n/1838289.html

相关文章

腾讯技术开放日 | 腾讯会议如何构建实时视频传输算法架构,来实现用户体验质量最优?

在实时视频通讯中&#xff0c;要达到终端用户的体验质量&#xff08;QoE&#xff09;最优&#xff0c;需要实现实时视频传输的信号质量和交互性最优&#xff0c;而时延和带宽是有限的&#xff0c;如何衡量取舍对有限资源进行分配&#xff0c;成为构建腾讯会议实时视频传输算法架…

腾讯宣布五年5000亿投入计划,发力新基建

5月26日&#xff0c;腾讯云与智慧产业事业群总裁汤道生对外宣布&#xff0c;腾讯未来五年将投入5000亿&#xff0c;用于新基建的进一步布局。 据介绍&#xff0c; 云计算、人工智能、区块链、服务器、大型数据中心、超算中心、物联网操作系统、5G网络、音视频通讯、网络安全、量…

asp.net表格的弹出页imagebutton按钮修改数据后的表格刷新

在模板页的imagebutton控件添加单击事件&#xff1a; 因为单击事件滞后与ONClienClick事件&#xff0c;所以重新提取数据源&#xff0c;单不改变表格的当前页索引。 注&#xff1a;1、imagebutton单击事件重新提取表格数据源 2、ONClienClick指向一个修改表格当前行数据的u…

图像处理和卷积神经网络架构

https://mp.weixin.qq.com/s?__bizMzA3MzI4MjgzMw&mid2650728746&idx1&sn61e9cb824501ec7c505eb464e8317915&scene0#wechat_redirect 感谢机器之心的翻译&#xff01;保存下来以便以后复习方便一些&#xff01; 近日&#xff0c;Dishashree Gupta 在 Analyti…

Java注释中的Target和Retention

文章目录RetentionTarget参考&#xff1a;https://blog.csdn.net/hongxue8888/article/details/90319473 Retention 在Annotation中&#xff0c;可以使用Retention定义一个Annotation的保存范围。Retention和RetentionPolicy定义如下&#xff1a; package java.lang.annotat…

VS 2008新特性

AutomaticProperties.cs&#xff08;自动属性&#xff09;usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts…

腾讯AI加速器三期五次闭门辅导 | 如何理解人工智能商业化红利?

经过几年热潮后&#xff0c;AI创业和投资逐渐回归理性。AI企业从最初的单纯比拼算法&#xff0c;到如今进入技术落地争霸赛阶段&#xff0c;资本市场评估企业的角度也从技术转向商业&#xff0c;越来越看重现金流、解决问题能力以及商业模式是否成立等。 在腾讯AI加速器三期第五…

Android MaterialDesign

文章目录简介Material Design提供的材料主题AppCompatActivityCoordinatorLayoutBehaviorMaterial Design中的部分控件Material Design相关网站 Material Design官网&#xff1a;https://www.mdui.org/design/material-design/introduction.html Material Design说明简书&…