use of org.jetbrains.jps.appengine.model.PersistenceApi in project intellij-community by JetBrains.
the class PersistenceApiComboboxUtil method getSelectedApi.
@Nullable
public static PersistenceApi getSelectedApi(final JComboBox comboBox) {
final String apiName = (String) comboBox.getSelectedItem();
PersistenceApi api = null;
for (PersistenceApi value : PersistenceApi.values()) {
if (value.getDisplayName().equals(apiName)) {
api = value;
}
}
return api;
}
use of org.jetbrains.jps.appengine.model.PersistenceApi in project intellij-community by JetBrains.
the class AppEngineEnhancerBuilder method processModule.
private static boolean processModule(final CompileContext context, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, JpsAppEngineModuleExtension extension) throws IOException, ProjectBuildException {
final Set<File> roots = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
for (String path : extension.getFilesToEnhance()) {
roots.add(new File(FileUtil.toSystemDependentName(path)));
}
final List<String> pathsToProcess = new ArrayList<>();
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
@Override
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor root) throws IOException {
if (JpsPathUtil.isUnder(roots, file)) {
Collection<String> outputs = context.getProjectDescriptor().dataManager.getSourceToOutputMap(target).getOutputs(file.getAbsolutePath());
if (outputs != null) {
pathsToProcess.addAll(outputs);
}
}
return true;
}
});
if (pathsToProcess.isEmpty()) {
return false;
}
JpsModule module = extension.getModule();
JpsSdk<JpsDummyElement> sdk = JavaBuilderUtil.ensureModuleHasJdk(module, context, NAME);
context.processMessage(new ProgressMessage("Enhancing classes in module '" + module.getName() + "'..."));
List<String> vmParams = Collections.singletonList("-Xmx256m");
List<String> classpath = new ArrayList<>();
classpath.add(extension.getToolsApiJarPath());
classpath.add(PathManager.getJarPathForClass(EnhancerRunner.class));
boolean removeOrmJars = Boolean.parseBoolean(System.getProperty("jps.appengine.enhancer.remove.orm.jars", "true"));
for (File file : JpsJavaExtensionService.dependencies(module).recursively().compileOnly().productionOnly().classes().getRoots()) {
if (removeOrmJars && FileUtil.isAncestor(new File(extension.getOrmLibPath()), file, true)) {
continue;
}
classpath.add(file.getAbsolutePath());
}
List<String> programParams = new ArrayList<>();
final File argsFile = FileUtil.createTempFile("appEngineEnhanceFiles", ".txt");
PrintWriter writer = new PrintWriter(argsFile);
try {
for (String path : pathsToProcess) {
writer.println(FileUtil.toSystemDependentName(path));
}
} finally {
writer.close();
}
programParams.add(argsFile.getAbsolutePath());
programParams.add("com.google.appengine.tools.enhancer.Enhance");
programParams.add("-api");
PersistenceApi api = extension.getPersistenceApi();
programParams.add(api.getEnhancerApiName());
if (api.getEnhancerVersion() == 2) {
programParams.add("-enhancerVersion");
programParams.add("v2");
}
programParams.add("-v");
List<String> commandLine = ExternalProcessUtil.buildJavaCommandLine(JpsJavaSdkType.getJavaExecutable(sdk), EnhancerRunner.class.getName(), Collections.<String>emptyList(), classpath, vmParams, programParams);
Process process = new ProcessBuilder(commandLine).start();
ExternalEnhancerProcessHandler handler = new ExternalEnhancerProcessHandler(process, commandLine, context);
handler.startNotify();
handler.waitFor();
ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger();
if (logger.isEnabled()) {
logger.logCompiledPaths(pathsToProcess, NAME, "Enhancing classes:");
}
return true;
}
use of org.jetbrains.jps.appengine.model.PersistenceApi in project intellij-community by JetBrains.
the class PersistenceApiComboboxUtil method setComboboxModel.
public static void setComboboxModel(final JComboBox comboBox, final boolean addNoneItem) {
final DefaultComboBoxModel model = new DefaultComboBoxModel();
if (addNoneItem) {
model.addElement(NONE_ITEM);
}
for (PersistenceApi api : PersistenceApi.values()) {
model.addElement(api.getDisplayName());
}
comboBox.setModel(model);
}
Aggregations