本文整理汇总了Java中com.intellij.openapi.roots.CompilerProjectExtension.getCompilerOutputUrl方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerProjectExtension.getCompilerOutputUrl方法的具体用法?Java CompilerProjectExtension.getCompilerOutputUrl怎么用?Java CompilerProjectExtension.getCompilerOutputUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.CompilerProjectExtension
的用法示例。
在下文中一共展示了CompilerProjectExtension.getCompilerOutputUrl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
public static Class compile(@NotNull PsiClass psiClass) {
Class cls = null;
String compileText = psiClass.getText();
String compileName = psiClass.getName();
CompilerProjectExtension extension = CompilerProjectExtension.getInstance(psiClass.getProject());
String outputRootUrl = extension.getCompilerOutputUrl();
File root = new File(outputRootUrl + "/tmp");
File sourceFile = new File(root, compileName + ".java");
sourceFile.getParentFile().mkdirs();
try {
new FileWriter(sourceFile).append(compileText).close();
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
compiler.run(null, null, null, sourceFile.getPath());
URLClassLoader classLoader = URLClassLoader.newInstance(new URL[]{root.toURI().toURL()});
cls = Class.forName(compileName, true, classLoader);
sourceFile.delete();
} catch (Exception e) {
e.printStackTrace();
}
return cls;
}
示例2: getDefaultArtifactOutputPath
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
@Nullable
public static String getDefaultArtifactOutputPath(@NotNull String artifactName, final @NotNull Project project) {
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(project);
if (extension == null) return null;
String outputUrl = extension.getCompilerOutputUrl();
if (outputUrl == null || outputUrl.length() == 0) {
final VirtualFile baseDir = project.getBaseDir();
if (baseDir == null) return null;
outputUrl = baseDir.getUrl() + "/out";
}
return VfsUtilCore.urlToPath(outputUrl) + "/artifacts/" + FileUtil.sanitizeFileName(artifactName);
}
示例3: getDefaultArtifactOutputPath
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
@Nullable
public static String getDefaultArtifactOutputPath(@NotNull String artifactName, final @NotNull Project project) {
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(project);
if (extension == null) return null;
String outputUrl = extension.getCompilerOutputUrl();
if (outputUrl == null || outputUrl.length() == 0) {
final VirtualFile baseDir = project.getBaseDir();
if (baseDir == null) return null;
outputUrl = baseDir.getUrl() + "/out";
}
return VfsUtil.urlToPath(outputUrl) + "/artifacts/" + FileUtil.sanitizeFileName(artifactName);
}
示例4: getOriginalCompilerOutputUrl
import com.intellij.openapi.roots.CompilerProjectExtension; //导入方法依赖的package包/类
@Nullable
private String getOriginalCompilerOutputUrl() {
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(myProject);
return extension != null ? extension.getCompilerOutputUrl() : null;
}