Search in sources :

Example 1 with PersistenceApi

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;
}
Also used : PersistenceApi(org.jetbrains.jps.appengine.model.PersistenceApi) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with PersistenceApi

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;
}
Also used : ProgressMessage(org.jetbrains.jps.incremental.messages.ProgressMessage) IOException(java.io.IOException) THashSet(gnu.trove.THashSet) EnhancerRunner(com.intellij.appengine.rt.EnhancerRunner) JpsModule(org.jetbrains.jps.model.module.JpsModule) PersistenceApi(org.jetbrains.jps.appengine.model.PersistenceApi) ProjectBuilderLogger(org.jetbrains.jps.builders.logging.ProjectBuilderLogger) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) JavaSourceRootDescriptor(org.jetbrains.jps.builders.java.JavaSourceRootDescriptor) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 3 with PersistenceApi

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);
}
Also used : PersistenceApi(org.jetbrains.jps.appengine.model.PersistenceApi)

Aggregations

PersistenceApi (org.jetbrains.jps.appengine.model.PersistenceApi)3 EnhancerRunner (com.intellij.appengine.rt.EnhancerRunner)1 THashSet (gnu.trove.THashSet)1 File (java.io.File)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Nullable (org.jetbrains.annotations.Nullable)1 JavaSourceRootDescriptor (org.jetbrains.jps.builders.java.JavaSourceRootDescriptor)1 ProjectBuilderLogger (org.jetbrains.jps.builders.logging.ProjectBuilderLogger)1 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)1 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1