blob: 5596fdf50ff2f507e52fa5fbff5b467adcd988ac [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 Tomassettiabcb5182018-02-13 18:20:56 +01008This project contains a set of libraries implementing a Java 1.0 - Java 9 Parser with advanced analysis functionalities.
Federico Tomassetti18d5a7d2018-02-12 16:34:03 +01009
10Our main site is at [JavaParser.org](http://javaparser.org)
11
12## Setup
13
14The project binaries are available in Maven Central.
15
Federico Tomassettiabcb5182018-02-13 18:20:56 +010016We strongly advises users to adopt Maven, Gradle or another build system for their projects. If you are not familiar with them
17we 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 Tomassetti18d5a7d2018-02-12 16:34:03 +010020
21Just add the following to your maven configuration or tailor to your own dependency management system.
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010022
Danny van Bruggen0962cf82017-08-27 20:20:12 +020023[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 -040024
un0btanium785f9352018-01-28 15:32:45 +010025**Maven**:
26
27```xml
28<dependency>
29 <groupId>com.github.javaparser</groupId>
30 <artifactId>javaparser-symbol-solver-core</artifactId>
Danny van Bruggen5dfb1e22018-02-25 18:53:48 +010031 <version>3.5.15</version>
un0btanium785f9352018-01-28 15:32:45 +010032</dependency>
33```
34
35**Gradle**:
36
37```
Danny van Bruggen5dfb1e22018-02-25 18:53:48 +010038compile 'com.github.javaparser:javaparser-symbol-solver-core:3.5.15'
un0btanium785f9352018-01-28 15:32:45 +010039```
40
Federico Tomassetti18d5a7d2018-02-12 16:34:03 +010041Since Version 3.5.10, the JavaParser project includes the JavaSymbolSolver.
42While JavaParser generates an Abstract Syntax Tree, JavaSymbolSolver analyzes that AST and is able to find
43the 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 +010044
45Using 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 Mehrotra112f4592017-07-10 13:47:53 -040048
Danny van Bruggen11887502016-12-05 19:27:34 +010049```xml
50<dependency>
51 <groupId>com.github.javaparser</groupId>
52 <artifactId>javaparser-core</artifactId>
Danny van Bruggen5dfb1e22018-02-25 18:53:48 +010053 <version>3.5.15</version>
Danny van Bruggen3588d262017-02-19 23:00:47 +010054</dependency>
55```
56
un0btanium785f9352018-01-28 15:32:45 +010057**Gradle**:
Parth Mehrotra112f4592017-07-10 13:47:53 -040058
59```
Danny van Bruggen5dfb1e22018-02-25 18:53:48 +010060compile 'com.github.javaparser:javaparser-core:3.5.15'
Parth Mehrotra112f4592017-07-10 13:47:53 -040061```
62
Nicholas Smithcd1296d2015-01-20 14:22:40 +000063## How To Compile Sources
Nicholas Smith15a23ae2015-01-14 10:27:51 +000064
Danny van Bruggend67b5062017-04-16 15:07:23 +020065If you checked out the project from GitHub you can build the project with maven using:
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010066
Federico Tomassetti2051f042014-07-30 19:01:19 +010067```
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010068mvn clean install
Federico Tomassetti2051f042014-07-30 19:01:19 +010069```
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010070
Danny van Bruggen11887502016-12-05 19:27:34 +010071If 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 +000072
73```
74mvn javacc:javacc
75```
76
Danny van Bruggen45f83182017-07-10 20:15:11 +020077If 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 +020078the code generators will update a lot of code for you.
Danny van Bruggen45f83182017-07-10 20:15:11 +020079The `run_metamodel_generator.sh` script will rebuild the metamodel,
80which is used by the code generators which are run by `run_core_generators.sh`
81Make sure that `javaparser-core` at least compiles before you run these.
82
Danny van Bruggen25c927d2017-12-10 14:20:43 +010083## More information
Nicholas Smithcd1296d2015-01-20 14:22:40 +000084
Danny van Bruggen25c927d2017-12-10 14:20:43 +010085#### [JavaParser.org](https://www.javaparser.org) is the main information site.
Federico Tomassetticf8d7b12014-07-30 19:00:26 +010086
Didier Villevaloisd5e88432015-03-16 14:23:45 +010087## License
Nicholas Smith26c753d2015-01-14 10:02:55 +000088
Federico Tomassetti2c7ba122015-08-12 08:06:33 +020089JavaParser 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 +020090
91For details about the LGPL License please refer to [LICENSE.LGPL](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.LGPL).
92
93For details about the Apache License please refer to [LICENSE.APACHE](ttps://github.com/javaparser/javaparser/blob/master/LICENSE.APACHE).