Results 1 to 5 of 5

Thread: Hook into -after-build-production using build.xml

  1. #1
    Sencha Premium Member Tarabass's Avatar
    Join Date
    Jun 2010
    Location
    The Netherlands
    Posts
    51

    Default Hook into -after-build-production using build.xml

    I am using build.xml to hook in into the build process to copy over the production folder to another place. I do this by using the target "-after-build". One big disadvantage is that this will occur at any build. But when I change "-after-build" to "-after-build-production" the task is not executed. Then I had the genius idea to check for the "${build.environment}" and if it equals "production" I copy. But it seems that most of the time, even if I run "sencha app build native" for example, this is production. How can I hook in into the "-after-build-production" target to copy only when "sencha app build" or "sencha app build production" is called?

    Not working
    Code:
    <target name="-after-build-production" description="Copy production folder to siteroot.">
            <x-echo message="Copy ${build.dir} to /Web/SiteRoot/Mobile"/>
            <copy todir="${workspace.dir}/../Web/SiteRoot/Mobile" overwrite="true">
                <fileset dir="${build.dir}">
                    <include name="**/*"/>
                </fileset>
            </copy>
        </target>
    Not working
    Code:
    <target name="-after-build">
            <x-echo message="Environment ${build.environment}"/>
            <x-echo message="Copy ${build.dir} to /Web/SiteRoot/Mobile"/>
            <if>
                <equals arg1="${build.environment}" arg2="production"/>
                <then>
                    <copy todir="${workspace.dir}/../Web/SiteRoot/Mobile" overwrite="true">
                <fileset dir="${build.dir}">
                    <include name="**/*"/>
                </fileset>
            </copy>
                </then>
            </if>
        </target>
    This is working
    Code:
    <target name="-after-build" description="Copy production folder to siteroot.">
            <x-echo message="Copy ${build.dir} to /Web/SiteRoot/Mobile"/>
            <copy todir="${workspace.dir}/../Web/SiteRoot/Mobile" overwrite="true">
                <fileset dir="${build.dir}">
                    <include name="**/*"/>
                </fileset>
            </copy>
        </target>
    So why is the "-after-build-production" target not working? How can I accomplish copying the folder only when "sencha app build" or "sencha app build production" is called?

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,436

    Default

    Why not use app.json to override where the build is going to? Just generated a new app with Cmd 5.1 and Ext 5.1 and see this in app.json:

    Code:
        "output": {
            "base": "${workspace.build.dir}/${build.environment}/${app.name}"
        },
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3

    Default

    Because that doesn't answer the question?

    Yes yes good to have alternates. But also nice to just use what is given without having to ask for support.

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <project name="myApp" default=".help">
        <import file="${basedir}/.sencha/app/build-impl.xml"/>
        <target name="-after-build" >
            <x-echo message="AFTER BUILD" level="debug"/>
        </target>
    </project>
    This used to work but now it does not. I found here in the forums that echo was changed to x-echo, but still no joy. Now I'll start looking at ant versions maybe.

    The echo in after build really does echo, but only with a standard generated project. So what changes in app.json might cause the after build step to be skipped?

    Or am I still way out in left field? Many thanks for any hints.

    Code:
    {
      "name": "myapp",
      "indexHtmlPath": "index.html",
      "classpath": "${app.dir}/app",
      "overrides": "${app.dir}/overrides",
      "framework": "ext",
      "theme": "blue-crisp",
      "requires": [],
      "sass": {
        "namespace": "myapp"
      },
      "url": null,
      "js": [
        {
          "path": "app.js",
          "bundle": true
        }
      ],
      "css": [
        {
          "path": "${build.out.css.dir}/myapp-all.css",
          "bootstrap": true
        }
      ],
      "production": {
        "loader": {
          "cache": "${build.timestamp}"
        }
      },
      "testing": {
        "loader": {
          "cache": false
        }
      },
      "development": {
        "loader": {
          "cache": false
        }
      },
      "output": {
        "base": "${workspace.build.dir}/${build.environment}/${app.name}/${build.id}",
        "page": "../index.html",
        "manifest": "../${build.id}.json",
        "deltas": {
          "enable": false
        },
        "cache": {
          "enable": false
        }
      },
      "appCache": {
        "cache": [
          "index.html"
        ],
        "network": [
          "*"
        ],
        "fallback": []
      },
      "resources": [
      ],
      "ignore": [
        "(^|/)CVS(/?$|/.*?$)"
      ],
      "archivePath": "archive",
      "slicer": {
        "js": [
          {
            "path": "${app.dir}/sass/example/custom.js",
            "isWidgetManifest": true
          }
        ]
      },
    
      "id": "96f01a95-140a-493d-b41f-6662cc86af25",
    
      "builds": {
        "blue-crisp": {
          "theme": "blue-crisp"
        }
      },
      "manifest": {
        "name": "${build.id}.json",
        "bootstrap": "${build.id}.json"
      }
    }

  4. #4
    Sencha Premium Member valio's Avatar
    Join Date
    Jan 2014
    Posts
    203

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Why not use app.json to override where the build is going to? Just generated a new app with Cmd 5.1 and Ext 5.1 and see this in app.json:

    Code:
        "output": {
            "base": "${workspace.build.dir}/${build.environment}/${app.name}"
        },
    I'm currently working on the same problem as Tarabass.

    The problem I have with the current build process is that I don't want the final build not to reside in a folder called "production", but in an entirely different directory in our project (which is also the only builds that are kept in our VCS).

    Symlinking the production build folder to there is not an option because we want to remove the entire workspace folder and just keep the production build during the deploy.

    [EDIT]

    Never mind.
    I just realised that I can configure the production build output specifically like this in app.json
    Code:
         /**
         * Settings specific to production builds.
         */
        "production": {
              "output": {
                          "base": "${workspace.build.dir}/../../built/${app.name}",

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

    Default

    "native" is a special type of build which runs additional tasks as part of it, but can be combined with production or testing and since "production" is the default environment (which is why "sencha app build" is the same as "sencha app build production").

    Regarding the x-echo call, you're clearly setting level to debug, are you also running your command with -debug? Otherwise the message will get filtered out since the default level is info (which is also the default value if no "level" is specified).

    Most importantly, about the -after-build-production: On which version did you have this working? Where you just running "sencha app build"?

    I'm asking you this because I see this is wired to the ant build process whenever you run "sencha ant build-production" but I don't see this being called as part of "sencha app build". If this was working for you on a previous version, then it's definitely a regression that needs to be addressed.

    Knowing the versions you were/are working with will help us a lot!
    Israel Roldán | Senior Software Engineer (Framework tools)

Posting Permissions

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