diff options
Diffstat (limited to 'jps/standalone-builder/src/org/jetbrains/jps/idea/IdeaProjectLoader.java')
-rw-r--r-- | jps/standalone-builder/src/org/jetbrains/jps/idea/IdeaProjectLoader.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/jps/standalone-builder/src/org/jetbrains/jps/idea/IdeaProjectLoader.java b/jps/standalone-builder/src/org/jetbrains/jps/idea/IdeaProjectLoader.java new file mode 100644 index 000000000000..b392dcf15081 --- /dev/null +++ b/jps/standalone-builder/src/org/jetbrains/jps/idea/IdeaProjectLoader.java @@ -0,0 +1,30 @@ +package org.jetbrains.jps.idea; + +import groovy.lang.Script; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * @author max + */ +public class IdeaProjectLoader { + 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, ".idea").exists()) { + return home.getCanonicalPath(); + } + + + home = home.getParentFile(); + } + + + throw new IllegalArgumentException("Cannot guess project home from '" + uri + "'"); + } +} |