mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
relaunch dex on make if its configuration is changed
This commit is contained in:
@@ -41,6 +41,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -78,7 +79,7 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
}
|
||||
|
||||
public ValidityState createValidityState(DataInput in) throws IOException {
|
||||
return new ClassesAndJarsValidityState(in);
|
||||
return new MyValidityState(in);
|
||||
}
|
||||
|
||||
public static VirtualFile getOutputDirectoryForDex(@NotNull Module module) {
|
||||
@@ -114,6 +115,9 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
}
|
||||
|
||||
public ProcessingItem[] compute() {
|
||||
final AndroidDexCompilerConfiguration dexConfig =
|
||||
AndroidDexCompilerConfiguration.getInstance(myContext.getProject());
|
||||
|
||||
Module[] modules = ModuleManager.getInstance(myContext.getProject()).getModules();
|
||||
List<ProcessingItem> items = new ArrayList<ProcessingItem>();
|
||||
for (Module module : modules) {
|
||||
@@ -181,7 +185,8 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
continue;
|
||||
}
|
||||
|
||||
items.add(new DexItem(module, dexOutputDir, platform.getTarget(), files));
|
||||
items.add(new DexItem(module, dexOutputDir, platform.getTarget(), files, dexConfig.VM_OPTIONS, dexConfig.MAX_HEAP_SIZE,
|
||||
dexConfig.OPTIMIZE));
|
||||
}
|
||||
}
|
||||
return items.toArray(new ProcessingItem[items.size()]);
|
||||
@@ -214,8 +219,9 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
files[i++] = FileUtil.toSystemDependentName(file.getPath());
|
||||
}
|
||||
|
||||
Map<CompilerMessageCategory, List<String>> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys(
|
||||
AndroidDxWrapper.execute(dexItem.myModule, dexItem.myAndroidTarget, outputDirPath, files));
|
||||
Map<CompilerMessageCategory, List<String>> messages = AndroidCompileUtil.toCompilerMessageCategoryKeys(AndroidDxWrapper.execute(
|
||||
dexItem.myModule, dexItem.myAndroidTarget, outputDirPath, files, dexItem.myAdditionalVmParams, dexItem.myMaxHeapSize,
|
||||
dexItem.myOptimize));
|
||||
|
||||
addMessages(messages, dexItem.myModule);
|
||||
if (messages.get(CompilerMessageCategory.ERROR).isEmpty()) {
|
||||
@@ -241,15 +247,24 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
final VirtualFile myClassDir;
|
||||
final IAndroidTarget myAndroidTarget;
|
||||
final Collection<VirtualFile> myFiles;
|
||||
final String myAdditionalVmParams;
|
||||
final int myMaxHeapSize;
|
||||
final boolean myOptimize;
|
||||
|
||||
public DexItem(@NotNull Module module,
|
||||
@NotNull VirtualFile classDir,
|
||||
@NotNull IAndroidTarget target,
|
||||
Collection<VirtualFile> files) {
|
||||
Collection<VirtualFile> files,
|
||||
@NotNull String additionalVmParams,
|
||||
int maxHeapSize,
|
||||
boolean optimize) {
|
||||
myModule = module;
|
||||
myClassDir = classDir;
|
||||
myAndroidTarget = target;
|
||||
myFiles = files;
|
||||
myAdditionalVmParams = additionalVmParams;
|
||||
myMaxHeapSize = maxHeapSize;
|
||||
myOptimize = optimize;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -259,7 +274,49 @@ public class AndroidDexCompiler implements ClassPostProcessingCompiler {
|
||||
|
||||
@Nullable
|
||||
public ValidityState getValidityState() {
|
||||
return new ClassesAndJarsValidityState(myFiles);
|
||||
return new MyValidityState(myFiles, myAdditionalVmParams, myMaxHeapSize, myOptimize);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyValidityState extends ClassesAndJarsValidityState {
|
||||
private final String myAdditionalVmParams;
|
||||
private final int myMaxHeapSize;
|
||||
private final boolean myOptimize;
|
||||
|
||||
public MyValidityState(@NotNull Collection<VirtualFile> files, @NotNull String additionalVmParams, int maxHeapSize, boolean optimize) {
|
||||
super(files);
|
||||
myAdditionalVmParams = additionalVmParams;
|
||||
myMaxHeapSize = maxHeapSize;
|
||||
myOptimize = optimize;
|
||||
}
|
||||
|
||||
public MyValidityState(@NotNull DataInput in) throws IOException {
|
||||
super(in);
|
||||
myAdditionalVmParams = in.readUTF();
|
||||
myMaxHeapSize = in.readInt();
|
||||
myOptimize = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(DataOutput out) throws IOException {
|
||||
super.save(out);
|
||||
out.writeUTF(myAdditionalVmParams);
|
||||
out.writeInt(myMaxHeapSize);
|
||||
out.writeBoolean(myOptimize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsTo(ValidityState otherState) {
|
||||
if (!super.equalsTo(otherState)) {
|
||||
return false;
|
||||
}
|
||||
if (!(otherState instanceof MyValidityState)) {
|
||||
return false;
|
||||
}
|
||||
final MyValidityState state = (MyValidityState)otherState;
|
||||
return state.myAdditionalVmParams.equals(myAdditionalVmParams) &&
|
||||
state.myMaxHeapSize == myMaxHeapSize &&
|
||||
state.myOptimize == myOptimize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.PathsList;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.android.compiler.AndroidDexCompilerConfiguration;
|
||||
import org.jetbrains.android.util.AndroidBundle;
|
||||
import org.jetbrains.android.util.AndroidCommonUtils;
|
||||
import org.jetbrains.android.util.AndroidCompilerMessageKind;
|
||||
@@ -53,7 +52,10 @@ public class AndroidDxWrapper {
|
||||
public static Map<AndroidCompilerMessageKind, List<String>> execute(@NotNull Module module,
|
||||
@NotNull IAndroidTarget target,
|
||||
@NotNull String outputDir,
|
||||
@NotNull String[] compileTargets) {
|
||||
@NotNull String[] compileTargets,
|
||||
@NotNull String additionalVmParams,
|
||||
int maxHeapSize,
|
||||
boolean optimize) {
|
||||
String outFile = outputDir + File.separatorChar + AndroidCommonUtils.CLASSES_FILE_NAME;
|
||||
|
||||
final Map<AndroidCompilerMessageKind, List<String>> messages = new HashMap<AndroidCompilerMessageKind, List<String>>(2);
|
||||
@@ -79,23 +81,20 @@ public class AndroidDxWrapper {
|
||||
parameters.setJdk(sdk);
|
||||
parameters.setMainClass(AndroidDxRunner.class.getName());
|
||||
|
||||
final AndroidDexCompilerConfiguration configuration = AndroidDexCompilerConfiguration.getInstance(module.getProject());
|
||||
|
||||
ParametersList programParamList = parameters.getProgramParametersList();
|
||||
programParamList.add(dxJarPath);
|
||||
programParamList.add(outFile);
|
||||
programParamList.add("--optimize", Boolean.toString(configuration.OPTIMIZE));
|
||||
programParamList.add("--optimize", Boolean.toString(optimize));
|
||||
programParamList.addAll(compileTargets);
|
||||
programParamList.add("--exclude");
|
||||
|
||||
ParametersList vmParamList = parameters.getVMParametersList();
|
||||
|
||||
String additionalVmParams = configuration.VM_OPTIONS;
|
||||
if (additionalVmParams.length() > 0) {
|
||||
vmParamList.addParametersString(additionalVmParams);
|
||||
}
|
||||
if (!hasXmxParam(vmParamList)) {
|
||||
vmParamList.add("-Xmx" + configuration.MAX_HEAP_SIZE + "M");
|
||||
vmParamList.add("-Xmx" + maxHeapSize + "M");
|
||||
}
|
||||
final PathsList classPath = parameters.getClassPath();
|
||||
classPath.add(PathUtil.getJarPathForClass(AndroidDxRunner.class));
|
||||
|
||||
Reference in New Issue
Block a user