blob: a1c6527f67e9a99bc0e654282a3b1509a7e85baa [file] [log] [blame] [view]
Federico Tomassetti18d5a7d2018-02-12 16:34:03 +01001# JavaParser
matozoid2d4deca2011-10-30 14:35:59 +01002
Nicholas Smithd7c51132015-09-02 13:14:42 +01003[![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 +00004[![Build Status](https://travis-ci.org/javaparser/javaparser.svg?branch=master)](https://travis-ci.org/javaparser/javaparser)
Nicholas Smithcc80fc12015-08-17 15:15:26 +01005[![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 +01006[![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 +01007
Federico Tomassetti18d5a7d2018-02-12 16:34:03 +01008This project contains a set of libraries implementing a Java 1.0 - Java 9 Parser with AST generation and advanced features
9like:
Nicholas Smithcd1296d2015-01-20 14:22:40 +000010
Federico Tomassetti18d5a7d2018-02-12 16:34:03 +010011* comment attribution
12* lexical preservation
13* code generation
14* symbol resolution (through the JavaSymbolSolver module)
15
16Our main site is at [JavaParser.org](http://javaparser.org)
17
18## Setup
19
20The project binaries are available in Maven Central.
21
22We strongly advises users to adopt Maven, Gradle or another build system for their projects.
23
24Just add the following to your maven configuration or tailor to your own dependency management system.
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010025
Danny van Bruggen0962cf82017-08-27 20:20:12 +020026[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 -040027
un0btanium785f9352018-01-28 15:32:45 +010028**Maven**:
29
30```xml
31<dependency>
32 <groupId>com.github.javaparser</groupId>
33 <artifactId>javaparser-symbol-solver-core</artifactId>
Danny van Bruggen0061b4b2018-02-11 21:58:02 +010034 <version>3.5.14</version>
un0btanium785f9352018-01-28 15:32:45 +010035</dependency>
36```
37
38**Gradle**:
39
40```
Danny van Bruggen0061b4b2018-02-11 21:58:02 +010041compile 'com.github.javaparser:javaparser-symbol-solver-core:3.5.14'
un0btanium785f9352018-01-28 15:32:45 +010042```
43
Federico Tomassetti18d5a7d2018-02-12 16:34:03 +010044Since Version 3.5.10, the JavaParser project includes the JavaSymbolSolver.
45While JavaParser generates an Abstract Syntax Tree, JavaSymbolSolver analyzes that AST and is able to find
46the 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).
un0btanium785f9352018-01-28 15:32:45 +010047
48Using 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:
49
50**Maven**:
Parth Mehrotra112f4592017-07-10 13:47:53 -040051
Danny van Bruggen11887502016-12-05 19:27:34 +010052```xml
53<dependency>
54 <groupId>com.github.javaparser</groupId>
55 <artifactId>javaparser-core</artifactId>
Danny van Bruggen0061b4b2018-02-11 21:58:02 +010056 <version>3.5.14</version>
Danny van Bruggen3588d262017-02-19 23:00:47 +010057</dependency>
58```
59
un0btanium785f9352018-01-28 15:32:45 +010060**Gradle**:
Parth Mehrotra112f4592017-07-10 13:47:53 -040061
62```
Danny van Bruggen0061b4b2018-02-11 21:58:02 +010063compile 'com.github.javaparser:javaparser-core:3.5.14'
Parth Mehrotra112f4592017-07-10 13:47:53 -040064```
65
Nicholas Smithcd1296d2015-01-20 14:22:40 +000066## How To Compile Sources
Nicholas Smith15a23ae2015-01-14 10:27:51 +000067
Danny van Bruggend67b5062017-04-16 15:07:23 +020068If you checked out the project from GitHub you can build the project with maven using:
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010069
Federico Tomassetti2051f042014-07-30 19:01:19 +010070```
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010071mvn clean install
Federico Tomassetti2051f042014-07-30 19:01:19 +010072```
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010073
Danny van Bruggen11887502016-12-05 19:27:34 +010074If 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 +000075
76```
77mvn javacc:javacc
78```
79
Danny van Bruggen45f83182017-07-10 20:15:11 +020080If 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 +020081the code generators will update a lot of code for you.
Danny van Bruggen45f83182017-07-10 20:15:11 +020082The `run_metamodel_generator.sh` script will rebuild the metamodel,
83which is used by the code generators which are run by `run_core_generators.sh`
84Make sure that `javaparser-core` at least compiles before you run these.
85
Danny van Bruggen25c927d2017-12-10 14:20:43 +010086## More information
Nicholas Smithcd1296d2015-01-20 14:22:40 +000087
Danny van Bruggen25c927d2017-12-10 14:20:43 +010088#### [JavaParser.org](https://www.javaparser.org) is the main information site.
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010089
Didier Villevaloisd5e88432015-03-16 14:23:45 +010090## License
Nicholas Smith26c753d2015-01-14 10:02:55 +000091
Federico Tomassetti2c7ba122015-08-12 08:06:33 +020092JavaParser 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 +020093
94For details about the LGPL License please refer to [LICENSE.LGPL](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.LGPL).
95
96For details about the Apache License please refer to [LICENSE.APACHE](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.APACHE).