Search code examples
gradlemercurialhgignore

Mercurial refuses to not ignore Gradle wrapper artifacts


My .hgignore file looks like this:

syntax: glob

# mercurial files
*.orig
*.rej

# build target and dependency directories
*/target/**
*/target-eclipse/**
.gradle/**
.gradle
*.war
*/wrapper/**
!gradle/wrapper/gradle-wrapper.jar
!gradle/wrapper/gradle-wrapper.properties
*/out/**
*/build/**

# IDE files
.idea/**
.settings/**
*.iml
*.ipr
*.iws
*.classpath
*.project

# LazyBones
.lazybones/**

# DropWizard
config.yml
config.json

# JMeter Results
*/jmeter/results/*

Pay attention to my attempt to exclude gradle/wrapper/* from this ignore file:

!gradle/wrapper/gradle-wrapper.jar
!gradle/wrapper/gradle-wrapper.properties

When I run gradle wrapper on my project it generates typical Gradle wrapper files. However when I hg add I don't see those files (gradle-wrapper.jar and gradle-wrapper.properties) added to hg tracking, and when I push my project (hg push) I don't see them showing up on the remote repo.

Have I misconfigured .hgignore somehow? is hg still actually ignoring my Gradle wrapper artifacts?


Solution

  • For two specific files, you should just add them manually:

    hg add gradle/wrapper/gradle-wrapper.jar gradle/wrapper/gradle-wrapper.properties
    hg commit
    

    This will work even if they are ignored, and changes will be picked up by subsequent commits automatically.