maven-gradle-guide
Skill4 starsChanged 9 months agoMITView on GitHub
Maven and Gradle build tool patterns including pom.xml structure, build.gradle.kts configuration, multi-module projects, dependency management, plugins, and BOMs. Use when the user is setting up Java/Kotlin build configurations, managing dependencies, creating multi-module projects, or troubleshooting build issues. Trigger on any mention of Maven, Gradle, pom.xml, build.gradle, dependency management, or Java build tools.
In this repository78 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/agents.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/claude-initial-setup.mdcCursor rule
- parallel-task-executionSkill
- subagent-patternsSkill
- task-coordinationSkill
- agent-communicationSkill
- context-managementSkill
- multi-agent-orchestrationSkill
- deploy-strategiesSkill
- github-actions-guideSkill
- pipeline-patternsSkill
- anthropic-sdk-guideSkill
- prompt-engineeringSkill
- tool-use-patternsSkill
- automated-review-setupSkill
- pr-standardsSkill
- review-checklistSkill
- file-organizationSkill
- immutability-patternsSkill
- naming-conventionsSkill
- branching-strategySkill
- commit-conventionsSkill
- pr-workflowSkill
- migration-patternsSkill
- query-optimizationSkill
- schema-design-guideSkill
- error-tracingSkill
- log-analysisSkill
- systematic-debuggingSkill
- django-admin-customizationSkill
- django-orm-masterySkill
- drf-api-patternsSkill
- docker-compose-guideSkill
- dockerfile-best-practicesSkill
- multi-stage-buildsSkill
- express-error-handlingSkill
- middleware-patternsSkill
- rest-api-nodeSkill
- async-fastapiSkill
- dependency-injection-fastapiSkill
- pydantic-validationSkill
- concurrency-patterns-goSkill
- error-handling-goSkill
- idiomatic-goSkill
- automation-triggersSkill
- hook-recipesSkill
- pre-post-hooksSkill
- junit-testingSkill
- spring-boot-patternsSkill
- mcp-resource-patternsSkill
- mcp-server-creationSkill
- mcp-tool-designSkill
- context-optimizationSkill
- knowledge-persistenceSkill
- memory-patternsSkill
- caching-strategiesSkill
- lazy-loading-patternsSkill
- profiling-guideSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 183
Use BOMs to align versions across a family of libraries.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Maven and Gradle Guide
Build tool configuration patterns for Java and Kotlin projects.
When to Use
- User is setting up a new Maven or Gradle project
- User needs to manage dependencies or resolve conflicts
- User is creating a multi-module project
- User asks about BOMs, plugins, or build lifecycle
- User is migrating between Maven and Gradle
Core Patterns
Maven pom.xml Structure
A well-organized POM with property management, dependency management, and plugin configuration.
<?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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
</parent>
<groupId>com.example</groupId>
<artifactId>my-service</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<java.version>21</java.version>
<testcontainers.version>1.19.3</testcontainers.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>Gradle Kotlin DSL (build.gradle.kts)
The equivalent Gradle configuration using the Kotlin DSL for type-safe build scripts.
plugins {
java
id("org.springframework.boot") version "3.2.0"
id("io.spring.dependency-management") version "1.1.4"
}
group = "com.example"
version = "1.0.0-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.testcontainers:postgresql:1.19.3")
}
tasks.test {
useJUnitPlatform()
}Multi-Module Project (Maven)
Parent POM manages shared configuration; child modules inherit.
<!-- parent pom.xml -->
<project>
<groupId>com.example</groupId>
<artifactId>my-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>common</module>
<module>api</module>
<module>service</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
<!-- service/pom.xml -- inherits parent, version from dependencyManagement -->
<project>
<parent>
<groupId>com.example</groupId>
<artifactId>my-platform</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>service</artifactId>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>common</artifactId>
</dependency>
</dependencies>
</project>Multi-Module Project (Gradle)
// settings.gradle.kts
rootProject.name = "my-platform"
include("common", "api", "service")
// build.gradle.kts (root)
subprojects {
apply(plugin = "java")
group = "com.example"
version = "1.0.0-SNAPSHOT"
repositories { mavenCentral() }
java { sourceCompatibility = JavaVersion.VERSION_21 }
tasks.test { useJUnitPlatform() }
}
// service/build.gradle.kts
dependencies {
implementation(project(":common"))
implementation("org.springframework.boot:spring-boot-starter-web")
}BOM (Bill of Materials)
Use BOMs to align versions across a family of libraries. Prevents version conflicts.
<!-- Maven: import BOM in dependencyManagement -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.19.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- Now use without version -->
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
</dependencies>// Gradle: import BOM via platform()
dependencies {
implementation(platform("org.testcontainers:testcontainers-bom:1.19.3"))
testImplementation("org.testcontainers:postgresql") // no version needed
}Anti-Patterns
- Specifying versions in child modules -- Manage all versions in the parent POM's
<dependencyManagement>or via BOMs. Child modules should omit version tags. - Using the Groovy DSL for new Gradle projects -- The Kotlin DSL (
build.gradle.kts) provides type safety, auto-completion, and compile-time checks. Prefer it for new projects. - Fat JARs without Spring Boot plugin -- Using the
maven-shade-pluginwhen Spring Boot's plugin handles fat JAR packaging correctly. Use the right tool. - Dependency version conflicts -- Not using BOMs and having transitive dependency conflicts. Run
mvn dependency:treeorgradle dependenciesto diagnose. - Putting test dependencies in compile scope -- Always use
<scope>test</scope>in Maven ortestImplementationin Gradle for test-only libraries.
Quick Reference
Maven lifecycle:
mvn clean compile -- Compile sources
mvn test -- Run tests
mvn package -- Build JAR/WAR
mvn install -- Install to local repo
mvn dependency:tree -- Show dependency tree
Gradle tasks:
gradle build -- Compile + test + package
gradle test -- Run tests
gradle dependencies -- Show dependency tree
gradle bootRun -- Run Spring Boot app
Dependency scopes:
Maven Gradle
compile -> implementation
provided -> compileOnly
runtime -> runtimeOnly
test -> testImplementationDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

