本文整理汇总了Java中com.intellij.openapi.compiler.CompileTask类的典型用法代码示例。如果您正苦于以下问题:Java CompileTask类的具体用法?Java CompileTask怎么用?Java CompileTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompileTask类属于com.intellij.openapi.compiler包,在下文中一共展示了CompileTask类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
public void init() {
CompilerManager compilerManager = CompilerManager.getInstance(myProject);
class MyCompileTask implements CompileTask {
private final boolean myBefore;
MyCompileTask(boolean before) {
myBefore = before;
}
@Override
public boolean execute(CompileContext context) {
return doExecuteCompileTasks(myBefore, context);
}
}
compilerManager.addBeforeTask(new MyCompileTask(true));
compilerManager.addAfterTask(new MyCompileTask(false));
fireTasksChanged();
}
示例2: generate
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
private static void generate(Project project, final Module... modules) {
CompilerManager.getInstance(project).executeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
// todo: compatibility with background autogenerating
for (Module module : modules) {
final AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
for (AndroidAutogeneratorMode mode : AndroidAutogeneratorMode.values()) {
AndroidCompileUtil.generate(facet, mode, context, true);
}
}
}
return true;
}
}, new ModuleCompileScope(project, modules, false), AndroidBundle.message("android.compile.messages.generating.r.java.content.name"),
null);
}
示例3: setUpInWriteAction
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
@Override
protected void setUpInWriteAction() throws Exception {
super.setUpInWriteAction();
final GradleResourceCompilerConfigurationGenerator buildConfigurationGenerator = new GradleResourceCompilerConfigurationGenerator(myProject);
CompilerManager.getInstance(myProject).addBeforeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
AccessToken token = ReadAction.start();
try {
buildConfigurationGenerator.generateBuildConfiguration(context);
}
finally {
token.finish();
}
return true;
}
});
}
示例4: runActivity
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
@Override
public void runActivity(@NotNull final Project project) {
configureBuildClasspath(project);
showNotificationForUnlinkedGradleProject(project);
final GradleResourceCompilerConfigurationGenerator buildConfigurationGenerator = new GradleResourceCompilerConfigurationGenerator(project);
CompilerManager.getInstance(project).addBeforeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
AccessToken token = ReadAction.start();
try {
buildConfigurationGenerator.generateBuildConfiguration(context);
}
finally {
token.finish();
}
return true;
}
});
}
示例5: initComponent
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
@Override
public void initComponent() {
if (!isNormalProject()) return;
if (isInitialized.getAndSet(true)) return;
CompilerManager compilerManager = CompilerManager.getInstance(myProject);
class MyCompileTask implements CompileTask {
private final boolean myBefore;
MyCompileTask(boolean before) {
myBefore = before;
}
@Override
public boolean execute(CompileContext context) {
return doExecute(myBefore, context);
}
}
compilerManager.addBeforeTask(new MyCompileTask(true));
compilerManager.addAfterTask(new MyCompileTask(false));
}
示例6: getMainOutputDirectory
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
/**
* Retrieves the output directory for the main module
* @param project Project
* @return String value
*/
private String getMainOutputDirectory(final Project project) {
// Preparing things up for a sneaky "CompileTask"
final CompilerManager compilerManager = CompilerManager.getInstance(project);
final Module[] modules = ModuleManager.getInstance(project).getModules();
final ModuleCompileScope compileScope = new ModuleCompileScope(project, modules, false);
final Module mainModule = modules[0];
// Though a "CompileTask" I can get hold of the "CompileContext"
CompileTask compileTask = compileContext -> {
// Through the "CompileContext" I can get the output directory of the main module
VirtualFile mainOutputDirectory = compileContext.getModuleOutputDirectory(mainModule);
if(mainOutputDirectory != null) {
JettyRunnerEditor.this.mainOutputDirectory = mainOutputDirectory.getPresentableUrl();
} else {
// Project hasn't been compiled yet, so there is no output directory
NotificationGroup notificationGroup = new NotificationGroup("IDEA Jetty Runner", NotificationDisplayType.BALLOON, true);
Notification notification = notificationGroup.createNotification("Jetty Runner - Couldn't determine the classes folder:<br>Please compile / make your project before creating the conf.", NotificationType.ERROR);
Notifications.Bus.notify(notification, project);
}
return true;
};
// Executes the task (synchronously), which invokes that internal 'execute' method
compilerManager.executeTask(compileTask, compileScope, "JettyRunner-By-GuiKeller", null);
return this.mainOutputDirectory;
}
示例7: getMainOutputDirectory
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
/**
* Retrieves the output directory for the main module
*
* @param project Project
* @return String value
*/
private String getMainOutputDirectory(final Project project) {
// Preparing things up for a sneaky "CompileTask"
final CompilerManager compilerManager = CompilerManager.getInstance(project);
final Module[] modules = ModuleManager.getInstance(project).getModules();
final ModuleCompileScope compileScope = new ModuleCompileScope(project, modules, false);
final Module mainModule = modules[0];
// Though a "CompileTask" I can get hold of the "CompileContext"
CompileTask compileTask = new CompileTask() {
public boolean execute(CompileContext compileContext) {
// Through the "CompileContext" I can get the output directory of the main module
VirtualFile mainOutputDirectory = compileContext.getModuleOutputDirectory(mainModule);
if (mainOutputDirectory != null) {
String mainOutputDirectoryValue = mainOutputDirectory.getPresentableUrl();
TomcatRunnerEditor.this.mainOutputDirectory = mainOutputDirectoryValue;
} else {
// Project hasn't been compiled yet, so there is no output directory
NotificationGroup notificationGroup = new NotificationGroup("IDEA Tomcat Runner", NotificationDisplayType.BALLOON, true);
Notification notification = notificationGroup.createNotification("Tomcat Runner - Couldn't determine the classes folder:<br>Please compile / make your project before creating the conf.", NotificationType.ERROR);
Notifications.Bus.notify(notification, project);
}
return true;
}
};
// Executes the task (synchronously), which invokes that internal 'execute' method
compilerManager.executeTask(compileTask, compileScope, TomcatRunnerConfigurationType.RUNNER_ID, null);
return this.mainOutputDirectory;
}
示例8: initComponent
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
@Override
public void initComponent() {
if (!isNormalProject()) return;
StartupManagerEx startupManager = StartupManagerEx.getInstanceEx(myProject);
startupManager.registerStartupActivity(new Runnable() {
public void run() {
boolean wasMavenized = !myState.originalFiles.isEmpty();
if (!wasMavenized) return;
initMavenized();
}
});
startupManager.registerPostStartupActivity(new Runnable() {
@Override
public void run() {
if (!isMavenizedProject()) {
showNotificationOrphanMavenProject(myProject);
}
CompilerManager.getInstance(myProject).addBeforeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
AccessToken token = ReadAction.start();
try {
new MavenResourceCompilerConfigurationGenerator(myProject, myProjectsTree).generateBuildConfiguration(context.isRebuild());
}
finally {
token.finish();
}
return true;
}
});
}
});
}
示例9: initComponent
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
@Override
public void initComponent() {
if (!isNormalProject()) return;
StartupManagerEx startupManager = StartupManagerEx.getInstanceEx(myProject);
startupManager.registerStartupActivity(new Runnable() {
public void run() {
boolean wasMavenized = !myState.originalFiles.isEmpty();
if (!wasMavenized) return;
initMavenized();
}
});
startupManager.registerPostStartupActivity(new Runnable() {
@Override
public void run() {
CompilerManager.getInstance(myProject).addBeforeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
AccessToken token = ReadAction.start();
try {
if (!CompilerWorkspaceConfiguration.getInstance(myProject).useOutOfProcessBuild()) return true;
new MavenResourceCompilerConfigurationGenerator(myProject, myProjectsTree).generateBuildConfiguration(context.isRebuild());
}
finally {
token.finish();
}
return true;
}
});
}
});
}
示例10: getTaskInstance
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
public CompileTask getTaskInstance() {
return myInstanceHolder.getValue();
}
示例11: initializeProject
import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
public static void initializeProject(final Project project) {
// setup a compile task if there isn't one yet
boolean found = false;
for (CompileTask task : CompilerManager.getInstance(project).getAfterTasks()) {
if (task instanceof RoboVmCompileTask) {
found = true;
break;
}
}
if (!found) {
CompilerManager.getInstance(project).addAfterTask(new RoboVmCompileTask());
}
// hook ito the message bus so we get to know if a storyboard/xib
// file is opened
project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new RoboVmFileEditorManagerListener(project));
// initialize our tool window to which we
// log all messages
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (project.isDisposed()) {
return;
}
ToolWindow toolWindow = ToolWindowManager.getInstance(project).registerToolWindow(ROBOVM_TOOLWINDOW_ID, false, ToolWindowAnchor.BOTTOM, project, true);
ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
Content content = toolWindow.getContentManager().getFactory().createContent(consoleView.getComponent(), "Console", true);
toolWindow.getContentManager().addContent(content);
toolWindow.setIcon(RoboVmIcons.ROBOVM_SMALL);
consoleViews.put(project, consoleView);
toolWindows.put(project, toolWindow);
logInfo(project, "RoboVM plugin initialized");
}
});
// initialize virtual file change listener so we can
// trigger recompiles on file saves
VirtualFileListener listener = new VirtualFileAdapter() {
@Override
public void contentsChanged(@NotNull VirtualFileEvent event) {
compileIfChanged(event, project);
}
};
VirtualFileManager.getInstance().addVirtualFileListener(listener);
fileListeners.put(project, listener);
}