-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Eclipse Project Setup Guide
This is a project setup guide for the Eclipse IDE. It will take you through the steps needed to: (1) fork the project, (2) setup a fully working project in Eclipse, (3) push your changes (we'll add a test case) to your GitHub repository, and (4) create a pull request.
Download and install Git for your operating system before proceeding to the next section. Remember to add the Git binaries directory to your OS PATH environment variable. See Git installation guide.
Download and install Maven before proceeding to the next section. Remember to add the Maven binaries directory to your OS PATH environment variable. See Maven installation guide.
Please install the following plugins through the Eclipse Marketplace
before proceeding to the next section. You can check if they're already installed by
selecting the Help->Installation Details
menu item in the IDE menu bar. These plugins
likely depend on the required entries to be included in the PATH variable as mentioned above.
- EGit (Git Integration for Eclipse)
- m2e (Maven support for Eclipse)
- m2e-connector for maven-dependency-plugin
You may find these plugins helpful as well, but aren't required:
- m2e javacc connector - Update site
- Maven SCM Handler for EGit (Support for Maven SCM commands)
- GitHub Mylyn Connector (Viewing Issues, Pull Requests, etc.)
- JavaCC Eclipse (Support for JavaCC files)
- SF JavaCC Eclipse Plugin-in Feature (Support for JavaCC files)
- JBehave Eclipse (Support for JBehave tests)
- JBehave Editor (Support for JBehave tests)
Please visit the code styling guide to set the formatting scheme for Eclipse. Be sure add a license header to each new file added to the project.
To fork the project, execute the following steps at the GitHub website:
- Register an account with GitHub if not already done. Make sure you're signed into your account.
- Visit the main repository page at https://github.com/javaparser/javaparser.
- At the top right-hand corner of the page, just below your profile avatar
(or profile settings dropdown), click the
Fork
button. - You now have a new repository whose content is an exact copy of the javaparser project.
To clone the project into Eclipse, execute the following steps in Eclipse:
- Select the
Window->Show View
menu item in the IDE menu bar. Typegit
in the filter text field and select theGit Repositories
view. - In the repository view, select the down arrow, which is the very last button
in view's toolbar. Select
Clone Repository
. - In the Select Repository Source prompt, select
Clone URI
and pressNext
. - Go to your forked repository's main page on GitHub. Press the down arrow on the green button
that says
Clone or download
. Copy the web URL to your clipboard. The URL is of the formhttps://github.com/<your-profile-name>/javaparser
. In Eclipse, paste this URL in theURI
text field, and theHost
andRepository Path
fields will be populated automatically. - Fill in the Authentication panel with your profile credentials. Also check
Store in Secure Store
to prevent Eclipse from re-prompting you later for those same credentials to make repository updates. - Press
Next
. - In the Branch Selection prompt, leave both branches selected and press
Next
. - In the Local Destination prompt, select the directory where you'd like to download
the project to. Ideally, this should be your Eclipse workspace directory. The path
should be:
<path to workspace>/javaparser
. Leave all other options untouched. - Congratulations! You've cloned the project and it exists as a repository in Eclipse.
To build the project (and prevent IDE errors in the next sections), execute the following steps:
- Open your OS command prompt and navigate to the root directory of the project.
- Type
mvn javacc:javacc
. - Type
mvn clean install
. The installation may take some time. Verify in the Maven results summary that thejavaparser-core
module built successfully. Do not be concerned if the other module builds fail or are skipped for now.
To import the project into Eclipse, execute the following steps in Eclipse:
- Select the
File->Import
menu item in the IDE menu bar. Typemaven
in the filter text field and select theExisting Maven Projects
option. - In the Select Project prompt, click the
Browse
button and navigate to the root folder of thejavaparser-core
project. PressOK
. Ensure the POM file that appears in theProjects
text area is selected. PressFinish
. Note that if you haven't installed them2e connector for javacc-maven-plugin
, Eclipse will alert you of an unresolved error. If so, you can still continue without problems for our purposes. - In the
Package Explorer
view, the project should appear annotated with Maven, Java, and Git Nature icons. - Repeat steps 1-3 for the
javaparser-testing
project. - Congratulations! You've imported the projects and are almost ready to start testing.
It's advisable to open the Problems
view to see project errors resolve as you execute
the following steps in Eclipse:
- Right-click the
javaparser-core
project. In the context menu, selectBuild Path->Configure Build Path
. - In the main panel, ensure the
Source
tab is selected. PressAdd Folder
. Expandtarget->generated-sources
and selectjavacc
. DO NOT deselect any other selected directories. PressOK
. - Press
Apply
andOK
. Clean and Build your workspace. All errors should be resolved.
Since javaparser-core
is specified as a Maven dependency in the test project's POM file, it should
already be listed under the Maven Dependencies
directory of the javaparser-testing
project.
However, you'll need to re-build javaparser-testing
after making changes to the core project.
I recommend applying the Clean option in Eclipse's Project menu.
We're going to add a JUnit test and push it to our GitHub repository in the following steps in Eclipse:
- In the
Package explorer
view, under thejavaparser-testing
project, expand thesrc/test/java
directory. A number of test packages should appear. - Right-click the first package,
com.github.javaparser
, and in the context menu, selectNew->JUnit Test Case
. If this option doesn't exist, selectNew->Other
and find theJUnit Test Case
option. - Name the class
SetupTest
and pressFinish
. - Remove the call to
fail(String)
in thetest()
method implementation. - Make sure to add the licensing header.
- Select
Run->Run As->JUnit Test
in the IDE's menu bar. The test should pass. - You'll notice in the package explorer that the file icon for
SetupTest.java
is annotated with a question mark. This indicates you need to track the file in Git. - Right-click
SetupTest.java
, and in the context menu, selectTeam->Add to Index
. The file icon will now be annotated with a green plus (+) symbol. - Now we'll commit the project changes. Right-click the project,
javaparser-testing
, and in the context menu, selectTeam->Commit
. TheGit Staging
view will appear. Enter a commit message, e.g., 'Added setup test case', and pressCommit
. Now your changes to the project have been saved to Git. - Now we'll push your changes to your GitHub repository. In the
Git Repositories
view, right-click thejavaparser
repository, and in the context menu, selectPush Branch 'master'
. - In the Push to Branch prompt, you should see the URL for your GitHub repository selected
for the
Remote
branch. PressNext
. - Press
Finish
to complete the push. A window should appear confirming a successful push. - Congratulations! One step to go!
We'll create a pull request in the following steps. Please note that you should not create a pull request until you've actually made what you feel is a worthwhile contribution you'd like the maintainers to consider! Thank you.
- Go to your repository's main page, and you'll see that you've made the latest commit.
- Press the
New pull request
button right above the latest commit message (next to the branch selector drop menu). - A page entitled Comparing changes appears showing you what changes the maintainers will be shown upon reviewing your request.
- Press the green
Create pull request
button to finalize your request. - Congratulations! You did it! 👍
Website: JavaParser.org Chat: Gitter.im/JavaParser/JavaParser Free eBook: leanpub.com/JavaParserVisited
- Home
- Migration Guide (2.5.1 to 3.0.0)
- Migration Guide (3.25.10 to 3.26.0)
- Inspecting an AST
JavaParser
vsStaticJavaParser
Pro* jectRoot
vsSourceRoot
(Analysing a Whole Project)- Parsing Java Comments
- Getting started with JavaParser: analyzing Java Code programmatically
- Observers for AST nodes in JavaParser
- Implementing Lexical Preservation for JavaParser
- JavaParser’s logging framework in one file
- Making strings in JavaParser
- The quick and the full API of JavaParser
- Less Casting in JavaParser
- Parse error recovery
- Inverting ifs in JavaParser
- Code generation and Maven in JavaParser
- Semantic validations in JavaParser
- Setting Java 8, 9, 10, etc
- Analysing an entire project in one go
- Pragmatic Versioning
- Testing JavaParser Code
- Functional Tree Traversal
- Coding Guidelines
- Eclipse Project Setup Guide
- Code Style / Architecture
- Build Process
- Release Process
- A Detailed Guide to Adding New Nodes and Fields
Visit the JavaParser blog
Download the JavaParserVisited book (free!).
Join the chatroom on Gitter!