Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 5.1.1
    • Fix Version/s: None
    • Component/s: cordova-cli
    • Labels:
      None

      Description

      Steps to reproduce:

      • Create hooks/before_build/010_test.js. Have it simply output some text to the console.
      • Do:
        cordova build <platform>

        The expected text is present.

      • Do:
        cordova run <platform>

        My expectation is that the text would be outputted, since "run" is more or less a wrapper around "prepare," "build," and some other commands. However, the text is not outputted.

      Workaround:

      • Do:
        cordova build <platform>

        The hook runs, and the app is built.

      • Do:
        cordova run <platform> --nobuild

        The app built in the previous step is deployed to the phone/emulator.

        Activity

        Hide
        omefire Omar Mefire added a comment - - edited

        This issue is due to the fact that we have two modules (cordova-lib and cordova-<platform>) that are involved in achieving the run, build, compile functionalities :

        • cordova-lib is responsible for running the hooks and then delegating the implementation of build/run/etc... to the underlying platform.
        • cordova-android/windows/... is responsible for the platform-specific logic.

        In the case of 'run', we delegate directly to the platform, and the platform is in charge of running a build before the deployment to the target (emulator/device). Because the run doesn't happen at the cordova-lib level, there is no way for the platform to run the build hooks supplied.
        Changing this behavior to delegating instead to cordova-lib's build logic would introduce certain breakage to the way things currently work : prepare would be executed multiple times, etc...

        Solving this would require rearchitecting the way cordova-lib and cordova-platform work in the case of the compile, build & run commands.

        I don't see this to be enough of a pain to justify that sweeping amount of changes. so, I'll hold off on making any modifications. Besides, you've got a workaround,

        Show
        omefire Omar Mefire added a comment - - edited This issue is due to the fact that we have two modules (cordova-lib and cordova-<platform>) that are involved in achieving the run, build, compile functionalities : cordova-lib is responsible for running the hooks and then delegating the implementation of build/run/etc... to the underlying platform. cordova-android/windows/... is responsible for the platform-specific logic. In the case of 'run', we delegate directly to the platform, and the platform is in charge of running a build before the deployment to the target (emulator/device). Because the run doesn't happen at the cordova-lib level, there is no way for the platform to run the build hooks supplied. Changing this behavior to delegating instead to cordova-lib's build logic would introduce certain breakage to the way things currently work : prepare would be executed multiple times, etc... Solving this would require rearchitecting the way cordova-lib and cordova-platform work in the case of the compile, build & run commands. I don't see this to be enough of a pain to justify that sweeping amount of changes. so, I'll hold off on making any modifications. Besides, you've got a workaround,
        Hide
        GinkgoFJG Frank J. Gómez added a comment -

        Thanks for the explanation. Perhaps some clarification in the docs about how the hooks work, and in which contexts, would be a good stopgap measure.

        Show
        GinkgoFJG Frank J. Gómez added a comment - Thanks for the explanation. Perhaps some clarification in the docs about how the hooks work, and in which contexts, would be a good stopgap measure.
        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user omefire opened a pull request:

        https://github.com/apache/cordova-lib/pull/280

        CB-9434: Adding a ToDO. 'cordova run' should run build related hooks …

        …: 'before_build' & 'after_build' hooks.

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/MSOpenTech/cordova-lib CB-9434

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/cordova-lib/pull/280.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #280


        commit 1871cd4a71b490cf521571db268ea56a27520f21
        Author: Omar Mefire <omefire@gmail.com>
        Date: 2015-08-19T19:47:35Z

        CB-9434: Adding a ToDO. 'cordova run' should run build related hooks : 'before_build' & 'after_build' hooks.


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user omefire opened a pull request: https://github.com/apache/cordova-lib/pull/280 CB-9434 : Adding a ToDO. 'cordova run' should run build related hooks … …: 'before_build' & 'after_build' hooks. You can merge this pull request into a Git repository by running: $ git pull https://github.com/MSOpenTech/cordova-lib CB-9434 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-lib/pull/280.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #280 commit 1871cd4a71b490cf521571db268ea56a27520f21 Author: Omar Mefire <omefire@gmail.com> Date: 2015-08-19T19:47:35Z CB-9434 : Adding a ToDO. 'cordova run' should run build related hooks : 'before_build' & 'after_build' hooks.
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user omefire commented on the pull request:

        https://github.com/apache/cordova-lib/pull/280#issuecomment-132759350

        For further details, see : https://issues.apache.org/jira/browse/CB-9434

        Show
        githubbot ASF GitHub Bot added a comment - Github user omefire commented on the pull request: https://github.com/apache/cordova-lib/pull/280#issuecomment-132759350 For further details, see : https://issues.apache.org/jira/browse/CB-9434
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user omefire closed the pull request at:

        https://github.com/apache/cordova-lib/pull/280

        Show
        githubbot ASF GitHub Bot added a comment - Github user omefire closed the pull request at: https://github.com/apache/cordova-lib/pull/280

          People

          • Assignee:
            omefire Omar Mefire
            Reporter:
            GinkgoFJG Frank J. Gómez
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development