You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.5 KiB
3.5 KiB
| name | description | version |
|---|---|---|
| analyze-dependencies | Analyze Java class dependencies, JAR requirements, and import relationships. Use when user needs to map dependencies, find missing libraries, or understand code relationships. | 1.0.0 |
Dependency Analysis
This skill analyzes Java project dependencies and relationships.
When to Use
- User needs to find required JAR files
- User wants to understand class relationships
- User needs to identify missing dependencies
- User wants to map import dependencies
Analysis Types
1. Import Analysis
Extract and analyze imports:
# Get all imports
find <dir> -name "*.java" -exec grep "^import" {} \; | \
sed 's/import //' | \
sed 's/;.*//' | \
sort -u
# Count imports per file
find <dir> -name "*.java" -exec sh -c 'echo "$(grep -c "^import" "$1") $1"' _ {} \; | \
sort -rn
2. External Dependency Detection
Identify required libraries:
# Find external imports (non-project)
find <dir> -name "*.java" -exec grep "^import" {} \; | \
sed 's/import //' | \
sed 's/;.*//' | \
grep -v "^com\.hst\." | \
sort -u
3. JAR Dependency Mapping
Map imports to JAR files:
| Import Pattern | Likely JAR |
|---|---|
org.springframework.* |
spring-*.jar |
org.apache.struts.* |
struts2-core.jar |
com.ibatis.* |
ibatis-sqlmap.jar |
org.apache.axis.* |
axis.jar |
javax.servlet.* |
servlet-api.jar |
org.apache.log4j.* |
log4j.jar |
java.sql.* |
JDK (built-in) |
4. Class Relationship Analysis
Find related classes:
# Find classes that extend/implement
grep -r "extends\|implements" <dir> | \
sed 's/:.*extends/: extends/' | \
sed 's/:.*implements/: implements/'
# Find interface implementations
grep -r "implements" <dir> | \
sed 's/.*implements //' | \
sed 's/{.*//' | \
sort -u
Dependency Report
Generate comprehensive report:
bash C:/Users/K/.claude/plugins/cache/claude-plugins-official/plugin-dev/9eae436aa296/scripts/analyze-deps.sh <classes_dir>
Resolving Dependencies
Step 1: Identify Missing JARs
# List required external packages
find <dir> -name "*.java" -exec grep "^import" {} \; | \
sed 's/import //' | \
sed 's/;.*//' | \
cut -d. -f1-3 | \
sort -u
Step 2: Find JAR Sources
Common sources:
- Maven Central: https://search.maven.org/
- MVN Repository: https://mvnrepository.com/
- Project lib/ directory
Step 3: Add to Build
For Maven, add to pom.xml:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.18.RELEASE</version>
</dependency>
Step 4: Verify Dependencies
# Check if JARs are available
mvn dependency:tree
# Download dependencies
mvn dependency:resolve
Common Dependency Groups
Spring Framework
spring-context
spring-web
spring-jdbc
spring-beans
spring-core
Struts 2
struts2-core
struts2-spring-plugin
xwork-core
ognl
freemarker
Database
ojdbc14 (Oracle)
mysql-connector-java (MySQL)
postgresql (PostgreSQL)
commons-dbcp (Connection pooling)
Web Services
axis
jaxrpc-api
wsdl4j
commons-discovery
Dependency Graph
Visualize dependencies:
[Action Layer]
↓
[Service Layer]
↓
[DAO Layer]
↓
[Domain Layer]
↓
[External Libraries]
Integration
After dependency analysis:
- Update pom.xml with missing dependencies
- Run
mvn dependency:resolveto download - Run
mvn compileto verify - Fix any remaining dependency issues