Skip to content

Commit c81209c

Browse files
committed
release v1
1 parent 9a4bc8c commit c81209c

22 files changed

+2296
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ build/
3535
#vscode
3636
.vscode/
3737

38+
.java-version
39+
40+
.cursor/

CHANGELOG.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2024-05-30
9+
10+
### 🎉 Initial Release
11+
12+
#### ✨ New Features
13+
- **ParseTestCaseToLlmContext Task**: Parses Java test cases and generates LLM-friendly JSON output
14+
- **Intelligent Build System Detection**: Automatically identifies and configures Maven/Gradle projects
15+
- **Enhanced Dependency Resolution**:
16+
- Maven: Parses dependencies from `pom.xml`, automatically handles property variables
17+
- Gradle: Uses Tooling API to get project configuration
18+
- Automatic search of local caches (`~/.m2`, `~/.gradle/caches`) for missing dependencies
19+
- **Automatic Test Framework Support**: JUnit 4/5, Mockito, Hamcrest, AssertJ
20+
- **Intelligent Statement Classification**: ASSERT, MOCK, NEW, THIRD, GET/SET, PRODUCTION
21+
- **DFS Method Call Analysis**: Recursively expands method calls within test cases
22+
- **Multi-threaded Parallel Processing**: Supports concurrent analysis of multiple test files
23+
- **Extensible Plugin Architecture**: Task and visitor extension mechanism based on Java SPI
24+
25+
#### 🔧 Technical Features
26+
- **Fat JAR Distribution**: Includes all dependencies, ready to use out of the box
27+
- **Detailed Debug Logging**: Complete dependency resolution and configuration detection logs
28+
- **Cross-platform Support**: Windows, macOS, Linux
29+
- **Java 21 Support**: Uses latest JDK features
30+
31+
#### 📋 Output Format
32+
```json
33+
{
34+
"project": "project name",
35+
"testClassName": "fully qualified test class name",
36+
"testCaseName": "test method name",
37+
"parsedStatementsSequence": ["method call sequence"],
38+
"productionFunctionImplementations": ["production code implementations"],
39+
"testCaseSourceCode": "test case source code",
40+
"importedPackages": ["imported packages list"]
41+
}
42+
```
43+
44+
#### 🏗️ Dependencies
45+
- **parser-core**: Core AST parsing engine
46+
- **picocli**: Command line interface framework
47+
- **Eclipse JDT**: Java development tools core
48+
- **Gson**: JSON serialization library
49+
50+
#### 📝 Command Line Interface
51+
```bash
52+
java -jar Javalang-analyzing-cli-1.0.0-all.jar ParseTestCaseToLlmContext \
53+
--project /path/to/project \
54+
--threads 8 \
55+
--format json
56+
```
57+
58+
### 🐛 Known Issues
59+
- Output directory is currently hardcoded to `results/` folder under project root
60+
- Some complex Maven dependency management scenarios may require manual intervention
61+
62+
### 🔄 Future Plans
63+
- Support for Go and Python project analysis
64+
- Configurable output directory
65+
- More built-in analysis tasks
66+
- Web UI interface
67+
68+
---
69+
70+
## Version Format Description
71+
72+
- **[Major.Minor.Patch]** - Release date
73+
- **Major**: Incompatible API changes
74+
- **Minor**: Backward-compatible functionality additions
75+
- **Patch**: Backward-compatible bug fixes

README.md

