Results 1 to 9 of 9

Thread: How to pass custom argument to sencha app build production?

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Location
    Salvador, Bahia - Brazil
    Posts
    35

    Default How to pass custom argument to sencha app build production?

    Using the -after-build target, would like to capture a custom argument to perform tasks.
    Is it possible?!
    It would be something like
    Code:
    sencha app build production --first
    Then I call custom target like this

    Code:
    <target name="first" if="args.first"/>
    <target name="second" if="args.second"/>

  2. #2
    Sencha - Engineering israelroldan's Avatar
    Join Date
    Nov 2011
    Location
    The Netherlands
    Posts
    395

    Default

    A quick (but not really recommended) way to achieve this would be to use ant directly in the app root:
    Code:
    ant build production -Dfirst=true
    Israel Roldán | Senior Software Engineer (Framework tools)

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Location
    Salvador, Bahia - Brazil
    Posts
    35

    Default

    Thank Israel.
    What is the best choice instead?
    Only can do this through ant call directly?

  4. #4
    Sencha - Engineering israelroldan's Avatar
    Join Date
    Nov 2011
    Location
    The Netherlands
    Posts
    395

    Default

    For regular cases (running some code after the build has been completed) the -after-build target is all you need. In this case, Sencha Cmd doesn't know how to react when you pass arbitrary flags (i.e.: -first).

    This would be the best way to do this currently.
    Israel Roldán | Senior Software Engineer (Framework tools)

  5. #5
    Sencha User
    Join Date
    Jan 2013
    Location
    Salvador, Bahia - Brazil
    Posts
    35

    Default

    I'll give more details.
    Sencha Cmd already come integrated with Cordova, but it doesn't generate the distribution app to release in stores, only debug.
    I made an integration in build.xml file, on the -after-build target, copy the build result to the cordova www directory and runs the cordova prepare for all installed platforms.
    What I want now is a way to be able to pass one parameter to -after-build target to decide to run the cordova or run the app in the device.


    Today I only run "sencha app build" command and it finishes in the "cordova prepare" command.
    I was thinking to use "sencha app build --release" or "sencha app build --run"

  6. #6
    Sencha - Engineering israelroldan's Avatar
    Join Date
    Nov 2011
    Location
    The Netherlands
    Posts
    395

    Default

    Please scratch my previous message, the recommended way would be to make use of the config command.

    The best way is to define a new property inside your app.json file, for example:
    Code:
    {
        //...
        "afterBuild": "run" // The name of this property is arbitrary, choose whatever suits you best
        //...
    }
    This will be accessible on your -after-build target as ${app.afterBuild}.

    Whenever you want to change the value of this property for a given build, you can use the "config" command together with the "then" operator:
    Code:
    > sencha config -prop app.afterBuild=release then app build
    Of course, you can put this on a simple bash script to just run a single command (i.e.: ./build-release)
    Israel Roldán | Senior Software Engineer (Framework tools)

  7. #7
    Sencha User
    Join Date
    Jan 2013
    Location
    Salvador, Bahia - Brazil
    Posts
    35

    Default

    This sounds nice!
    Thanks!

  8. #8
    Sencha User
    Join Date
    Dec 2015
    Posts
    2

    Default

    Quote Originally Posted by israelroldan View Post
    Please scratch my previous message, the recommended way would be to make use of the config command.

    The best way is to define a new property inside your app.json file, for example:
    Code:
    {
        //...
        "afterBuild": "run" // The name of this property is arbitrary, choose whatever suits you best
        //...
    }
    This will be accessible on your -after-build target as ${app.afterBuild}.

    Whenever you want to change the value of this property for a given build, you can use the "config" command together with the "then" operator:
    Code:
    > sencha config -prop app.afterBuild=release then app build
    Of course, you can put this on a simple bash script to just run a single command (i.e.: ./build-release)
    Hi,

    For me this solution not work:
    Code:
    > sencha config -prop app.baseUrl=/api
    This line not change the attibute of "${app.dir}/app.json", what I am doing wrong?

    Best regards.

  9. #9
    Sencha Premium Member
    Join Date
    May 2011
    Posts
    33

    Default

    I had the same problem. To get the prop in my build I have used the ant variable in the app.json.

    So the code from israelroldan have to be:

    Quote Originally Posted by israelroldan View Post
    Code:
    {
        //...
        "afterBuild": "${app.afterBuild}" // The name of this property is arbitrary, choose whatever suits you best
        //...
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •