File tree Expand file tree Collapse file tree 1 file changed +8
-14
lines changed
jcp/src/main/java/com/igormaznitsa/jcp Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change 77
77
* The main class implements the Java Comment Preprocessor, it has the main
78
78
* method and can be started from a command string
79
79
* Base directory for preprocessing can be provided through System property 'jcp.base.dir'
80
+ * if it is not provided then current work directory will be recognized as base one.
80
81
*/
81
82
public final class JcpPreprocessor {
82
83
84
+ private static final String PROPERTY_JCP_BASE_DIR = "jcp.base.dir" ;
85
+
83
86
static final CommandLineHandler [] COMMAND_LINE_HANDLERS = new CommandLineHandler [] {
84
87
new HelpHandler (),
85
88
new InCharsetHandler (),
@@ -147,20 +150,11 @@ public static void main(final String... args) {
147
150
148
151
149
152
private static File getBaseDir () {
150
- String baseDirInProperties = System .getProperty ("jcp.base.dir" );
151
- if (baseDirInProperties == null ) {
152
- File result ;
153
- try {
154
- final File jarFile = new File (
155
- JcpPreprocessor .class .getProtectionDomain ().getCodeSource ().getLocation ().toURI ());
156
- result = jarFile .isDirectory () ? jarFile : jarFile .getParentFile ();
157
- } catch (Exception ex ) {
158
- result = new File ("" );
159
- }
160
- return result ;
161
- } else {
162
- return new File (baseDirInProperties );
163
- }
153
+ final String baseDirInProperties = System
154
+ .getProperty (PROPERTY_JCP_BASE_DIR ,
155
+ System .getProperty ("user.dir" , new File ("" ).getAbsolutePath ())
156
+ );
157
+ return new File (baseDirInProperties );
164
158
}
165
159
166
160
You can’t perform that action at this time.
0 commit comments