This is a brief 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)7 (just to prevent VU#225657, see: http://www.kb.cert.org/vuls/id/225657), or version 1.8 for Tapestry 5.5 and later.
- 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: For Tapestry 5.4.x and earlier, install Firefox browser version 3.642 or earlier, needed for the integration tests (because newer versions require a newer version of Selenium than Tapestry's Java version requirements allow).
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 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 Git support is built in.
- Install Gradle 1.0-milestone-3 or newer (or a Gradle plugin to your IDE),
- Command-line users: http://www.gradle.org/downloadsnothing to do (Tapestry's Gradle wrapper, gradlew, will download Gradle automatically on first use).
- Eclipse users: Install Gradle IDE (aka Gradle Integration for Eclipse), from the Eclipse Marketplace. Note that for Eclipse 4.6 (Neon) and later, Gradle support is built in.
Getting Started
Please read https://git-wip-usgitbox.apache.org/ first 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:
Non Committers:
git clone
git-wip-ushttps://
reponame.gitgitbox.apache.org/repos/asf/
Committers:
git clone
http://git-wip-us.apache.org/repos/asf/reponame.gittapestry-5.git
- Eclipse EGit users:
- Switch to Git perspective; then copy one of the URLs URL 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 do this via using Gradle, below)
- Click Finish. (Be patient; the clone operation might take a few minutes.)
...
- 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.
- If you're using Eclipse but not Gradle IDE do
- 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.
SelectWhen it completes, s
elect the top-level (the top-level module and all sub-modules) then clickFinish
. - Be sure the "Enable dependency management" and ""Add to 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
.
- 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
...
- 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 > findtapestry-core/build/generated-sources/antlr}}
and check the checkbox next to it, then clickOK
.
- Right click on the
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 > findtapestry-core/build/generated-sources/compiled-coffeescript
andtapestry-core/build/generated-sources/compiled-test-coffeescript
and check the checkbox next to it, then clickOK
.
- Right click on the
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 {{OK"Browse Workspace..." and select gradlew (for Mac/Linux) or
gradlew.bat (for Windows)
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".
- Right click on the
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.
- Ensure that your environment will allow a connection to https://localhost:4439090
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 small 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.). Just invoke the corresponding Gradle tasks. This is mainly useful when debugging failing selenium tests.
- Command-line users:
- ./gradlew runTestApp1
- Eclipse usersIf 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 , 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
- Use the run-jetty-run plugin in Eclipse, with the context directory selected from among the
The integration test apps are:
- activationctx – used by tapestry-core integration tests
- activationctx2 – used by tapestry-core integration tests
- app0 – used only by the tapestry-hibernate integration tests
- app1 – used by most of the tapestry-core integration tests
- app2 – used by tapestry-core integration tests (HTTPS)
- app3 – used by tapestry-core integration tests
- app4 – used by tapestry-core integration tests
- app5 – used by tapestry-core integration tests
- appfolder – used by tapestry-core integration tests
- cluster – used by tapestry-core integration tests
- linktrans – used by tapestry-core integration tests
- symbolparam – used by tapestry-core integration tests
- (...and a few others not yet documented, and without Gradle tasks yet. Search for web.xml files in the Tapestry source.)
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:
...
You can use the git format-patch command to produce a nice set of patches to attach to the relevant issue in JIRA:
Code Block |
---|
git format-patch origin/master
|
...
Troubleshooting Hints
Problem 1: I can't run the build. it gives me an error in line 91:
Code Block |
---|
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".
...
Problem 2: Under Linux I get java.io.FileNotFoundException saying "Too many open files"
Solution: You may have to increase the number of files your operating system allows you to have open at once. Try ulimit -n
to see what the current value is, and if it is less than 2048, increase it to 2048 by editing your /etc/security/limits.conf
file. See your operating system's documentation for details.
...
Problem 3: The gradle build opens a Firefox browser with a File Not Found error:
Code Block |
---|
Firefox can't find the file at chrome://src/content/RemoteRunner.html
?sessionId=74c5c263747249739d82e4bee33fb4b6&multiWindow=true&baseUrl=
http://localhost:9090/&debugMode=false&driverUrl=http://localhost:4444/selenium-server/driver/. |
You probably have a newer version of Firefox than is supported by the Selenium tests.
Solution: You must use Firefox version 42 or earlier. Be sure to configure it not to upgrade itself. This problem will go away when Tapestry discontinues support for Java 6, currently planned for Tapestry v5.5.