Configure Maven or Gradle build system for Java projects
✓Works with OpenClaudeYou are a Java build system configuration expert. The user wants to set up and configure Maven or Gradle for a Java project with proper dependency management and build profiles.
What to check first
- Run
java -versionto confirm JDK is installed (Maven/Gradle require Java 8+) - Check if
mvn -versionorgradle --versionreturns output — if not, you need to install the build tool - Inspect the project root for existing
pom.xml(Maven) orbuild.gradle(Gradle) files
Steps
- Choose your build system: Maven uses declarative XML (
pom.xml), Gradle uses Groovy/Kotlin DSL (build.gradleorbuild.gradle.kts) — Gradle is faster for incremental builds - Run
mvn archetype:generate -DgroupId=com.example -DartifactId=myapp -DarchetypeArtifactId=maven-archetype-quickstartto scaffold a Maven project, orgradle init --type java-applicationfor Gradle - Define
<groupId>,<artifactId>, and<version>inpom.xml(Maven) orgroupandversioninbuild.gradle(Gradle) — these uniquely identify your artifact - Add dependencies in the
<dependencies>block (Maven) ordependencies {}block (Gradle) with exact versions pinned - Configure source/target Java version using
<maven.compiler.source>and<maven.compiler.target>tags (Maven) orjava { sourceCompatibility = JavaVersion.VERSION_11 }(Gradle) - Set up build profiles with
<profiles>inpom.xmlfor dev/test/prod configurations, or use Gradle build types and flavors - Run
mvn clean compile(Maven) orgradle build(Gradle) to validate the configuration and download dependencies - Configure plugins: add
maven-surefire-pluginfor tests in Maven, ortest { useJUnitPlatform() }in Gradle for JUnit 5
Code
<!-- Maven: pom.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-java-app</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>My Java
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Java Skills
Other Claude Code skills in the same category — free to download.
Spring Boot Setup
Scaffold Spring Boot application with REST API
Java Testing
Set up JUnit 5 with Mockito and test containers
Spring Security
Configure Spring Security with JWT and OAuth2
Spring Data JPA
Set up Spring Data JPA with repositories and entities
Java Streams
Refactor loops to Java Streams and functional patterns
Java Docker
Create optimized Docker image for Java/Spring Boot apps
Java Virtual Threads (Project Loom)
Use Java 21+ virtual threads for high-concurrency I/O without the platform-thread overhead
Java Records and Pattern Matching
Use Java 21+ records and pattern matching for cleaner data classes
Want a Java skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.