private static String getRootPath()

in rake-runner-agent/src/jetbrains/buildServer/agent/rakerunner/utils/RubyProjectSourcesUtil.java [30:56]


  private static String getRootPath() throws RunBuildException {
    final String jarPath = PathUtil.getJarPathForClass(RubyProjectSourcesUtil.class);

    final File rubySourcesDir;
    if (jarPath != null && jarPath.endsWith(".jar")) {
      File jarFile = new File(jarPath);
      rubySourcesDir = new File(jarFile.getParentFile(), RUBY_SOURCES_SUBDIR);
    } else {
      // Used in tests
      File test = new File("lib/rb");
      if (!test.exists()) {
        test = new File("external-repos/rake-runner/lib/rb");
      }
      rubySourcesDir = test;
    }

    try {
      if (rubySourcesDir.exists() && rubySourcesDir.isDirectory()) {
        return rubySourcesDir.getCanonicalPath();
      }
      throw new RunBuildException("Unable to find bundled ruby scripts folder("
                                  + rubySourcesDir.getCanonicalPath()
                                  + " [original path: " + rubySourcesDir.getPath() + "]). Plugin is damaged.");
    } catch (Exception e) {
      throw new RunBuildException(e.getMessage(), e);
    }
  }