use of com.intellij.openapi.compiler.CompileScope in project intellij-community by JetBrains.
the class InternalProjectTaskRunner method buildArtifacts.
private static void buildArtifacts(@NotNull Project project, @NotNull List<Artifact> artifacts, @Nullable Object sessionId, @Nullable CompileStatusNotification compileNotification, boolean forceArtifactBuild) {
if (!artifacts.isEmpty()) {
final CompileScope scope = ArtifactCompileScope.createArtifactsScope(project, artifacts, forceArtifactBuild);
ArtifactsWorkspaceSettings.getInstance(project).setArtifactsToBuild(artifacts);
ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.set(scope, sessionId);
//in external build we can set 'rebuild' flag per target type
CompilerManager.getInstance(project).make(scope, compileNotification);
}
}
use of com.intellij.openapi.compiler.CompileScope in project android by JetBrains.
the class GradleModuleTasksProvider method getAffectedModules.
@NotNull
private static Module[] getAffectedModules(@NotNull Project project, @NotNull Module[] modules) {
final CompilerManager compilerManager = CompilerManager.getInstance(project);
CompileScope scope = compilerManager.createModulesCompileScope(modules, true, true);
return scope.getAffectedModules();
}
use of com.intellij.openapi.compiler.CompileScope in project android by JetBrains.
the class ApkStep method _commit.
@Override
public void _commit(boolean finishChosen) throws CommitStepException {
final String apkPath = myApkPathField.getText().trim();
if (apkPath.length() == 0) {
throw new CommitStepException(AndroidBundle.message("android.extract.package.specify.apk.path.error"));
}
AndroidFacet facet = myWizard.getFacet();
PropertiesComponent properties = PropertiesComponent.getInstance(myWizard.getProject());
properties.setValue(ChooseModuleStep.MODULE_PROPERTY, facet != null ? facet.getModule().getName() : "");
properties.setValue(getApkPathPropertyName(), apkPath);
File folder = new File(apkPath).getParentFile();
if (folder == null) {
throw new CommitStepException(AndroidBundle.message("android.cannot.create.file.error", apkPath));
}
try {
if (!folder.exists()) {
folder.mkdirs();
}
} catch (Exception e) {
throw new CommitStepException(e.getMessage());
}
final CompileScope compileScope = CompilerManager.getInstance(myWizard.getProject()).createModuleCompileScope(facet.getModule(), true);
AndroidCompileUtil.setReleaseBuild(compileScope);
properties.setValue(RUN_PROGUARD_PROPERTY, Boolean.toString(myProguardCheckBox.isSelected()));
if (myProguardCheckBox.isSelected()) {
final List<String> proguardOsCfgPaths = myProGuardConfigFilesPanel.getOsPaths();
if (proguardOsCfgPaths.isEmpty()) {
throw new CommitStepException(AndroidBundle.message("android.extract.package.specify.proguard.cfg.path.error"));
}
final String proguardPathsStr = mergeProguardCfgPathsToOneString(proguardOsCfgPaths);
properties.setValue(PROGUARD_CFG_PATHS_PROPERTY, proguardPathsStr);
for (String path : proguardOsCfgPaths) {
if (!new File(path).isFile()) {
throw new CommitStepException("Cannot find file " + path);
}
}
compileScope.putUserData(AndroidCompileUtil.PROGUARD_CFG_PATHS_KEY, proguardPathsStr);
}
myWizard.setCompileScope(compileScope);
myWizard.setApkPath(apkPath);
}
use of com.intellij.openapi.compiler.CompileScope in project android by JetBrains.
the class AndroidCompileUtil method doGenerate.
public static boolean doGenerate(AndroidFacet facet, final AndroidAutogeneratorMode mode) {
assert !ApplicationManager.getApplication().isDispatchThread();
final CompileContext[] contextWrapper = new CompileContext[1];
final Module module = facet.getModule();
final Project project = module.getProject();
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
if (project.isDisposed())
return;
CompilerTask task = new CompilerTask(project, "Android auto-generation", true, false, true, true);
CompileScope scope = new ModuleCompileScope(module, false);
contextWrapper[0] = new CompileContextImpl(project, task, scope, false, false);
}
});
CompileContext context = contextWrapper[0];
if (context == null) {
return false;
}
generate(facet, mode, context, false);
return context.getMessages(CompilerMessageCategory.ERROR).length == 0;
}
use of com.intellij.openapi.compiler.CompileScope in project android by JetBrains.
the class AndroidJunitPatcher method handleJavaResources.
/**
* Puts folders with merged java resources for the selected variant of every module on the classpath.
*
* <p>The problem we're solving here is that CompilerModuleExtension supports only one directory for "compiler output". When IJ compiles
* Java projects, it copies resources to the output classes dir. This is something our Gradle plugin doesn't do, so we need to add the
* resource directories to the classpath here.
*
* <p>We need to do this for every project dependency as well, since we're using classes and resources directories of these directly.
*
* @see <a href="http://b.android.com/172409">Bug 172409</a>
*/
private static void handleJavaResources(@NotNull Module module, @NotNull AndroidModuleModel androidModel, @NotNull PathsList classPath) {
CompilerManager compilerManager = CompilerManager.getInstance(module.getProject());
CompileScope scope = compilerManager.createModulesCompileScope(new Module[] { module }, true, true);
// The only test resources we want to use, are the ones from the module where the test is. They should go first, before main resources.
JavaArtifact testArtifact = androidModel.getUnitTestArtifactInSelectedVariant();
if (testArtifact != null) {
try {
classPath.add(testArtifact.getJavaResourcesFolder());
} catch (UnsupportedMethodException ignored) {
// Java resources were not present in older versions of the gradle plugin.
}
}
FileRootSearchScope excludeScope = null;
TestArtifactSearchScopes testScopes = TestArtifactSearchScopes.get(module);
if (testScopes != null) {
excludeScope = testScopes.getUnitTestExcludeScope();
}
for (Module affectedModule : scope.getAffectedModules()) {
AndroidFacet facet = AndroidFacet.getInstance(affectedModule);
if (facet != null) {
AndroidModuleModel affectedAndroidModel = AndroidModuleModel.get(facet);
if (affectedAndroidModel != null) {
try {
File resourceFolder = affectedAndroidModel.getMainArtifact().getJavaResourcesFolder();
if (excludeScope != null && excludeScope.accept(resourceFolder)) {
continue;
}
classPath.add(resourceFolder);
} catch (UnsupportedMethodException ignored) {
// Java resources were not present in older versions of the gradle plugin.
}
}
}
}
}
Aggregations