【问题标题】:How to use ant command line to pick my custom build.xml如何使用 ant 命令行来选择我的自定义 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 应用的版本号

【问题讨论】:

    标签: android xml qt ant


    【解决方案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的源代码。如果有办法,我会尝试挖掘
    猜你喜欢
    • 1970-01-01
    • 2014-10-01
    • 2015-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多