.gitignore for Gradle + Java + JetBrains
.gitignore for Java projects built with Gradle and developed in IntelliJ IDEA.
Quick presets
31 patterns · 587 B
# Generated by DevZone Tools — https://devzone.tools/tools/gitignore-generator # Templates: JetBrains, Java, Gradle # 2026-05-28 # ---- JetBrains ---- # JetBrains IDEs .idea/ *.iws *.iml *.ipr out/ !**/src/main/**/out/ !**/src/test/**/out/ .idea/caches/ .idea/libraries/ .idea/modules/ .idea/modules.xml .idea/workspace.xml # ---- Java ---- # Java *.class *.log *.ctxt .mtj.tmp/ *.jar *.war *.nar *.ear *.zip *.tar.gz *.rar hs_err_pid* replay_pid* # ---- Gradle ---- # Gradle .gradle/ **/build/ !src/**/build/ !gradle/wrapper/gradle-wrapper.jar local.properties *.gradle.kts.~lock~
Why use Gradle + Java + JetBrains together?
The most common modern Java setup: Gradle as the build tool, IntelliJ IDEA as the IDE. This combination layers three templates so nothing slips through.
Gradle contributes .gradle/ caches and build/ output. The Gradle wrapper (gradlew, gradlew.bat, and gradle/wrapper/gradle-wrapper.jar) should always be committed — it ensures every contributor and CI runner uses the same Gradle version without a system install.
The Java template covers compiled .class files plus packaged JAR/WAR/EAR archives. JetBrains adds .idea/ workspace state, *.iml module files, and the out/ build directory IntelliJ creates for non-Gradle runs. Together you get clean, deterministic Gradle/Java repos with no IDE noise.
Related combinations
Frequently asked questions
- Do I need to commit .gitignore?
- Yes — .gitignore should be committed to the repository so all collaborators benefit from the same ignore rules.
- How do I add custom patterns?
- Open your .gitignore file and add the pattern on a new line. Use # for comments, * for wildcards, / to match directories, and ! to un-ignore a previously ignored path.
- How do I ignore a file that is already tracked?
- Adding a file to .gitignore does not remove it from tracking if it was previously committed. Run: git rm --cached <file> to stop tracking it without deleting the file locally.
- Why combine Gradle and Java and JetBrains?
- The most common modern Java setup: Gradle as the build tool, IntelliJ IDEA as the IDE. This combination layers three templates so nothing slips through.
Looking for something else? Browse all templates →