如何自定义centos命令行命令

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何自定义centos命令行命令相关的知识,希望对你有一定的参考价值。

参考技术A 1.首先进入root目录

2.然后查看目录下的 .bashrc 文件

3.在里面进行自定义命令的编写,模仿文件里的例子

4.编写自定义命令

5.重新载入环境变量

6.使用自定义命令

如何使用 ant 命令行来选择我的自定义 build.xml

【中文标题】如何使用 ant 命令行来选择我的自定义 build.xml【英文标题】:How to use ant command line to pick my custom build.xml 【发布时间】:2016-10-17 14:05:30 【问题描述】:

我有一个QtApp 用于android,我使用以下命令构建了command line。它使用蚂蚁构建。都很棒。构建良好。运行良好。遵循为我创建和签署 apk 的核心命令。

ANT_OPTIONS=" -ant"
Path/To/androiddeployqt --sign /Path/to/MyKey.keystore MyAlias --storepass MyPassword --output android --verbose --input /path/to/android-libMyQtApp.so-deployment-settings.json $ANT_OPTIONS

接下来,我需要进行一些版本控制自定义,为此我需要创建自己的 build.xml 并让 ant 选择我的自定义 build.xml。我通读了以下 ant 官方页面,该页面描述了 -buildfile 的用法,并指出您可以提及包含自定义 build.xml 的目录。 https://ant.apache.org/manual/running.html

由于我想使用我在项目目录中创建的自定义 build.xml我在命令中进行了以下更改

ANT_OPTIONS=" -ant -buildfile '/Directory/containing/my_build.xml'"
Path/To/androiddeployqt --sign /Pathto/MyKey.keystore MyAlias --storepass MyPassword --output android --verbose --input /path/to/android-libMyQtApp.so-deployment-settings.json $ANT_OPTIONS

但 ant 仍然会选择默认生成的 build.xml。我的 ANT_OPTIONS 有什么问题? androiddeployqt 是否不允许我传递额外的 ant 命令行选项?

或者,是否可以创建一个 ant.properties 文件以便 ant 获取我的自定义构建命令? 我只想增加我的 Android 应用的版本号

【问题讨论】:

【参考方案1】:

根据apache-ant documentation,如果构建脚本不是默认名称 (build.xml),则有三个选项可供选择。

 -buildfile <file>      use given buildfile
    -file    <file>              ''
    -f       <file>              ''

您可以在下面看到上述所有版本都可以正常工作:

- bash $~/Documents/so$ ant -buildfile build-regex.xml 
Buildfile: /home/apps/Documents/so/build-regex.xml

myTarget:
     [echo] D:/MyFolder/abc/

BUILD SUCCESSFUL
Total time: 0 seconds
- bash $~/Documents/so$ ant -f build-regex.xml 
Buildfile: /home/apps/Documents/so/build-regex.xml

myTarget:
     [echo] D:/MyFolder/abc/

BUILD SUCCESSFUL
Total time: 0 seconds
- bash $~/Documents/so$ ant -file build-regex.xml 
Buildfile: /home/apps/Documents/so/build-regex.xml

myTarget:
     [echo] D:/MyFolder/abc/

BUILD SUCCESSFUL
Total time: 0 seconds

您尝试了-buildfile 选项,但奇怪的是它不起作用。您可以尝试-f-file 选项。

【讨论】:

您在尝试ant -buildfile 命令 statndalone 吗?或androiddeployqt。就我而言,它是一个 QtApp,我正在构建命令行,为此我使用了一个名为 androiddeployqt 的命令行工具。该工具有一个-ant 选项。但它不接受 -buildfile 作为 ant 的额外参数 感谢您的建议。命令行 ant 可以独立工作。毫无疑问。我在这里遇到的问题是 ant 与 androiddeployqt 的组合,这会带来问题。 但无论如何感谢生动的解释。我正在对我的 QtApp 和 androiddeploqt 进行相同的尝试。似乎 androiddeployqt 工具是问题所在。它不识别 ant 选项。试穿.. 我在 android 中没有声音。查看此链接是否有帮助,其中包含 androiddeployqt - osxr.org:8080/qt/source/qttools/src/androiddeployqt/main.cpp 的选项 是的。你是对的。不需要ANT_OPTIONS。我期待-ant 有更多选项来指定自定义 build.xml。它会派上用场的。另外,我想如果有附加到-ant 的选项,那么只需将正确的命令附加到ANT_OPTIONS 就可以更容易地回答我的问题。感谢您指向androiddeployqt的源代码。如果有办法,我会尝试挖掘

以上是关于如何自定义centos命令行命令的主要内容,如果未能解决你的问题,请参考以下文章

centos7怎么设置开机进入命令行

centos虚拟机开启命令

centos如何进入图形界面和centos已经进到图形界面后怎么打开命令行

centos如何定位到某一行?

配置Centos7开机自动进入命令行界面

centos进入命令行模式怎么使用