Lines changed: 233 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,233 @@
1-
# Javalang-analyzing-cli
1+
# Javalang-analyzing-cli
2+
3+
> A powerful Java code analysis command-line tool designed for research and code quality analysis.
4+
5+
[![License](https://img.shields.io/github/license/your-username/Javalang-analyzing-cli)](LICENSE)
6+
[![Release](https://img.shields.io/github/v/release/your-username/Javalang-analyzing-cli)](https://github.com/your-username/Javalang-analyzing-cli/releases)
7+
8+
## 🚀 Quick Start
9+
10+
### Download
11+
12+
Download the latest `Javalang-analyzing-cli-all.jar` from the [Releases](https://github.com/your-username/Javalang-analyzing-cli/releases) page.
13+
14+
This is a **Fat JAR** that includes all dependencies - no additional installation required.
15+
16+
### System Requirements
17+
18+
- **Java 21** or higher
19+
- Supported OS: Windows, macOS, Linux
20+
21+
### Basic Usage
22+
23+
```bash
24+
# Check version
25+
java -jar Javalang-analyzing-cli-all.jar --version
26+
27+
# Show help
28+
java -jar Javalang-analyzing-cli-all.jar --help
29+
30+
# Analyze test cases and generate LLM context
31+
java -jar Javalang-analyzing-cli-all.jar ParseTestCaseToLlmContext \
32+
--project /path/to/your/java/project \
33+
--format json
34+
```
35+
36+
## 📋 Supported Tasks
37+
38+
### ParseTestCaseToLlmContext
39+
40+
Parses Java test cases and outputs structured JSON files for LLM code analysis.
41+
42+
**Output includes**:
43+
- 📝 Test case source code
44+
- 🔍 Method invocation sequence (DFS traversal)
45+
- 📦 Production code implementations
46+
- 🏷️ Statement classification (ASSERT, MOCK, NEW, third-party calls, etc.)
47+
- 📂 Imported packages list
48+
49+
**Example**:
50+
```bash
51+
java -jar Javalang-analyzing-cli-all.jar ParseTestCaseToLlmContext \
52+
--project /Users/john/projects/commons-cli \
53+
--threads 8 \
54+
--format json
55+
```
56+
57+
**Output file format**: `project_name:testclass_name:testcase_name.json`
58+
59+
## 📄 Output Example
60+
61+
```json
62+
{
63+
"project": "commons-cli",
64+
"testClassName": "org.apache.commons.cli.ArgumentIsOptionTest",
65+
"testCaseName": "testOption",
66+
"parsedStatementsSequence": [
67+
"org.apache.commons.cli.CommandLineParser.parse(Options, String[])",
68+
"ASSERT org.junit.jupiter.api.Assertions.assertTrue(boolean)",
69+
"GET org.apache.commons.cli.CommandLine.hasOption(String)"
70+
],
71+
"productionFunctionImplementations": [
72+
"public boolean hasOption(String opt) { ... }"
73+
],
74+
"testCaseSourceCode": "@Test\npublic void testOption() { ... }",
75+
"importedPackages": [
76+
"org.junit.jupiter.api.Test",
77+
"org.junit.jupiter.api.Assertions"
78+
]
79+
}
80+
```
81+
82+
## ⚙️ Command Line Options
83+
84+
| Option | Description | Default | Example |
85+
|--------|-------------|---------|---------|
86+
| `--project` | Project root directory (absolute path) | **Required** | `/home/user/my-project` |
87+
| `--threads` | Number of threads to use | `0` (auto-detect CPU cores) | `8` |
88+
| `--format` | Output format | `json` | `json`, `csv`, `md`, `console` |
89+
| `--lang` | Programming language | `java` | `java` |
90+
| `--output-file` | Output file path | Console output | `/tmp/results.json` |
91+
| `--config` | Configuration file path | None | `config.yml` |
92+
| `--plugin-path` | Plugin directory path | None | `/path/to/plugins` |
93+
94+
## 🏗️ Supported Build Systems
95+
96+
The tool automatically detects the project's build system and configures the appropriate classpath:
97+
98+
-**Maven**: Automatically parses `pom.xml` and dependencies
99+
-**Gradle**: Uses Gradle Tooling API to get project configuration
100+
- 🔄 **Automatic dependency resolution**: Searches `~/.m2` and `~/.gradle/caches` for missing test dependencies
101+
102+
### Automatically Handled Test Frameworks
103+
104+
- **JUnit 5** (Jupiter)
105+
- **JUnit 4**
106+
- **Mockito**
107+
- **Hamcrest**
108+
- **AssertJ**
109+
110+
## 🛠️ Advanced Usage
111+
112+
### Configuration File
113+
114+
Create an `analyzer.yml` configuration file:
115+
116+
```yaml
117+
project: /path/to/project
118+
threads: 8
119+
lang: java
120+
output:
121+
format: json
122+
file: results.json
123+
124+
# Task-specific configuration
125+
ParseTestCaseToLlmContext:
126+
outputDirectory: /custom/output/path
127+
includeDisabledTests: false
128+
```
129+
130+
Using configuration file:
131+
```bash
132+
java -jar Javalang-analyzing-cli-all.jar ParseTestCaseToLlmContext --config analyzer.yml
133+
```
134+
135+
### Multi-threaded Processing
136+
137+
```bash
138+
# Use 16 threads for parallel analysis
139+
java -jar Javalang-analyzing-cli-all.jar ParseTestCaseToLlmContext \
140+
--project /large/project \
141+
--threads 16
142+
```
143+
144+
### Plugin Extensions
145+
146+
The tool supports extension through Java SPI mechanism:
147+
148+
```bash
149+
# Use custom plugins
150+
java -jar Javalang-analyzing-cli-all.jar CustomTask \
151+
--plugin-path /path/to/plugins \
152+
--project /path/to/project
153+
```
154+
155+
## 🏷️ Statement Classification
156+
157+
The tool automatically identifies and classifies statements in test code:
158+
159+
| Classification | Description | Examples |
160+
|----------------|-------------|----------|
161+
| `ASSERT` | Assertion statements | `assertTrue()`, `assertEquals()` |
162+
| `MOCK` | Mock operations | `when()`, `verify()` |
163+
| `NEW` | Object creation | `new Object()` |
164+
| `THIRD` | Third-party library calls | External library method calls |
165+
| `GET/SET` | Property access | `getProperty()`, `setProperty()` |
166+
| `PRODUCTION` | Production code calls | Business logic methods being tested |
167+
168+
## 🐛 Troubleshooting
169+
170+
### Common Issues
171+
172+
**Q: "No suitable build tool found" error**
173+
```
174+
A: Ensure the project root contains pom.xml (Maven) or build.gradle (Gradle) files.
175+
```
176+
177+
**Q: Test dependencies cannot be resolved**
178+
```
179+
A: Ensure the project has been built (mvn compile or gradle build),
180+
the tool will automatically search local caches.
181+
```
182+
183+
**Q: Out of memory errors**
184+
```
185+
A: Increase JVM heap memory:
186+
java -Xmx4g -jar Javalang-analyzing-cli-all.jar ...
187+
```
188+
189+
**Q: Unicode escape characters in output**
190+
```
191+
A: This is normal - the tool is configured to output readable characters
192+
instead of Unicode escapes.
193+
```
194+
195+
### Debug Mode
196+
197+
The tool outputs detailed debug information including:
198+
- Detected build system
199+
- Parsed dependencies
200+
- Classpath configuration
201+
- List of processed files
202+
203+
This information helps diagnose issues.
204+
205+
## 🔧 Development
206+
207+
### Building the Project
208+
209+
```bash
210+
git clone https://github.com/your-username/Javalang-analyzing-cli.git
211+
cd Javalang-analyzing-cli
212+
./gradlew shadowJar
213+
```
214+
215+
The generated Fat JAR is located at: `build/libs/Javalang-analyzing-cli-*-all.jar`
216+
217+
### Adding New Tasks
218+
219+
1. Implement the `AnalyzerTask` interface
220+
2. Register in `META-INF/services/edu.stevens.swe.research.java.cli.analyzer.spi.AnalyzerTask`
221+
3. Rebuild and test
222+
223+
## 📄 License
224+
225+
This project is open source under the [Apache License 2.0](LICENSE).
226+
227+
## 🤝 Contributing
228+
229+
Issues and Pull Requests are welcome!
230+
231+
## 📞 Support
232+
233+
For issues, please report them in [GitHub Issues](https://github.com/your-username/Javalang-analyzing-cli/issues).

build.gradle

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
plugins {
22
id 'java'
3+
id 'application'
4+
id 'com.github.johnrengelman.shadow' version '8.1.1'
35
}
46

57
java {
@@ -10,15 +12,33 @@ java {
1012
}
1113
}
1214

15+
application {
16+
mainClass = 'edu.stevens.swe.research.java.cli.Main'
17+
}
18+
1319
group = 'edu.stevens'
14-
version = '1.0-SNAPSHOT'
20+
version = '1.0.0'
1521

1622
dependencies {
17-
implementation("com.github.Codegass:parser-core:main")
23+
// Use JitPack dependency for release builds
24+
implementation("com.github.Codegass:parser-core:main-SNAPSHOT")
25+
// implementation project(':parser-core') // For local development
26+
implementation 'info.picocli:picocli:4.7.0'
27+
implementation 'org.eclipse.jdt:org.eclipse.jdt.core:3.37.0'
28+
implementation 'com.google.code.gson:gson:2.11.0'
1829
testImplementation platform('org.junit:junit-bom:5.10.0')
1930
testImplementation 'org.junit.jupiter:junit-jupiter'
2031
}
2132

2233
test {
2334
useJUnitPlatform()
35+
}
36+
37+
shadowJar {
38+
archiveBaseName.set('Javalang-analyzing-cli')
39+
archiveClassifier.set('all')
40+
mergeServiceFiles()
41+
manifest {
42+
attributes 'Main-Class': 'edu.stevens.swe.research.java.cli.Main'
43+
}
2444
}

0 commit comments

Comments
 (0)