当前位置: 首页>>代码示例>>Java>>正文


Java CompileTask类代码示例

本文整理汇总了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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ExternalSystemTaskActivator.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AndroidRegenerateSourcesAction.java

示例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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GradleCompilingTestCase.java

示例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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GradleStartupActivity.java

示例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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MavenTasksManager.java

示例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;
}
 
开发者ID:guikeller,项目名称:jetty-runner,代码行数:30,代码来源:JettyRunnerEditor.java

示例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;
}
 
开发者ID:vitorzachi,项目名称:tomcat-runner,代码行数:34,代码来源:TomcatRunnerEditor.java

示例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;
        }
      });
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:MavenProjectsManager.java

示例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;
        }
      });
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:MavenProjectsManager.java

示例10: getTaskInstance

import com.intellij.openapi.compiler.CompileTask; //导入依赖的package包/类
public CompileTask getTaskInstance() {
  return myInstanceHolder.getValue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:CompileTaskBean.java

示例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);
}
 
开发者ID:robovm,项目名称:robovm-idea,代码行数:48,代码来源:RoboVmPlugin.java


注:本文中的com.intellij.openapi.compiler.CompileTask类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。