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 7777 * The main class implements the Java Comment Preprocessor, it has the main
7878 * method and can be started from a command string
7979 * 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.
8081 */
8182public final class JcpPreprocessor {
8283
84+ private static final String PROPERTY_JCP_BASE_DIR = "jcp.base.dir" ;
85+
8386 static final CommandLineHandler [] COMMAND_LINE_HANDLERS = new CommandLineHandler [] {
8487 new HelpHandler (),
8588 new InCharsetHandler (),
@@ -147,20 +150,11 @@ public static void main(final String... args) {
147150
148151
149152 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 );
164158 }
165159
166160
You can’t perform that action at this time.
0 commit comments