blob: b4294bbe7c6ceb6b45f15778b1ecaf543232ecc8 [file] [log] [blame] [view]
Nicholas Smith646793d2015-01-20 14:53:07 +00001## Java Parser and Abstract Syntax Tree
matozoid2cab70d2013-09-16 13:31:33 +02002
Danny van Bruggen3ad07502017-03-23 15:24:33 +01003This package contains a Java 1.0 - Java 9 Parser with AST generation and visitor support.
Nicholas Smithcd1296d2015-01-20 14:22:40 +00004
Danny van Bruggen5e6d7292017-07-16 22:19:10 +02005Our main site is at [JavaParser.org](http://javaparser.org)
matozoid2d4deca2011-10-30 14:35:59 +01006
Nicholas Smithd7c51132015-09-02 13:14:42 +01007[![Maven Central](https://img.shields.io/maven-central/v/com.github.javaparser/javaparser-core.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.javaparser%22%20AND%20a%3A%22javaparser-core%22)
Nicholas Smith2b77f432015-02-23 11:01:28 +00008[![Build Status](https://travis-ci.org/javaparser/javaparser.svg?branch=master)](https://travis-ci.org/javaparser/javaparser)
Nicholas Smithcc80fc12015-08-17 15:15:26 +01009[![Coverage Status](https://coveralls.io/repos/javaparser/javaparser/badge.svg?branch=master&service=github)](https://coveralls.io/github/javaparser/javaparser?branch=master)
Nicholas Smithd6a80982015-08-17 15:25:32 +010010[![Join the chat at https://gitter.im/javaparser/javaparser](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/javaparser/javaparser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Nicholas Smithcc80fc12015-08-17 15:15:26 +010011
Nicholas Smithcd1296d2015-01-20 14:22:40 +000012## Dependency Management
13
matozoid3c137e92016-04-06 19:37:37 +020014The project binaries are available in Maven Central. Just add the following to your maven configuration or tailor to your own dependency management system.
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010015
Danny van Bruggen0962cf82017-08-27 20:20:12 +020016[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 Mehrotra112f4592017-07-10 13:47:53 -040017
un0btanium785f9352018-01-28 15:32:45 +010018**Maven**:
19
20```xml
21<dependency>
22 <groupId>com.github.javaparser</groupId>
23 <artifactId>javaparser-symbol-solver-core</artifactId>
Danny van Bruggen0061b4b2018-02-11 21:58:02 +010024 <version>3.5.14</version>
un0btanium785f9352018-01-28 15:32:45 +010025</dependency>
26```
27
28**Gradle**:
29
30```
Danny van Bruggen0061b4b2018-02-11 21:58:02 +010031compile 'com.github.javaparser:javaparser-symbol-solver-core:3.5.14'
un0btanium785f9352018-01-28 15:32:45 +010032```
33
34
35
36Since Version 3.5.10, the JavaParser project includes the JavaSymbolSolver. While JavaParser generates an Abstract Syntax Tree, JavaSymbolSolver analyzes that AST and is able to find 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).
37
38Using 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:
39
40**Maven**:
Parth Mehrotra112f4592017-07-10 13:47:53 -040041
Danny van Bruggen11887502016-12-05 19:27:34 +010042```xml
43<dependency>
44 <groupId>com.github.javaparser</groupId>
45 <artifactId>javaparser-core</artifactId>
Danny van Bruggen0061b4b2018-02-11 21:58:02 +010046 <version>3.5.14</version>
Danny van Bruggen3588d262017-02-19 23:00:47 +010047</dependency>
48```
49
un0btanium785f9352018-01-28 15:32:45 +010050**Gradle**:
Parth Mehrotra112f4592017-07-10 13:47:53 -040051
52```
Danny van Bruggen0061b4b2018-02-11 21:58:02 +010053compile 'com.github.javaparser:javaparser-core:3.5.14'
Parth Mehrotra112f4592017-07-10 13:47:53 -040054```
55
Nicholas Smithcd1296d2015-01-20 14:22:40 +000056## How To Compile Sources
Nicholas Smith15a23ae2015-01-14 10:27:51 +000057
Danny van Bruggend67b5062017-04-16 15:07:23 +020058If you checked out the project from GitHub you can build the project with maven using:
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010059
Federico Tomassetti2051f042014-07-30 19:01:19 +010060```
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010061mvn clean install
Federico Tomassetti2051f042014-07-30 19:01:19 +010062```
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010063
Danny van Bruggen11887502016-12-05 19:27:34 +010064If 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 Smithcd1296d2015-01-20 14:22:40 +000065
66```
67mvn javacc:javacc
68```
69
Danny van Bruggen45f83182017-07-10 20:15:11 +020070If you modify the code of the AST nodes, specifically if you add or remove fields or node classes,
Danny van Bruggen969b7f62017-07-10 21:03:41 +020071the code generators will update a lot of code for you.
Danny van Bruggen45f83182017-07-10 20:15:11 +020072The `run_metamodel_generator.sh` script will rebuild the metamodel,
73which is used by the code generators which are run by `run_core_generators.sh`
74Make sure that `javaparser-core` at least compiles before you run these.
75
Danny van Bruggen25c927d2017-12-10 14:20:43 +010076## More information
Nicholas Smithcd1296d2015-01-20 14:22:40 +000077
Danny van Bruggen25c927d2017-12-10 14:20:43 +010078#### [JavaParser.org](https://www.javaparser.org) is the main information site.
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010079
Didier Villevaloisd5e88432015-03-16 14:23:45 +010080## License
Nicholas Smith26c753d2015-01-14 10:02:55 +000081
Federico Tomassetti2c7ba122015-08-12 08:06:33 +020082JavaParser 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 Tomassettiee6a48a2015-07-25 14:42:17 +020083
84For details about the LGPL License please refer to [LICENSE.LGPL](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.LGPL).
85
86For details about the Apache License please refer to [LICENSE.APACHE](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.APACHE).