Files
openide/jps/standalone-builder/src/org/jetbrains/jps/idea/IdeaProjectLoader.java
nik e06b425787 [build scripts] restore IdeaProjectLoader class which are still used in *.gant scripts
...via jps-build-script-dependencies-bootstrap library. It was deleted in d63b2fa6bb by mistake.

GitOrigin-RevId: 50beb93ddf812f60f363560318c3e7e3e2f4ef3a
2020-02-10 11:03:00 +00:00

37 lines
1.1 KiB
Java

// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.jps.idea;
import groovy.lang.Script;
import org.jetbrains.jps.model.serialization.PathMacroUtil;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
/**
* @author max
*/
public class IdeaProjectLoader {
/**
* This method is still used in some *.gant scripts via jps-build-script-dependencies-bootstrap library
*/
@SuppressWarnings("unused")
public static String guessHome(Script script) throws IOException, URISyntaxException {
String uri = (String)script.getProperty("gant.file");
File home = new File(new URI(uri).getSchemeSpecificPart());
while (home != null) {
if (home.isDirectory() && new File(home, PathMacroUtil.DIRECTORY_STORE_NAME).exists()) {
return home.getCanonicalPath();
}
home = home.getParentFile();
}
throw new IllegalArgumentException("Cannot guess project home from '" + uri + "'");
}
}