You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

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.6 (1.5 should also work).
  • 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.
  • 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)
  • 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.

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 go this via 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. Select the top-level (the top-level module and all sub-modules) then click Finish.
    • Be sure the "Enable dependency management" and ""Add to 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.

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...

Running Tests

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:
    • ./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:

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. (See a live example running on Google App Engine.)

  • 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 use /src/test/app1 (or app2, etc).

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:

git branch TAP5-123 origin/master

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:

git checkout TAP5-123

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.

git commit

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:

git push

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:

git format-patch origin/master

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:

20:22:11.438 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
20:22:11.439 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating root project 'tapestry-project-trunk'.
20:22:11.440 [ERROR] [org.gradle.BuildExceptionReporter] Cause: Cannot get property 'plus' on null object

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

  • No labels