raydac / java-comment-preprocessor

preprocessor for computer languages with C-like comment format (C/C++/Java/Go)
Apache License 2.0
172 stars 27 forks source link

add exclude-git command line directive #16

Closed jamuir closed 7 years ago

jamuir commented 7 years ago

Use /EG to tell JCP to exclude the contents of ".git" directories from the files it processes.

This is useful for speeding up JCP (because fewer files are scanned), and, more importantly, it keeps JCP from crashing when processing git projects inside an android development tree.

Here is an example crash:

$ jcp /C /I:android-7.x/frameworks/opt/telephony /O:~/tmp/jcp/frameworks/opt/telephony
Java Comment Preprocessor v6.0.0
Project page: http://java-comment-preprocessor.googlecode.com/
2003-2014 Author: Igor A. Maznitsa (igor.maznitsa@igormaznitsa.com)
android-7.x/frameworks/opt/telephony/.git/shallow (No such file or directory)
java.io.FileNotFoundException: android-7.x/frameworks/opt/telephony/.git/shallow (No such file or directory)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(FileInputStream.java:195)
        at java.io.FileInputStream.<init>(FileInputStream.java:138)
        at com.igormaznitsa.jcp.utils.PreprocessorUtils.copyFile(PreprocessorUtils.java:147)
        at com.igormaznitsa.jcp.JCPreprocessor.preprocessFiles(JCPreprocessor.java:168)
        at com.igormaznitsa.jcp.JCPreprocessor.execute(JCPreprocessor.java:100)
        at com.igormaznitsa.jcp.JCPreprocessor.main(JCPreprocessor.java:265)

To be fair, the crash isn't JCP's fault. It happens because of the way the repo tool populates the android dev tree with git projects (.git/shallow is a broken sym-link). /EG is just a way of accommodating repo's behaviour.

jamuir commented 7 years ago

@raydac I'm not certain if this PR will be of interested to you, but we make use of it at Graphite.

The /EG option could instead be generalized to accept a list of a directories that the user wants to exclude. If that would be preferred, then let me know and I could give it a try.

By the way, thank-you for creating JCP! We use it to enable/disable certain features when preparing patch sets for customers. It is really useful to us. Cheers! :-)

raydac commented 7 years ago

just to disable .git is a too corner case, but it is a good point to exclude some sub-folders of source folder during preprocessing, I have added /ED: CLI option, so that now it is possible to disable through /ED:.git or /ED:**/.git

jamuir commented 7 years ago

awesome. thanks for adding "/ED"!