Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intelligent current working directory resolution #88

Closed
purplefox opened this issue Sep 29, 2015 · 2 comments
Closed

Intelligent current working directory resolution #88

purplefox opened this issue Sep 29, 2015 · 2 comments
Milestone

Comments

@purplefox
Copy link
Contributor

The current examples, when running in the IDE using ExampleRunner assume that the IDE working directory is set up to be the root directory of the vertx-examples project.

This is the case when running in IntelliJ but behaviour can vary in other IDEs, e.g. in Eclipse and NetBeans which set the cwd to be the directory of the Maven sub-module (e.g. the core-examples directory). This can result in examples that use file system access failing for those IDEs when running in the IDE.

To remedy this we can do some "intelligent" cwd resolution in the ExampleRunner class. We can detect the cwd being used with new File(".") and based on the path of that and the desired working directory we can calculate the cwd offset to use. This should work if the actual cwd is set to anything below the project root.

@cescoffier cescoffier added this to the 3.1.0 milestone Sep 29, 2015
@cescoffier
Copy link
Member

I've made an initial implementation. Quite simple:

try {
      // We need to use the canonical file. Without the file name is .
      File current = new File(".").getCanonicalFile();
      if (exampleDir.startsWith(current.getName())  && !     exampleDir.equals(current.getName())) {
        exampleDir = exampleDir.substring(current.getName().length() + 1);
      }
    } catch (IOException e) {
      // Ignore it.
    }

I need to test it on windows, and in various IDEs

@cescoffier
Copy link
Member

We start discussing it on #89

cescoffier added a commit that referenced this issue Oct 1, 2015
Works on intellij, eclipse and netbeans
@cescoffier cescoffier removed the Planned label Oct 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants