Java ignore rules
🙈 Select project type
It is recommended to put the temporary files of the editor and operating system into global ignore rules, and they can also be generated here.
💡 Instructions for use
- Just check the languages and frameworks used in the project, and repeated rules will be automatically deduplicated. It is recommended to also check the editors and operating systems used by team members.
- Keep annotation titles for future maintenance: when you look back a few months later, you'll still know why each set of rules was added.
- Directory rules ending with a slash only match directories; when you need to retain an ignored file, append an exception rule starting with an exclamation mark in the custom area.
- The rules only take effect on files that have not been included in management; if the target file is already tracked, it needs to be removed from the management list first.
The ignore list of Java projects mainly focuses on compilation output and build cache.
Compile output
The compilation result directory is regenerated from the source code and does not need to be submitted.
Packaged products and archive files are also products.
Build cache
The cache and incremental compilation directories of the build tools are growing rapidly.
The local repository cache is bound to the local environment and should not be committed.
Dependency statement
Dependency coordinates are written in the build description file and submitted with the warehouse.
Dependency packages downloaded locally do not enter version management.
Logs and temporary files
Run logs, dump files, and temporary directories should be ignored.
These files are often generated based on time and are easy to accumulate.
local configuration
Local environment configuration and personal development settings should not be shared.
Provide a configuration example and list the required fields.
Compilation output and build caches can be regenerated; dependencies are declared in build descriptors.
📖 Glossary
- Ignore rules
- A rule list that tells the version control tool which files do not need to be included in the management. It is usually placed in the project root directory and takes effect step by step.
- Rule matching
- Match one by one by path, supporting wildcards, exceptions starting with a slash at the end of the directory, and an exclamation mark; rules written later can overwrite rules written first.
- Exclamation mark exception
- Used to bring a file that has been ignored back into management, such as ignoring the entire directory but retaining one of the configuration files. The way to write it is to add an exclamation mark before the rule.
- directory trailing slash
- When the rule ends with a slash, only the directory will be matched. If it does not end with a slash, both files and directories with the same name will be matched. It is recommended to include a slash when writing dependent directories.
- Tracked files
- Files that have been included in version management will not automatically stop tracking due to new ignore rules. They need to be removed from the management list before submitting.
- global ignore
- Ignore rules that are saved on the local machine and are effective for all local repositories are suitable for temporary files of the editor and operating system, and do not need to be written into the project file.
- Dependency directory
- A directory automatically generated by a dependency management tool, such as the installation directory of a package manager. They are large and recreated from manifest files and are generally not managed.
- Build product
- The output directories and files generated by compilation or packaging can be regenerated from the source code and are usually ignored; exceptions will be made if they need to be released with the warehouse.
- environment variable file
- Files that store keys and local configuration must be ignored to avoid leakage; the team usually provides a separate sample file for reference.
- lock file
- Documentation relies on precise versions of files. Application projects usually need to be submitted to ensure a consistent environment, while library projects are subject to agreement.
- Editor directory
- The configuration directory automatically generated by the editor is a personal preference and is usually ignored; configurations shared by the team can be retained as an exception.
- Rule merging order
- Multiple rule files can be superimposed to take effect, and files within the project take precedence over global files; there are no side effects if the same rule appears repeatedly, and duplication is only for readability.
🔗 All keywords and tutorials
❓ FAQ
- Do I need to submit the compiled output?
- Don't. It can be regenerated from the source code and will only make the warehouse larger after submission.
- What to do with local dependency cache?
- Just ignore it, it is bound to the local machine path, and download it again after changing the machine.