Building Tapestry from Source

This is a guide to building Tapestry itself from source code. This is primarily of interest to Tapestry contributors, rather than Tapestry users.

Although Tapestry users are free to use any build mechanism for their own projects (and first class Maven support is provided), to build Tapestry itself from source you will use Gradle.

Note: Both command line and Eclipse Gradle IDE/EGit instructions are given here. Generally you'll want to chose approach one or the other, rather than mixing them.

Prerequisites

  • Install a Java JDK (Sun/Oracle, not OpenJDK), version 1.7 (just to prevent VU#225657, see: http://www.kb.cert.org/vuls/id/225657).
  • Install an IDE (IDEA IntelliJ is recommended (and free to Tapestry committers), but Eclipse will also work. NetBeans is reported to work as well.
  • Install Firefox browser version 3.6, needed for the integration tests.
  • Set the Firefox browser's "preferred language" to English (en), because some tests will otherwise fail. (Fixed; see TAP5-2413)
  • Install a Git client
    • Command-line users: http://git-scm.com/downloads
    • Eclipse users: Install EGit from the Eclipse Marketplace, then in In Window > Preferences > Team > Git, set your "Default repository folder" (e.g. ~/git or %HOME%\git). Note that for Eclipse 4.4 (Luna) and later this is already done.
  • Install Gradle 1.0-milestone-3 or newer (or a Gradle plugin to your IDE),

Getting Started

Please read https://git-wip-us.apache.org/ first.

Windows users (especialy EGit users) should probably set the core.autocrlf config setting to false so that local diffs won't highlight line ending differences.

Clone the Repository

Clone Tapestry from the Git repo:

  • Command-line git users:

  • Eclipse EGit users:
    • Switch to Git perspective; then copy one of the URLs above into paste buffer
    • Right-click > Paste repository path or URI. This will bring up the Clone Git Repository dialog.
    • Committers: make sure Protocol is https, and enter your Apache commiter LDAP user name & password
    • click Next.
    • Select the branches you're interested in (e.g 5.3 and master), click Next
    • Select Directory to where you want the project source code (e.g. ~/git/tapestry-5 or %HOME%\git\tapestry-5)
    • Select whichever "Initial Branch" you're interested in (e.g. master)
    • Set "Remote name" to "origin" (the default)
    • VERY IMPORTANT: uncheck the "Import all existing projects" checkbox (we'll do this using Gradle, below)
    • Click Finish. (Be patient; the clone operation might take a few minutes.)

Gradle Preparation

  • Command-line gradle users only:
    • If you're using Eclipse but not Gradle IDE do ./gradlew eclipse
    • The command-line Gradle's eclipse plugin doesn't include the provided project dependencies; you need to add them manually (Java Build Path > Projects > Add tapestry-test). The plugin also generates a root eclipse project, so you'll need to delete the ".project" file in the root folder, and then you can import all Tapestry sub-projects at once.
  • Eclipse Gradle IDE users:
    • Switch to Java (or JEE) perspective and right-click > Import... > Gradle > Gradle Project > Next.
    • Set the "Root folder" to where you put your Tapestry source in the previous section (e.g. ~/git/tapestry-5 or %Home%\git\tapestry-5)
    • Click Build Model. When it completes, select the top-level (the top-level module and all sub-modules).
    • Be sure the "Enable dependency management" and "Create workingset 'tapestry-5' checkboxes are checked.
    • Click Finish. (Be patient; the import operation might take a few minutes.)
  • Eclipse EGit users: Do a Git "Share" on the project:
    • Still in the Java (or JEE) perspective, select all of the Tapestry projects (top-level and sub-modules) and right-click > Team > Share Project... > Git > Next > Ensure all are selected, click Finish.

Antlr

The tapestry-core project will initially have errors because of missing Java classes that are produced by ANTLR the first time the project is built. To fix this:

  • Eclipse Gradle IDE users:
    • Right click on the build.gradle file within tapestry-core and click Run As > "Gradle build...", check only the generateGrammarSource task, and change the "Name" field to something like "tapestry-core antlr", then click Apply and Run.
    • When it's finished, the antlr-generated classes (e.g. PropertyExpressionLexer.java) will be in created in $buildDir/generated-sources/antlr/, but Eclipse doesn't yet know about that path. To fix that, right click on the tapestry-core project > Properties > Java Build Path > Source > Add Folder > find tapestry-core/build/generated-sources/antlr and check the checkbox next to it, then click OK.

CoffeeScript

If you want to run tests from within Eclipse, Tapestry will complain that it won't find certain JavaScript files that normally are generated during compile time from their Coffeescript sources. In order to generate the JavaScript files you need to have Coffeescript installed and in your path. Simply install Node.js and afterwards run npm install -g coffee-script. The installation should take care of everything.

  • Eclipse Gradle IDE users:
    • Right click on the build.gradle file within tapestry-core and click Run As > "Gradle build...", check only the tapestry-core:compileCoffeeScript and tapestry-core:compileTestCoffeeScript tasks, and change the "Name" field to something like "tapestry-core coffeescript", then click Apply and Run.
    • When it's finished, the coffeescript-generated JavaScript files (e.g. t5-core-dom-jquery.js) will be in created in $buildDir/generated-sources/compiled-coffeescript/ and $buildDir/generated-sources/compiled-test-coffeescript/, but Eclipse doesn't yet know about that path. To fix that, right click on the tapestry-core project > Properties > Java Build Path > Source > Add Folder > find tapestry-core/build/generated-sources/compiled-coffeescript and tapestry-core/build/generated-sources/compiled-test-coffeescript and check the checkbox next to it, then click OK.

Generate CoffeeScript and Antlr files automatically when changed

If you want to have Eclipse compile the JavaScript files and lexer classes from their Coffeescript sources and Antlr files automatically when they change, you can do that by configuring an additional builder for the tapestry-core project:

  • Eclipse Gradle IDE users:
    • Right click on the tapestry-core project and select properties.
    • Select the "Builders" entry from the list on the left and click "New.." in the right panel.
    • Select "Program" and click "Ok".
    • Give the program a meaningful name, e.g. "compile coffeescript and antlr".
    • Switch to the "Main" tab.
    • For "Location:" click "Browse Workspace..." and select gradlew.sh or gradlew.bat in the Tapestry root project. If the root project is called "tapestry-5" the entry should look similar to "${workspace_loc:/tapestry-5/gradlew.bat}".
    • For "Working Directory:" click "Browse Workspace..." and select the Tapestry root project.
    • For "Arguments:" enter tapestry-core:generateGrammarSource tapestry-core:compileCoffeeScript tapestry-core:compileTestCoffeeScript.
    • Switch to the "Build Options" tab.
    • Make sure that only "Allocate Console", "After a "Clean"", "During manual builds", "During auto builds" and "Specify working set of relevant resources" are checked.
    • Click "Specify Resources...".
    • From the "tapestry-core" project select "src/main/antlr", "src/main/coffeescript", and "src/test/coffeescript".
    • Click "Finish".
    • Click "OK".
    • Click "OK".

Building

You can build individual modules, or (from the root folder) build everything.

  • Command-line users:
    *( "gradlew" is the gradle wrapper shell script (gradlew) or batch file (gradlew.bat) found in the root folder of the Tapestry source.
    • ./gradlew build
  • Eclipse Gradle IDE users:
    • Right click on the top-level project (or any sub-project) and select Run As > Gradle Build..., which starts an External Tools Configuration dialog box. Enter a reasonable name, select the tasks you want to run (for example, tapestry-core/install), and click Run.

Selenium Setup

It is necessary that you have a compatible version of Firefox installed.  On a Mac, you should install it in ~/Applications (rather than /Applications).

You should modify your ~/.bash_profile (or equivalent), to add ~/Applications/Firefox.app/Contents/MacOS to the PATH variable.

Running Individual Tests

Eclipse users:

  • Install the TestNG plugin to allow running of individual TestNG unit tests from within in Eclipse.
  • Right-click on any test class and select Run As >TestNG Test

Command-line users:

  • ./gradlew -Dtest.single=myclassname
  • ./gradlew -Dtest.single=myclassname.mymethod

where myclassname is the test class, such as FormTest

The Tapestry integration tests will repeatedly start up a Firefox browser.

Skipping Tests

Running the Tapestry integration tests can take 10 minutes or more (mostly because of Selenium tests, which repeatedly start and stop the Firefox browser), so you won't want to run them every time you try a change.

  • Command-line users:
    • To build while skipping all tests: ./gradlew build -x test
    • You can skip tests on a specific module by adding a colon and the module name. For example: -x test:tapestry-ioc
  • Eclipse Gradle IDE users:
    • In your External Tools Configuration, add the same -x test option as above at Arguments > Program Arguments.

Running the Integration Test Apps Manually

The Tapestry source includes several web apps that are used by the automated Selenium integration tests. You can also run these apps manually to try out nearly every browser-visible aspect of Tapestry.

  • If using Eclipse:
    • Use the run-jetty-run plugin in Eclipse, with the context directory selected from among the test context directories. For example, in the tapestry-core module, right click on the /src/test/app1 (or app2, etc) folder, and select Run As > Run Jetty, then open your browser to http://localhost:8080/tapestry-core

Making Code Changes

Once you have cloned or pulled the latest changes to your local Git repository, you can start working on it. Whenever you make some changes to the codebase, it's good to have a related issue filed in JIRA and to use a similarly named branch in your local Git repository. For example, to create a branch for an issue with the key TAP5-123:

With per-issue branches you can easily switch back and forth between different issues without worrying about unwanted side-effects from unfinished changes to other issues. Whenever you want to work on the TAP5-123 example issue, simply checkout that branch and start making your changes:

It's a good idea to commit your changes to your local Git repo whenever you have finished one logical part of the issue. For example when refactoring, make a new commit for each refactoring step you take.

Pushing your commits upstream

First:

  • Run the full suite of tests before pushing your commits to the upstream (remote) repository.
  • Ensure your changes have full test coverage
  • Ensure you have set your local repo to track the official Tapestry repo as its upstream repository.

Then:

Producing Patches

If you aren't an official committer (with write access to the Apache Tapestry Git repo), you'll need to submit changes via a patch.
See the recommendations at http://commons.apache.org/patches.html. (Obviously that isn't specifically for the Tapestry project, but most of the same principles apply.)

You can use the git format-patch command to produce a nice set of patches to attach to the relevant issue in JIRA:

The sooner you share your work the better. You can repeat the steps of this workflow as often as you like, producing more patches to be attached to the issue tracker. Once some of your patches are accepted and applied by a committer, you can rebase your work against the latest trunk. Alternatively, if you're asked to make some changes, you can go back to the original Git commit and modify it until the project team accepts your changes.

Troubleshooting Hints

Problem: I can't run the build. it gives me an error in line 91:

Solution: Use the gradle wrapper (./gradlew build), not plain "gradle".