This project uses the Java Compiler API to analyze method references in a Maven project. It scans all Java files in the project and identifies both method declarations and method references.
- Analyzes all Java files in a Maven project
- Identifies method declarations
- Identifies method references
- Supports custom source directories (via pom.xml configuration)
- Provides detailed logging of findings
- Java 11 or higher
- Maven 3.6 or higher
To build the project, run:
mvn clean packageThis will create a runnable JAR file in the target directory.
Run the analyzer by providing the path to your Maven project:
java -jar target/method-reference-analyzer-1.0-SNAPSHOT-jar-with-dependencies.jar /path/to/your/maven/projectThe analyzer will:
- Read the project's pom.xml to determine the source directory
- Scan all Java files in the project
- Log all method declarations and method references found
The analyzer will output:
- The path of each Java file being analyzed
- All method declarations found in each file
- All method references found in each file
- Line numbers where methods and references are found
INFO: Analyzing file: /path/to/project/src/main/java/com/example/MyClass.java
INFO: Found method: myMethod in 10
INFO: Found method reference: MyClass::myMethod in 15
The analyzer includes error handling for:
- Invalid project paths
- Missing source directories
- File parsing errors
- Maven configuration issues
All errors are logged with appropriate context information.
You can run the analyzer directly using Maven without building the JAR file by using the following command:
mvn exec:java -Dexec.mainClass="com.example.ReferenceAnalyzerMain" -Dexec.args="/path/to/your/maven/project"Replace /path/to/your/maven/project with the path to the Maven project you want to analyze.
This command will:
- Compile the code if necessary
- Run the analyzer directly
- Output results as described below
To run the tests for the project, use the following command:
mvn testThis will execute all the tests defined in the project.