In this entry, we'll compile the project under Eclipse (version 3.2.2), as it is the IDE of choice for quite many people. Start the IDE and select File -> New -> Project. In the creation wizard, select "Java project from existing Ant buildfile":
Press Next and in the following screen, press "Browse" and select the build.xml file that comes with the compiler. Eclipse will read the ant file and determine automatically the name of the project (you can change it, though):
Press Finish and the project will appear in the workbench. Initially, the project fails to compile because one of the files, called "version-template.java" is just a template that is used by the ant file, but in itself is not part of the things that must be compiled:
(If you are getting more errors, make sure that the project is using the latest JDK and not an older version).
We are going to exclude this file from the source set. Click on any file of the project, and select from the top menu Project -> Properties. Then in the properties dialog for this project, select "Java Build Path" on the right, and when done, click on the "Source" Tab:
There are two source sets : the os-javac/classes and os-javac/gensrc. Since the file we want to exclude belongs to the first set, click on the first "Excluded" item and press "Edit". The "Inclusion and Exclusion patterns" wizard will appear. Click on the "Add Multiple" button (it's shorter) and browse until you locate the version-template.java file.
Select it and press ok. You should see the following filter:
Press Finish. The project will be rebuilt, and this time there should be no errors (lots of warnings, though).
Next, we are going to edit the build.xml file a bit in order to make it work under eclipse. Double click on the build.xml file and locate the following line:
<project name="os-javac" default="build" basedir="f:/javac/compiler"> <property name="src" value="src"/> <property name="src.bin" value="${src}/bin"/> <property name="src.classes" value="${src}/share/classes"/> <property name="build" value ="build"/> ... </project>
Modify the basedir attribute to point to the root location of the javac compiler.
The next thing we will do is to make Eclipse show the build.properties file in order to be able to edit it from within the environment. We need this in order to be able to run the jtreg regression tests from within Eclipse.
From the main menu, select File -> New -> File, and click on the "Advanced" button when the "New File" wizard appears:
Click on the "Link to file in the file system" and click on "Browse". Since navigation usually starts at the root level, you should immediately see the "build.properties" file in the list that is presented. Select it an press "Open". You should now see the following:
Press "Finish" and the properties.file wil be added to the project. By default Eclipse opens this file with a custom editor. You can mostly ignore this editor : switch to the text view by pressing the "build.properties" tab under the editor window:
In this properties file, you must uncomment and assign values to jtreg.home and test.jdk.home. The first one should point to the location where the jtreg harness was uncompressed. The second one must point to the location of the JDK to use (it should be the same value as the JAVA_HOME environment variable, if you have it). Be careful not to include accidentally any trailing spaces after the value of the properties, or the tests will fail.
Once you have edited this file, let's run the compiler regression tests. From the main menu, activate the Ant targets view by selecting Window -> Show View -> Ant. Now drag and drop the "build.xml" file onto that view:
You should see the following:
Ok, right-click on "xtest" and from the pop-up menu select Run As -> Ant Build. You should start to see messages like:
Buildfile: C:\Documents and Settings\GrupoT\workspace\os-javac\build.xml
prep:
check-javac.isuptodate:
build-lib.javac.jar:
build-bin.javac:
build:
xtest:
[jtreg] Directory "F:\javac\compiler\build\jtreg\report" not found: creating
[jtreg] Directory "F:\javac\compiler\build\jtreg\work" not found: creating
[jtreg] Directory "F:\javac\compiler\build\jtreg\work\scratch" not found: creating
[jtreg] Passed: tools\javac\4980495\static\Test.java
[jtreg] Passed: tools\javac\4980495\std\Test.java
[jtreg] Passed: tools\javac\5045412\Bar.java
[jtreg] Passed: tools\javac\5045412\Bar.java
[jtreg] Passed: tools\javac\5045412\Foo.java
[jtreg] Passed: tools\javac\5045412\Foo.java
[jtreg] Passed: tools\javac\6199662\Tree.java
In total there are about a thousand unit tests, so complete testing may take its time (5-10 minutes on a reasonable machine)