是否可以手动编辑settings.gradle文件? [英] Is it possible to manually edit settings.gradle file?
问题描述
在Cordova项目中,我有一个文件settings.gradle,其格式如下:
// GENERATED FILE - DO NOT EDIT
include:
include:CordovaLib
我要编辑该文件并使其看起来像:
//生成的文件 - 不要编辑
pre>
include:
include:CordovaLib
include'manager-A'
project(':manager-A')。projectDir = new File('libs / Manager-A')
include'manager-B'
project(':manager-B')。projectDir = new File('libs / Manager-B')
上面的脚本看起来不错,它可以使用Android studio成功构建。但是,当我尝试执行命令行:cordova build android,它不能被构建。
错误是'manager-A'和'manager-B'手动包括较早的命令行无法找到。检查后,结果,我手动编辑的文件被重新生成,它成为:
//生成的文件 - DO NOT EDIT
include:
include:CordovaLib
'd喜欢询问是否可以手动编辑文件,并且可以使用命令行:cordova build android来构建。
任何输入是非常感谢!
解决方案是的,我一直在寻找解决同样的问题,并从这 npm cordova-blinkup-plugin's Page 。您可以使用以下命令编辑设置:
1.打开路径/ to / project / platforms / android / cordova / lib / build.js
2.编辑fs.writeFileSync()
function(line 273)://写settings.gradle文件。
fs.writeFileSync(path.join(projectPath,'settings.gradle'),
'// GENERATED FILE - DO NOT EDIT\\\
'+
'include:\ n'+ settingsGradlePaths.join('')+
'include:customProject1+
'include:customProject2');
我希望这会有所帮助。
In a Cordova project, I have a file settings.gradle which looks like:
// GENERATED FILE - DO NOT EDIT include ":" include ":CordovaLib"
However, manually I want to edit the file and to make it look something like:
// GENERATED FILE - DO NOT EDIT include ":" include ":CordovaLib" include 'manager-A' project(':manager-A').projectDir = new File('libs/Manager-A') include 'manager-B' project(':manager-B').projectDir = new File('libs/Manager-B')
The above script looks good and it can be built successfully using Android studio. However, when I try to execute command line: cordova build android, it cannot be built.
The error is 'manager-A' and 'manager-B' that I manually included earlier cannot be found by the command line. After checking, it turned out that the file that I manually edited was re-generated and it becomes:
// GENERATED FILE - DO NOT EDIT include ":" include ":CordovaLib"
I'd like to ask whether it is possible to manually edit the file and that can be built as I explained above using the command line: cordova build android.
Any input is really appreciated!
解决方案Yes, I was looking to resolve same problem and found out following solution from this npm cordova-blinkup-plugin's Page. You can edit the settings with as:
1. Open path/to/project/platforms/android/cordova/lib/build.js
2. Editfs.writeFileSync()
function (line 273):// Write the settings.gradle file. fs.writeFileSync(path.join(projectPath, 'settings.gradle'), '// GENERATED FILE - DO NOT EDIT\n' + 'include ":"\n' + settingsGradlePaths.join('') + 'include ":customProject1" + 'include ":customProject2"');
I hope this will help.
这篇关于是否可以手动编辑settings.gradle文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!