Work for a few months, the JDK Foundation and Web application framework of the almost, began to learn jetty source code, the cost of a small half a day to compile the success of their own demolition of the pit record down.
Pre-compilation environment:
MAVEN 3.3, Eclips eluna Service Release 1 (4.4.1)
After you download maven, you have to configure Maven in eclipse as the download maven specific search for other blog references!
- Download source code
- Import Eclipse
- Compiling source code
1. Download the source code
1.1 Jetty source code can be conveniently downloaded on GitHub's Jetty Project homepage, link.
1.2 After entering the homepage, the page looked like the following:
1.3 Click Jetty Project homepage Picture 1 can appear drop-down pop-up menu, you can press branch or tag to choose different version of jetty, this article uses jetty 9.3.x, that is, the snapshot version.
1.4 Click on the Jetty Project homepage Picture 2, show the way to download the source package, if you do not have a GIT client or do not want to install, download the zip package to download the connection for direct downloading.
2. Import Eclipse
2.1 Download the zip package after successful, unzip, jetty package root directory below the file list below. Here, for the convenience of the following narrative, said the directory is $myJettySourceRoot.
The two files in the red bezel in this directory ( later called $myjettysourceroot) are worth noting:
README.MD is the developer team to compile the source of the developers to provide some of the content, but don't take it seriously! Completely according to his do is the compilation will not be successful!!!
Porm.xml is the root Porm file for the jetty project.
2.2 Open Eclipse and choose File->import->maven->exesting Maven Projects. Select the $myjettysourceroot directory, mine is C:\Users\Administrator\Downloads\jetty.project-jetty-9.3.x, for example, select all projects. Click "Finish" to start the import, then Maven will start
Download dependent packages, the project may take up to 3 hours. The options that appear halfway are "OK" and "resolve later", and there may be options to restart Eclipse, as well as "confirm".
3. Compiling the source code
3.1 After the successful import, the Eclipse directory tree as follows, find Jetty-protject project right mouse button, select Run As->maven clean, for project cleanup.
3.2 After the cleanup is complete, in the Select Etty-protject Project right mouse button, select Run As->run configuration. Create a new build configuration under Maven Bulid. By configuration: Install, but skip test. (Because some tests are hard to succeed on this machine). Click "Run" to start compiling, there will be a failure in the middle of the scene, processing step reference 3.3, repeated several times to compile successfully .
3.3 Compilation failed for processing reference.
In the compilation, there are often compilation failures, viewing the console information will find Could not resolve dependencies for
similar information "Xxx:jar:test", which occurs when one of the Jetty-project Submodule relies on the test package of another submodule, this situation, Find the MAVEN project in eclipse that corresponds to XXX, right-click Run as->maven install. For example, XXX is jetty-plus, right button Jetty-plus project, run as->maven install, first follow the sub-module of all packages, and then execute 3.2, repeat several times can be compiled successfully. Fully compiled successfully such as:
3.4 In the $myjettysourceroot\jetty-distribution\target\distribution directory (my directory is C:\Users\Administrator\Downloads\ jetty.project-jetty-9.3.x\jetty-distribution\target\distribution), you can find the successful compilation of the discovery file.
3.5 Open CMD,CD To this directory, enter Java-jar Start.jar to start jetty.
Jetty Source Learning-compiling jetty source code two or three