| Federico Tomassetti | 18d5a7d | 2018-02-12 16:34:03 +0100 | [diff] [blame] | 1 | # JavaParser
|
| matozoid | 2d4deca | 2011-10-30 14:35:59 +0100 | [diff] [blame] | 2 |
|
| Nicholas Smith | d7c5113 | 2015-09-02 13:14:42 +0100 | [diff] [blame] | 3 | [](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.javaparser%22%20AND%20a%3A%22javaparser-core%22)
|
| Nicholas Smith | 2b77f43 | 2015-02-23 11:01:28 +0000 | [diff] [blame] | 4 | [](https://travis-ci.org/javaparser/javaparser)
|
| Nicholas Smith | cc80fc1 | 2015-08-17 15:15:26 +0100 | [diff] [blame] | 5 | [](https://coveralls.io/github/javaparser/javaparser?branch=master)
|
| Nicholas Smith | d6a8098 | 2015-08-17 15:25:32 +0100 | [diff] [blame] | 6 | [](https://gitter.im/javaparser/javaparser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
| Nicholas Smith | cc80fc1 | 2015-08-17 15:15:26 +0100 | [diff] [blame] | 7 |
|
| Federico Tomassetti | abcb518 | 2018-02-13 18:20:56 +0100 | [diff] [blame] | 8 | This project contains a set of libraries implementing a Java 1.0 - Java 9 Parser with advanced analysis functionalities.
|
| Federico Tomassetti | 18d5a7d | 2018-02-12 16:34:03 +0100 | [diff] [blame] | 9 |
|
| 10 | Our main site is at [JavaParser.org](http://javaparser.org)
|
| 11 |
|
| 12 | ## Setup
|
| 13 |
|
| 14 | The project binaries are available in Maven Central.
|
| 15 |
|
| Federico Tomassetti | abcb518 | 2018-02-13 18:20:56 +0100 | [diff] [blame] | 16 | We strongly advises users to adopt Maven, Gradle or another build system for their projects. If you are not familiar with them
|
| 17 | we suggest taking a look at the maven quickstart projects
|
| 18 | ([javaparser-maven-sample](https://github.com/javaparser/javaparser-maven-sample),
|
| 19 | [javasymbolsolver-maven-sample](https://github.com/javaparser/javasymbolsolver-maven-sample)).
|
| Federico Tomassetti | 18d5a7d | 2018-02-12 16:34:03 +0100 | [diff] [blame] | 20 |
|
| 21 | Just add the following to your maven configuration or tailor to your own dependency management system.
|
| Federico Tomassetti | cf8d7b1 | 2014-07-30 19:00:26 +0100 | [diff] [blame] | 22 |
|
| Danny van Bruggen | 0962cf8 | 2017-08-27 20:20:12 +0200 | [diff] [blame] | 23 | [Please refer to the Migration Guide when upgrading from 2.5.1 to 3.0.0+](https://github.com/javaparser/javaparser/wiki/Migration-Guide)
|
| Parth Mehrotra | 112f459 | 2017-07-10 13:47:53 -0400 | [diff] [blame] | 24 |
|
| un0btanium | 785f935 | 2018-01-28 15:32:45 +0100 | [diff] [blame] | 25 | **Maven**:
|
| 26 |
|
| 27 | ```xml
|
| 28 | <dependency>
|
| 29 | <groupId>com.github.javaparser</groupId>
|
| 30 | <artifactId>javaparser-symbol-solver-core</artifactId>
|
| Danny van Bruggen | 5dfb1e2 | 2018-02-25 18:53:48 +0100 | [diff] [blame] | 31 | <version>3.5.15</version>
|
| un0btanium | 785f935 | 2018-01-28 15:32:45 +0100 | [diff] [blame] | 32 | </dependency>
|
| 33 | ```
|
| 34 |
|
| 35 | **Gradle**:
|
| 36 |
|
| 37 | ```
|
| Danny van Bruggen | 5dfb1e2 | 2018-02-25 18:53:48 +0100 | [diff] [blame] | 38 | compile 'com.github.javaparser:javaparser-symbol-solver-core:3.5.15'
|
| un0btanium | 785f935 | 2018-01-28 15:32:45 +0100 | [diff] [blame] | 39 | ```
|
| 40 |
|
| Federico Tomassetti | 18d5a7d | 2018-02-12 16:34:03 +0100 | [diff] [blame] | 41 | Since Version 3.5.10, the JavaParser project includes the JavaSymbolSolver.
|
| 42 | While JavaParser generates an Abstract Syntax Tree, JavaSymbolSolver analyzes that AST and is able to find
|
| 43 | the relation between an element and its declaration (e.g. for a variable name it could be a parameter of a method, providing information about its type, position in the AST, ect).
|
| un0btanium | 785f935 | 2018-01-28 15:32:45 +0100 | [diff] [blame] | 44 |
|
| 45 | Using the dependency above will add both JavaParser and JavaSymbolSolver to your project. If you only need the core functionality of parsing Java source code in order to traverse and manipulate the generated AST, you can reduce your projects boilerplate by only including JavaParser to your project:
|
| 46 |
|
| 47 | **Maven**:
|
| Parth Mehrotra | 112f459 | 2017-07-10 13:47:53 -0400 | [diff] [blame] | 48 |
|
| Danny van Bruggen | 1188750 | 2016-12-05 19:27:34 +0100 | [diff] [blame] | 49 | ```xml
|
| 50 | <dependency>
|
| 51 | <groupId>com.github.javaparser</groupId>
|
| 52 | <artifactId>javaparser-core</artifactId>
|
| Danny van Bruggen | 5dfb1e2 | 2018-02-25 18:53:48 +0100 | [diff] [blame] | 53 | <version>3.5.15</version>
|
| Danny van Bruggen | 3588d26 | 2017-02-19 23:00:47 +0100 | [diff] [blame] | 54 | </dependency>
|
| 55 | ```
|
| 56 |
|
| un0btanium | 785f935 | 2018-01-28 15:32:45 +0100 | [diff] [blame] | 57 | **Gradle**:
|
| Parth Mehrotra | 112f459 | 2017-07-10 13:47:53 -0400 | [diff] [blame] | 58 |
|
| 59 | ```
|
| Danny van Bruggen | 5dfb1e2 | 2018-02-25 18:53:48 +0100 | [diff] [blame] | 60 | compile 'com.github.javaparser:javaparser-core:3.5.15'
|
| Parth Mehrotra | 112f459 | 2017-07-10 13:47:53 -0400 | [diff] [blame] | 61 | ```
|
| 62 |
|
| Nicholas Smith | cd1296d | 2015-01-20 14:22:40 +0000 | [diff] [blame] | 63 | ## How To Compile Sources
|
| Nicholas Smith | 15a23ae | 2015-01-14 10:27:51 +0000 | [diff] [blame] | 64 |
|
| Danny van Bruggen | d67b506 | 2017-04-16 15:07:23 +0200 | [diff] [blame] | 65 | If you checked out the project from GitHub you can build the project with maven using:
|
| Federico Tomassetti | cf8d7b1 | 2014-07-30 19:00:26 +0100 | [diff] [blame] | 66 |
|
| Federico Tomassetti | 2051f04 | 2014-07-30 19:01:19 +0100 | [diff] [blame] | 67 | ```
|
| Federico Tomassetti | cf8d7b1 | 2014-07-30 19:00:26 +0100 | [diff] [blame] | 68 | mvn clean install
|
| Federico Tomassetti | 2051f04 | 2014-07-30 19:01:19 +0100 | [diff] [blame] | 69 | ```
|
| Federico Tomassetti | cf8d7b1 | 2014-07-30 19:00:26 +0100 | [diff] [blame] | 70 |
|
| Danny van Bruggen | 1188750 | 2016-12-05 19:27:34 +0100 | [diff] [blame] | 71 | If you checkout the sources and want to view the project in an IDE, it is best to first generate some of the source files; otherwise you will get many compilation complaints in the IDE. (mvn clean install already does this for you.)
|
| Nicholas Smith | cd1296d | 2015-01-20 14:22:40 +0000 | [diff] [blame] | 72 |
|
| 73 | ```
|
| 74 | mvn javacc:javacc
|
| 75 | ```
|
| 76 |
|
| Danny van Bruggen | 45f8318 | 2017-07-10 20:15:11 +0200 | [diff] [blame] | 77 | If you modify the code of the AST nodes, specifically if you add or remove fields or node classes,
|
| Danny van Bruggen | 969b7f6 | 2017-07-10 21:03:41 +0200 | [diff] [blame] | 78 | the code generators will update a lot of code for you.
|
| Danny van Bruggen | 45f8318 | 2017-07-10 20:15:11 +0200 | [diff] [blame] | 79 | The `run_metamodel_generator.sh` script will rebuild the metamodel,
|
| 80 | which is used by the code generators which are run by `run_core_generators.sh`
|
| 81 | Make sure that `javaparser-core` at least compiles before you run these.
|
| 82 |
|
| Danny van Bruggen | 25c927d | 2017-12-10 14:20:43 +0100 | [diff] [blame] | 83 | ## More information
|
| Nicholas Smith | cd1296d | 2015-01-20 14:22:40 +0000 | [diff] [blame] | 84 |
|
| Danny van Bruggen | 25c927d | 2017-12-10 14:20:43 +0100 | [diff] [blame] | 85 | #### [JavaParser.org](https://www.javaparser.org) is the main information site.
|
| Federico Tomassetti | cf8d7b1 | 2014-07-30 19:00:26 +0100 | [diff] [blame] | 86 |
|
| Didier Villevalois | d5e8843 | 2015-03-16 14:23:45 +0100 | [diff] [blame] | 87 | ## License
|
| Nicholas Smith | 26c753d | 2015-01-14 10:02:55 +0000 | [diff] [blame] | 88 |
|
| Federico Tomassetti | 2c7ba12 | 2015-08-12 08:06:33 +0200 | [diff] [blame] | 89 | JavaParser is available either under the terms of the LGPL License or the Apache License. You as the user are entitled to choose the terms under which adopt JavaParser.
|
| Federico Tomassetti | ee6a48a | 2015-07-25 14:42:17 +0200 | [diff] [blame] | 90 |
|
| 91 | For details about the LGPL License please refer to [LICENSE.LGPL](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.LGPL).
|
| 92 |
|
| 93 | For details about the Apache License please refer to [LICENSE.APACHE](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.APACHE).
|