mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[google app engine] remove sources of obsolete Google App Engine for Java plugin (IDEA-298697)
GitOrigin-RevId: 650febbd29d9e07b193f3133fcb9859ff58be43d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4400e62446
commit
c37f3a4327
Generated
-4
@@ -102,7 +102,6 @@
|
||||
<module old-name="git4idea" new-name="intellij.vcs.git" />
|
||||
<module old-name="git4idea-rt" new-name="intellij.vcs.git.rt" />
|
||||
<module old-name="github" new-name="intellij.vcs.github" />
|
||||
<module old-name="google-app-engine" new-name="intellij.java.googleAppEngine" />
|
||||
<module old-name="gradle" new-name="intellij.gradle" />
|
||||
<module old-name="gradle-api-deps" new-name="intellij.tools.dependencies.gradle" />
|
||||
<module old-name="gradle-tests" new-name="intellij.gradle.tests" />
|
||||
@@ -637,9 +636,6 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/java/execution/openapi/intellij.java.execution.iml" filepath="$PROJECT_DIR$/java/execution/openapi/intellij.java.execution.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/execution/impl/intellij.java.execution.impl.iml" filepath="$PROJECT_DIR$/java/execution/impl/intellij.java.execution.impl.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/java-features-trainer/intellij.java.featuresTrainer.iml" filepath="$PROJECT_DIR$/java/java-features-trainer/intellij.java.featuresTrainer.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/google-app-engine/intellij.java.googleAppEngine.iml" filepath="$PROJECT_DIR$/plugins/google-app-engine/intellij.java.googleAppEngine.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/google-app-engine/jps-plugin/intellij.java.googleAppEngine.jps.iml" filepath="$PROJECT_DIR$/plugins/google-app-engine/jps-plugin/intellij.java.googleAppEngine.jps.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/google-app-engine/runtime/intellij.java.googleAppEngine.runtime.iml" filepath="$PROJECT_DIR$/plugins/google-app-engine/runtime/intellij.java.googleAppEngine.runtime.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/compiler/forms-compiler/intellij.java.guiForms.compiler.iml" filepath="$PROJECT_DIR$/java/compiler/forms-compiler/intellij.java.guiForms.compiler.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/ui-designer/intellij.java.guiForms.designer.iml" filepath="$PROJECT_DIR$/plugins/ui-designer/intellij.java.guiForms.designer.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/ui-designer/jps-plugin/intellij.java.guiForms.jps.iml" filepath="$PROJECT_DIR$/plugins/ui-designer/jps-plugin/intellij.java.guiForms.jps.iml" />
|
||||
|
||||
@@ -165,10 +165,8 @@
|
||||
<orderEntry type="module" module-name="intellij.configurationScript.test.java" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.statistics.envTests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.toml.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.java.googleAppEngine" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.maven.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.gradle.java.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.java.googleAppEngine.jps" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.reStructuredText" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.groovy.uast.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.remoteServers.targetsIntegrationTests" scope="TEST" />
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 787 B |
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB |
@@ -1,18 +0,0 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package icons;
|
||||
|
||||
import com.intellij.ui.IconManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run "Generate icon classes" configuration instead
|
||||
*/
|
||||
public final class GoogleAppEngineIcons {
|
||||
private static @NotNull Icon load(@NotNull String path, int cacheKey, int flags) {
|
||||
return IconManager.getInstance().loadRasterizedIcon(path, GoogleAppEngineIcons.class.getClassLoader(), cacheKey, flags);
|
||||
}
|
||||
/** 16x16 */ public static final @NotNull Icon AppEngine = load("icons/appEngine.svg", 2102647694, 0);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/source" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testSource" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/compatibilityResources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/out" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="intellij.java.execution" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util" />
|
||||
<orderEntry type="module" module-name="intellij.platform.lang" />
|
||||
<orderEntry type="module" module-name="intellij.java" />
|
||||
<orderEntry type="module" module-name="intellij.java.debugger" />
|
||||
<orderEntry type="module" module-name="intellij.java.testFramework" scope="TEST" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.xml.impl" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.java.googleAppEngine.runtime" />
|
||||
<orderEntry type="module" module-name="intellij.java.googleAppEngine.jps" />
|
||||
<orderEntry type="module" module-name="intellij.java.compiler.impl" />
|
||||
<orderEntry type="module" module-name="intellij.xml.dom" />
|
||||
<orderEntry type="module" module-name="intellij.java.impl" />
|
||||
<orderEntry type="module" module-name="intellij.java.remoteServers" />
|
||||
<orderEntry type="module" module-name="intellij.maven" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.classLoader" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.ui" />
|
||||
<orderEntry type="module" module-name="intellij.platform.ide.util.io" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testSource" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="intellij.platform.jps.build" />
|
||||
<orderEntry type="module" module-name="intellij.platform.jps.model" />
|
||||
<orderEntry type="module" module-name="intellij.platform.jps.model.serialization" />
|
||||
<orderEntry type="module" module-name="intellij.platform.jps.model.impl" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.java.googleAppEngine.runtime" />
|
||||
<orderEntry type="module" module-name="intellij.platform.jps.model.serialization.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
|
||||
</component>
|
||||
</module>
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
enhancing.classes.in.module.0=Enhancing classes in module ''{0}''...
|
||||
google.appengine.enhancer=Google AppEngine Enhancer
|
||||
|
||||
persistence.api.item.name.jdo=JDO 2
|
||||
persistence.api.item.name.jdo3=JDO 3
|
||||
persistence.api.item.name.jpa=JPA 1
|
||||
persistence.api.item.name.jpa2=JPA 2
|
||||
-1
@@ -1 +0,0 @@
|
||||
org.jetbrains.jps.appengine.model.impl.JpsAppEngineExtensionServiceImpl
|
||||
-1
@@ -1 +0,0 @@
|
||||
org.jetbrains.jps.appengine.build.AppEngineEnhancerBuilderService
|
||||
-1
@@ -1 +0,0 @@
|
||||
org.jetbrains.jps.appengine.model.impl.JpsAppEngineModelSerializerExtension
|
||||
-170
@@ -1,170 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.jps.appengine.build;
|
||||
|
||||
import com.intellij.appengine.rt.EnhancerRunner;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.containers.FileCollectionFactory;
|
||||
import com.intellij.util.execution.ParametersListUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.appengine.model.JpsAppEngineExtensionService;
|
||||
import org.jetbrains.jps.appengine.model.JpsAppEngineModuleExtension;
|
||||
import org.jetbrains.jps.appengine.model.PersistenceApi;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.logging.ProjectBuilderLogger;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.model.JpsDummyElement;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.java.JpsJavaSdkType;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdk;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.util.JpsPathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class AppEngineEnhancerBuilder extends ModuleLevelBuilder {
|
||||
|
||||
public static final Supplier<@Nls String> NAME_SUPPLIER = JavaGoogleAppEngineJpsBundle.messagePointer("google.appengine.enhancer");
|
||||
|
||||
public AppEngineEnhancerBuilder() {
|
||||
super(BuilderCategory.CLASS_POST_PROCESSOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExitCode build(final CompileContext context,
|
||||
ModuleChunk chunk,
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder,
|
||||
OutputConsumer outputConsumer)
|
||||
throws ProjectBuildException, IOException {
|
||||
|
||||
boolean doneSomething = false;
|
||||
for (final JpsModule module : chunk.getModules()) {
|
||||
JpsAppEngineModuleExtension extension = JpsAppEngineExtensionService.getInstance().getExtension(module);
|
||||
if (extension != null && extension.isRunEnhancerOnMake()) {
|
||||
doneSomething |= processModule(context, dirtyFilesHolder, extension);
|
||||
}
|
||||
}
|
||||
|
||||
return doneSomething ? ExitCode.OK : ExitCode.NOTHING_DONE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> getCompilableFileExtensions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private static boolean processModule(final CompileContext context,
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder,
|
||||
JpsAppEngineModuleExtension extension) throws IOException, ProjectBuildException {
|
||||
final Set<File> roots = FileCollectionFactory.createCanonicalFileSet();
|
||||
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_SUPPLIER.get());
|
||||
context.processMessage(new ProgressMessage(
|
||||
JavaGoogleAppEngineJpsBundle.message("enhancing.classes.in.module.0", 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");
|
||||
try (PrintWriter writer = new PrintWriter(argsFile)) {
|
||||
for (String path : pathsToProcess) {
|
||||
writer.println(FileUtil.toSystemDependentName(path));
|
||||
}
|
||||
}
|
||||
|
||||
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.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_SUPPLIER.get(), "Enhancing classes:");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return NAME_SUPPLIER.get();
|
||||
}
|
||||
|
||||
private static class ExternalEnhancerProcessHandler extends EnhancerProcessHandlerBase {
|
||||
private final CompileContext myContext;
|
||||
|
||||
ExternalEnhancerProcessHandler(Process process, List<String> commandLine, CompileContext context) {
|
||||
super(process, ParametersListUtil.join(commandLine), null);
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reportInfo(@Nls String message) {
|
||||
myContext.processMessage(new CompilerMessage(NAME_SUPPLIER.get(), BuildMessage.Kind.INFO, message));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reportError(@Nls String message) {
|
||||
myContext.processMessage(new CompilerMessage(NAME_SUPPLIER.get(), BuildMessage.Kind.ERROR, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine.build;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.incremental.BuilderService;
|
||||
import org.jetbrains.jps.incremental.ModuleLevelBuilder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AppEngineEnhancerBuilderService extends BuilderService {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends ModuleLevelBuilder> createModuleLevelBuilders() {
|
||||
return Collections.singletonList(new AppEngineEnhancerBuilder());
|
||||
}
|
||||
}
|
||||
-124
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine.build;
|
||||
|
||||
import com.intellij.execution.process.BaseOSProcessHandler;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class EnhancerProcessHandlerBase extends BaseOSProcessHandler {
|
||||
private static final Logger LOG = Logger.getInstance(EnhancerProcessHandlerBase.class);
|
||||
private final Map<Key, EnhancerOutputParser> myParsers =
|
||||
FactoryMap.create(key -> new EnhancerOutputParser(ProcessOutputTypes.STDERR.equals(key)));
|
||||
|
||||
public EnhancerProcessHandlerBase(Process process, @NotNull String commandLine, Charset charset) {
|
||||
super(process, commandLine, charset);
|
||||
addProcessListener(new ProcessAdapter() {
|
||||
@Override
|
||||
public void processTerminated(@NotNull ProcessEvent event) {
|
||||
final int exitCode = event.getExitCode();
|
||||
if (exitCode != 0) {
|
||||
reportError("Enhancement process terminated with exit code " + exitCode);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyTextAvailable(@NotNull String text, @NotNull Key outputType) {
|
||||
super.notifyTextAvailable(text, outputType);
|
||||
myParsers.get(outputType).appendText(text);
|
||||
}
|
||||
|
||||
protected abstract void reportInfo(String message);
|
||||
|
||||
protected abstract void reportError(String message);
|
||||
|
||||
private class EnhancerOutputParser {
|
||||
@NonNls private static final String PLEASE_SEE_THE_LOGS_PREFIX = "Please see the logs [";
|
||||
private final StringBuilder myBuffer = new StringBuilder();
|
||||
private final boolean myErrorStream;
|
||||
|
||||
EnhancerOutputParser(boolean errorStream) {
|
||||
myErrorStream = errorStream;
|
||||
}
|
||||
|
||||
|
||||
public void appendText(String text) {
|
||||
myBuffer.append(text);
|
||||
int start = 0;
|
||||
while (true) {
|
||||
int lineEnd1 = myBuffer.indexOf("\n", start);
|
||||
int lineEnd2 = myBuffer.indexOf("\r", start);
|
||||
if (lineEnd1 == -1 && lineEnd2 == -1) break;
|
||||
|
||||
int lineEnd = lineEnd1 == -1 ? lineEnd2 : lineEnd2 == -1 ? lineEnd1 : Math.min(lineEnd1, lineEnd2);
|
||||
parseLine(myBuffer.substring(start, lineEnd).trim());
|
||||
start = lineEnd + 1;
|
||||
}
|
||||
|
||||
myBuffer.delete(0, start);
|
||||
}
|
||||
|
||||
private void parseLine(String line) {
|
||||
LOG.debug(myErrorStream ? "[err] " + line : line);
|
||||
if (myErrorStream) {
|
||||
reportError(line);
|
||||
return;
|
||||
}
|
||||
|
||||
if (line.startsWith("Encountered a problem: ")) {
|
||||
reportError(line);
|
||||
}
|
||||
else if (line.startsWith(PLEASE_SEE_THE_LOGS_PREFIX)) {
|
||||
if (!showLogFileContent(line)) {
|
||||
reportError(line);
|
||||
}
|
||||
}
|
||||
else if (line.startsWith("DataNucleus Enhancer completed")) {
|
||||
reportInfo(line);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean showLogFileContent(String line) {
|
||||
final int i = line.lastIndexOf(']');
|
||||
if (i != -1) {
|
||||
File logFile = new File(line.substring(PLEASE_SEE_THE_LOGS_PREFIX.length(), i));
|
||||
if (logFile.exists()) {
|
||||
try {
|
||||
reportError(FileUtil.loadFile(logFile));
|
||||
return true;
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.jps.appengine.build;
|
||||
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
import org.jetbrains.jps.api.JpsDynamicBundle;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class JavaGoogleAppEngineJpsBundle extends JpsDynamicBundle {
|
||||
@NonNls private static final String BUNDLE = "messages.JavaGoogleAppEngineJpsBundle";
|
||||
private static final JavaGoogleAppEngineJpsBundle INSTANCE = new JavaGoogleAppEngineJpsBundle();
|
||||
|
||||
private JavaGoogleAppEngineJpsBundle() {
|
||||
super(BUNDLE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nls
|
||||
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
|
||||
return INSTANCE.getMessage(key, params);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Supplier<@Nls @NotNull String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key,
|
||||
Object @NotNull ... params) {
|
||||
return INSTANCE.getLazyMessage(key, params);
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
public abstract class JpsAppEngineExtensionService {
|
||||
public static JpsAppEngineExtensionService getInstance() {
|
||||
return JpsServiceManager.getInstance().getService(JpsAppEngineExtensionService.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract JpsAppEngineModuleExtension getExtension(@NotNull JpsModule module);
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine.model;
|
||||
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface JpsAppEngineModuleExtension extends JpsElement {
|
||||
JpsModule getModule();
|
||||
|
||||
String getOrmLibPath();
|
||||
|
||||
String getSdkHomePath();
|
||||
|
||||
boolean isRunEnhancerOnMake();
|
||||
|
||||
List<String> getFilesToEnhance();
|
||||
|
||||
PersistenceApi getPersistenceApi();
|
||||
|
||||
String getToolsApiJarPath();
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine.model;
|
||||
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.jps.appengine.build.JavaGoogleAppEngineJpsBundle;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public enum PersistenceApi {
|
||||
JDO(JavaGoogleAppEngineJpsBundle.messagePointer("persistence.api.item.name.jdo"), "JDO", 1),
|
||||
JDO3(JavaGoogleAppEngineJpsBundle.messagePointer("persistence.api.item.name.jdo3"), "JDO", 2),
|
||||
JPA(JavaGoogleAppEngineJpsBundle.messagePointer("persistence.api.item.name.jpa"), "JPA", 1),
|
||||
JPA2(JavaGoogleAppEngineJpsBundle.messagePointer("persistence.api.item.name.jpa2"), "JPA", 2);
|
||||
|
||||
private final Supplier<@Nls String> myDisplayNameSupplier;
|
||||
private final String myEnhancerApiName;
|
||||
private final int myEnhancerVersion;
|
||||
|
||||
PersistenceApi(Supplier<@Nls String> displayNameSupplier, String enhancerApiName, int enhancerVersion) {
|
||||
myDisplayNameSupplier = displayNameSupplier;
|
||||
myEnhancerApiName = enhancerApiName;
|
||||
myEnhancerVersion = enhancerVersion;
|
||||
}
|
||||
|
||||
@Nls
|
||||
public String getDisplayName() {
|
||||
return myDisplayNameSupplier.get();
|
||||
}
|
||||
|
||||
public String getEnhancerApiName() {
|
||||
return myEnhancerApiName;
|
||||
}
|
||||
|
||||
public int getEnhancerVersion() {
|
||||
return myEnhancerVersion;
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine.model.impl;
|
||||
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import com.intellij.util.xmlb.annotations.XCollection;
|
||||
import org.jetbrains.jps.appengine.model.PersistenceApi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AppEngineModuleExtensionProperties {
|
||||
@Tag("sdk-home-path")
|
||||
public String mySdkHomePath = "";
|
||||
|
||||
@Tag("run-enhancer-on-make")
|
||||
public boolean myRunEnhancerOnMake = false;
|
||||
|
||||
@XCollection(propertyElementName = "files-to-enhance", elementName = "file", valueAttributeName = "path")
|
||||
public List<String> myFilesToEnhance = new ArrayList<>();
|
||||
|
||||
@Tag("persistence-api")
|
||||
public PersistenceApi myPersistenceApi = PersistenceApi.JDO;
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.appengine.model.JpsAppEngineExtensionService;
|
||||
import org.jetbrains.jps.appengine.model.JpsAppEngineModuleExtension;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
public class JpsAppEngineExtensionServiceImpl extends JpsAppEngineExtensionService {
|
||||
@Nullable
|
||||
@Override
|
||||
public JpsAppEngineModuleExtension getExtension(@NotNull JpsModule module) {
|
||||
return module.getContainer().getChild(JpsAppEngineModuleExtensionImpl.ROLE);
|
||||
}
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.appengine.model.impl;
|
||||
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.appengine.model.JpsAppEngineModuleExtension;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension;
|
||||
import org.jetbrains.jps.model.serialization.facet.JpsFacetConfigurationSerializer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class JpsAppEngineModelSerializerExtension extends JpsModelSerializerExtension {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends JpsFacetConfigurationSerializer<?>> getFacetConfigurationSerializers() {
|
||||
return Collections.singletonList(new JpsAppEngineModuleExtensionSerializer());
|
||||
}
|
||||
|
||||
private static final class JpsAppEngineModuleExtensionSerializer extends JpsFacetConfigurationSerializer<JpsAppEngineModuleExtension> {
|
||||
JpsAppEngineModuleExtensionSerializer() {
|
||||
super(JpsAppEngineModuleExtensionImpl.ROLE, "google-app-engine", "Google App Engine");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JpsAppEngineModuleExtension loadExtension(@NotNull Element facetConfigurationElement,
|
||||
String name,
|
||||
JpsElement parent,
|
||||
JpsModule module) {
|
||||
return new JpsAppEngineModuleExtensionImpl(
|
||||
XmlSerializer.deserialize(facetConfigurationElement, AppEngineModuleExtensionProperties.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
-96
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine.model.impl;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.appengine.model.JpsAppEngineModuleExtension;
|
||||
import org.jetbrains.jps.appengine.model.PersistenceApi;
|
||||
import org.jetbrains.jps.incremental.artifacts.impl.JpsArtifactPathUtil;
|
||||
import org.jetbrains.jps.model.JpsElementChildRole;
|
||||
import org.jetbrains.jps.model.ex.JpsElementBase;
|
||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JpsAppEngineModuleExtensionImpl extends JpsElementBase<JpsAppEngineModuleExtensionImpl> implements
|
||||
JpsAppEngineModuleExtension {
|
||||
public static final JpsElementChildRole<JpsAppEngineModuleExtension> ROLE = JpsElementChildRoleBase.create("AppEngine");
|
||||
public static final String LIB_APPENGINE_TOOLS_API_JAR = "/lib/appengine-tools-api.jar";
|
||||
private final AppEngineModuleExtensionProperties myProperties;
|
||||
|
||||
public JpsAppEngineModuleExtensionImpl(AppEngineModuleExtensionProperties properties) {
|
||||
myProperties = properties;
|
||||
}
|
||||
|
||||
private JpsAppEngineModuleExtensionImpl(JpsAppEngineModuleExtensionImpl original) {
|
||||
myProperties = XmlSerializerUtil.createCopy(original.myProperties);
|
||||
}
|
||||
|
||||
public AppEngineModuleExtensionProperties getProperties() {
|
||||
return myProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsModule getModule() {
|
||||
return (JpsModule)getParent();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsAppEngineModuleExtensionImpl createCopy() {
|
||||
return new JpsAppEngineModuleExtensionImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyChanges(@NotNull JpsAppEngineModuleExtensionImpl modified) {
|
||||
XmlSerializerUtil.copyBean(modified.myProperties, myProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolsApiJarPath() {
|
||||
return FileUtil.toSystemDependentName(JpsArtifactPathUtil.appendToPath(getSdkHomePath(), LIB_APPENGINE_TOOLS_API_JAR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrmLibPath() {
|
||||
return FileUtil.toSystemDependentName(JpsArtifactPathUtil.appendToPath(getSdkHomePath(), "/lib/user/orm"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSdkHomePath() {
|
||||
return myProperties.mySdkHomePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunEnhancerOnMake() {
|
||||
return myProperties.myRunEnhancerOnMake;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFilesToEnhance() {
|
||||
return myProperties.myFilesToEnhance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistenceApi getPersistenceApi() {
|
||||
return myProperties.myPersistenceApi;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/war/WEB-INF/web.xml" />
|
||||
</descriptors>
|
||||
<webroots>
|
||||
<root url="file://$MODULE_DIR$/war" relative="/" />
|
||||
</webroots>
|
||||
</configuration>
|
||||
<facet type="google-app-engine" name="Google App Engine">
|
||||
<configuration>
|
||||
<files-to-enhance>
|
||||
<file path="$MODULE_DIR$/src" />
|
||||
</files-to-enhance>
|
||||
<persistence-api>JPA2</persistence-api>
|
||||
<run-enhancer-on-make>true</run-enhancer-on-make>
|
||||
<sdk-home-path>$USER_HOME$/applications/appengine-java-sdk-1.7.3</sdk-home-path>
|
||||
</configuration>
|
||||
</facet>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="orm" level="project" />
|
||||
<orderEntry type="library" name="Java EE 6-Java EE 6" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AntConfiguration">
|
||||
<defaultAnt bundledAnt="true" />
|
||||
</component>
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="exploded-war" name="appEngine:Web exploded">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/appEngineEnhancerV2_Web_exploded</output-path>
|
||||
<root id="root">
|
||||
<element id="javaee-facet-resources" facet="appEngine/web/Web" />
|
||||
<element id="directory" name="WEB-INF">
|
||||
<element id="directory" name="classes">
|
||||
<element id="module-output" name="appEngine" />
|
||||
</element>
|
||||
<element id="directory" name="lib">
|
||||
<element id="library" level="project" name="appengine api" />
|
||||
<element id="library" level="project" name="orm" />
|
||||
</element>
|
||||
</element>
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/appEngine.iml" filepath="$PROJECT_DIR$/appEngine.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" project-jdk-name="1.6.0_34" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="libraryTable">
|
||||
<library name="appengine api">
|
||||
<CLASSES>
|
||||
<root url="file://$USER_HOME$/applications/appengine-java-sdk-1.7.3/lib/user" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
<jarDirectory url="file://$USER_HOME$/applications/appengine-java-sdk-1.7.3/lib/user" recursive="false" />
|
||||
</library>
|
||||
<library name="Java EE 6-Java EE 6">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/javax.annotation.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/javax.ejb.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/javax.jms.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/javax.resource.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/javax.servlet.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/javax.servlet.jsp.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/javax.servlet.jsp.jstl.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
<library name="orm">
|
||||
<CLASSES>
|
||||
<root url="file://$USER_HOME$/applications/appengine-java-sdk-1.7.3/lib/opt/user/datanucleus/v2" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
<jarDirectory url="file://$USER_HOME$/applications/appengine-java-sdk-1.7.3/lib/opt/user/datanucleus/v2" recursive="false" />
|
||||
</library>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.appengine.tools.enhancer;
|
||||
|
||||
public class Enhance {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Enhancing finished");
|
||||
}
|
||||
}
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine;
|
||||
|
||||
import com.google.appengine.tools.enhancer.Enhance;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.jps.appengine.build.AppEngineEnhancerBuilder;
|
||||
import org.jetbrains.jps.appengine.model.JpsAppEngineModuleExtension;
|
||||
import org.jetbrains.jps.appengine.model.impl.AppEngineModuleExtensionProperties;
|
||||
import org.jetbrains.jps.appengine.model.impl.JpsAppEngineModuleExtensionImpl;
|
||||
import org.jetbrains.jps.builders.JpsBuildTestCase;
|
||||
import org.jetbrains.jps.model.java.JpsJavaLibraryType;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class AppEngineEnhancerBuilderTest extends JpsBuildTestCase {
|
||||
public void testChangeFile() {
|
||||
String file = createFile("src/A.java", "class A{}");
|
||||
addAppEngineModule("a", true, PathUtil.getParentPath(file));
|
||||
buildAllModules();
|
||||
assertEnhanced("out/production/a/A.class");
|
||||
|
||||
buildAllModules();
|
||||
assertEnhanced();
|
||||
|
||||
change(file);
|
||||
buildAllModules();
|
||||
assertEnhanced("out/production/a/A.class");
|
||||
}
|
||||
|
||||
public void testDoNotRunEnhancerIfDisabled() {
|
||||
String file = createFile("src/A.java", "class A{}");
|
||||
addAppEngineModule("a", false, PathUtil.getParentPath(file));
|
||||
buildAllModules();
|
||||
assertEnhanced();
|
||||
}
|
||||
|
||||
private void assertEnhanced(final String... paths) {
|
||||
assertCompiled(AppEngineEnhancerBuilder.NAME_SUPPLIER.get(), paths);
|
||||
}
|
||||
|
||||
private void addAppEngineModule(final String moduleName, final boolean runEnhancerOnMake, String srcRoot) {
|
||||
JpsModule module = addModule(moduleName, srcRoot);
|
||||
AppEngineModuleExtensionProperties properties = new AppEngineModuleExtensionProperties();
|
||||
properties.myRunEnhancerOnMake = runEnhancerOnMake;
|
||||
properties.myFilesToEnhance.add(srcRoot);
|
||||
JpsAppEngineModuleExtension extension = new JpsAppEngineModuleExtensionImpl(properties);
|
||||
module.getContainer().setChild(JpsAppEngineModuleExtensionImpl.ROLE, extension);
|
||||
addEnhancerLibrary(module);
|
||||
}
|
||||
|
||||
private static void addEnhancerLibrary(JpsModule module) {
|
||||
String path = PathManager.getJarPathForClass(Enhance.class);
|
||||
JpsLibrary library = module.addModuleLibrary("appengine-enhancer", JpsJavaLibraryType.INSTANCE);
|
||||
library.addRoot(new File(path), JpsOrderRootType.COMPILED);
|
||||
module.getDependenciesList().addLibraryDependency(library);
|
||||
}
|
||||
}
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.appengine;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.jps.appengine.model.JpsAppEngineExtensionService;
|
||||
import org.jetbrains.jps.appengine.model.JpsAppEngineModuleExtension;
|
||||
import org.jetbrains.jps.appengine.model.PersistenceApi;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.serialization.JpsSerializationTestCase;
|
||||
|
||||
public class JpsAppEngineSerializationTest extends JpsSerializationTestCase {
|
||||
public static final String PROJECT_PATH = "plugins/google-app-engine/jps-plugin/testData/serialization/appEngine";
|
||||
|
||||
public void testLoad() {
|
||||
loadProject(PROJECT_PATH + "/appEngine.ipr");
|
||||
JpsModule module = assertOneElement(myProject.getModules());
|
||||
assertEquals("appEngine", module.getName());
|
||||
JpsAppEngineModuleExtension extension = JpsAppEngineExtensionService.getInstance().getExtension(module);
|
||||
assertNotNull(extension);
|
||||
assertEquals(PersistenceApi.JPA2, extension.getPersistenceApi());
|
||||
assertEquals(FileUtil.toSystemIndependentName(getTestDataFileAbsolutePath(PROJECT_PATH) + "/src"), assertOneElement(extension.getFilesToEnhance()));
|
||||
assertTrue(extension.isRunEnhancerOnMake());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="org.jetbrains.idea.maven">
|
||||
<importer implementation="com.intellij.appengine.maven.AppEngineFacetImporter"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -1,45 +0,0 @@
|
||||
<idea-plugin>
|
||||
<resource-bundle>messages.JavaGoogleAppEngineBundle</resource-bundle>
|
||||
<depends optional="true" config-file="google-app-engine-maven-support.xml">org.jetbrains.idea.maven</depends>
|
||||
|
||||
<extensionPoints>
|
||||
<extensionPoint qualifiedName="com.intellij.appengine.forbiddenCodeHandler"
|
||||
interface="com.intellij.appengine.inspections.AppEngineForbiddenCodeHandler"/>
|
||||
</extensionPoints>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<applicationService serviceInterface="com.intellij.appengine.sdk.AppEngineSdkManager"
|
||||
serviceImplementation="com.intellij.appengine.sdk.impl.AppEngineSdkManagerImpl"/>
|
||||
<applicationService serviceInterface="com.intellij.appengine.facet.AppEngineWebIntegration"
|
||||
serviceImplementation="com.intellij.appengine.facet.impl.AppEngineCommunityWebIntegration"/>
|
||||
|
||||
<framework.type implementation="com.intellij.appengine.facet.AppEngineFrameworkType"/>
|
||||
<fileTemplateGroup implementation="com.intellij.appengine.facet.AppEngineTemplateGroupDescriptorFactory"/>
|
||||
<facetType implementation="com.intellij.appengine.facet.AppEngineFacetType"/>
|
||||
<project.converterProvider implementation="com.intellij.appengine.converter.AppEngineFacetConverterProvider" id="google-app-engine-facet"/>
|
||||
<framework.detector implementation="com.intellij.appengine.facet.AppEngineFrameworkDetector"/>
|
||||
<compileServer.plugin classpath="java-googleAppEngine-jps.jar;java-googleAppEngine-runtime.jar"/>
|
||||
|
||||
<xml.schemaProvider implementation="com.intellij.appengine.descriptor.AppEngineWebSchemaProvider"/>
|
||||
<dom.fileMetaData implementation="com.intellij.appengine.descriptor.dom.AppEngineWebFileDescription" rootTagName="appengine-web-app"/>
|
||||
|
||||
<localInspection language="JAVA" shortName="AppEngineForbiddenCode" enabledByDefault="true" level="ERROR"
|
||||
implementationClass="com.intellij.appengine.inspections.AppEngineForbiddenCodeInspection"
|
||||
groupKey="app.engine.inspection.group.name" key="app.engine.inspection.forbidden.code.name"
|
||||
bundle="messages.JavaGoogleAppEngineBundle"/>
|
||||
|
||||
<remoteServer.type implementation="com.intellij.appengine.cloud.AppEngineCloudType"/>
|
||||
<remoteServer.defaultConfigurable.includeServerType serverType="com.intellij.appengine.cloud.AppEngineCloudType"/>
|
||||
|
||||
<pluginReplacement implementation="com.intellij.appengine.converter.AppEnginePluginReplacement"/>
|
||||
<postStartupActivity implementation="com.intellij.appengine.converter.MigrateToCloudToolsNotification"/>
|
||||
<notificationGroup id="Migrate to Google Cloud SDK" displayType="BALLOON" bundle="messages.AppEngineBundle" key="notification.group.migrate"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<action class="com.intellij.appengine.actions.UploadApplicationAction" id="AppEngine.UploadApplication"
|
||||
icon="GoogleAppEngineIcons.AppEngine">
|
||||
<add-to-group group-id="ToolsMenu" anchor="last"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
</idea-plugin>
|
||||
@@ -1,3 +0,0 @@
|
||||
java.lang.System:exit,gc,runFinalization,runFinalizersOnExit,load,loadLibrary,setSecurityManager,inheritedChannel,console
|
||||
java.lang.Thread:new
|
||||
java.lang.ThreadGroup:new
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<appengine-application xmlns="http://appengine.google.com/ns/1.0">
|
||||
<application></application>
|
||||
</appengine-application>
|
||||
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<font face="verdana" size="-1">
|
||||
A built-in template for creating an <i>appengine-application.xml</i> descriptor in a Google App Engine application.
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
|
||||
|
||||
<persistence-manager-factory name="transactions-optional">
|
||||
<property name="javax.jdo.PersistenceManagerFactoryClass"
|
||||
value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
|
||||
<property name="javax.jdo.option.ConnectionURL" value="appengine"/>
|
||||
<property name="javax.jdo.option.NontransactionalRead" value="true"/>
|
||||
<property name="javax.jdo.option.NontransactionalWrite" value="true"/>
|
||||
<property name="javax.jdo.option.RetainValues" value="true"/>
|
||||
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
|
||||
</persistence-manager-factory>
|
||||
</jdoconfig>
|
||||
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<font face="verdana" size="-1">
|
||||
A built-in template for creating a <i>jdoconfig.xml</i> descriptor in a Google App Engine application.
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
|
||||
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
|
||||
|
||||
<persistence-unit name="transactions-optional">
|
||||
<provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
|
||||
<properties>
|
||||
<property name="datanucleus.NontransactionalRead" value="true"/>
|
||||
<property name="datanucleus.NontransactionalWrite" value="true"/>
|
||||
<property name="datanucleus.ConnectionURL" value="appengine"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
|
||||
</persistence>
|
||||
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<font face="verdana" size="-1">
|
||||
A built-in template for creating a <i>persistence.xml</i> descriptor in a Google App Engine application.
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
|
||||
<application></application>
|
||||
<version>1</version>
|
||||
<threadsafe>true</threadsafe>
|
||||
</appengine-web-app>
|
||||
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<font face="verdana" size="-1">
|
||||
A built-in template for creating an <b>appengine-web.xml</b> descriptor in a Google App Engine application.
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,11 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<g fill="none" fill-rule="evenodd" transform="translate(-.07 .94)">
|
||||
<path fill="#4285F4" d="M15.3944522,6.34426227 L12.1931073,0.776600024 C11.9481448,0.342190172 11.4915423,0.0698957629 10.9929072,0.0608620709 L4.58900014,0.0608620709 C4.09029498,0.069649919 3.63357959,0.342011634 3.38880011,0.776600024 L0.186237937,6.32965537 C-0.0615125891,6.76077125 -0.0615125891,7.29106367 0.186237937,7.72217955 L3.38758286,13.3214901 C3.62985333,13.7620755 4.08535369,14.043414 4.5877829,14.0627901 L10.99169,14.0627901 C11.4940926,14.0455448 11.9504108,13.7653737 12.1931073,13.3251418 L15.3944522,7.75747955 C15.6439244,7.31943623 15.6439244,6.78230559 15.3944522,6.34426227 Z"/>
|
||||
<path fill="#000" d="M12.3270038,6.81655194 L12.2430142,6.79098987 L7.99484163,2.54160008 L7.12329677,3.81605184 L7.85364162,4.54639669 L5.99491398,5.22318292 L5.26456913,7.07095539 L4.55126566,6.35765192 L3.27194493,7.48725196 L9.84504858,14.0603556 L10.99169,14.0603556 C11.4940926,14.0431103 11.9504108,13.7629393 12.1931073,13.3227073 L14.6166349,9.1049658 L12.3270038,6.81655194 Z" opacity=".07"/>
|
||||
<g fill="#FFF" transform="translate(3.165 2.434)">
|
||||
<path fill-rule="nonzero" d="M4.62551738,1.82586213 C3.07931048,1.82586213 1.82586213,3.07931048 1.82586213,4.62551738 C1.82586213,6.17172429 3.07931048,7.42517264 4.62551738,7.42517264 C6.17172429,7.42517264 7.42517264,6.17172429 7.42517264,4.62551738 C7.42517264,3.88300264 7.13020981,3.17089937 6.6051726,2.64586217 C6.0801354,2.12082496 5.36803213,1.82586213 4.62551738,1.82586213 M4.62551738,6.75934159 C3.45020417,6.76001051 2.49669386,5.80813022 2.49535186,4.63281758 C2.49400986,3.45750494 3.44534393,2.50344966 4.62065561,2.50143459 C5.79596729,2.49941951 6.75056722,3.45020705 6.75325538,4.62551738 C6.75357834,5.19003946 6.52954916,5.73155071 6.13048587,6.13084229 C5.73142259,6.53013388 5.19003955,6.75447272 4.62551738,6.75447262"/>
|
||||
<path d="M9.02462787 4.29321048L7.85485886 3.92803805C7.90469083 4.15719496 7.92998966 4.39100512 7.93032783 4.62551738 7.93029126 4.79051925 7.91808574 4.95529374 7.89381059 5.11850016L9.02584511 5.11850016C9.12164313 5.10375954 9.1941558 5.02414774 9.19991063 4.92739326L9.19991063 4.48553462C9.1941558 4.38878014 9.12164313 4.30916834 9.02584511 4.29442772M4.62551738 1.32070694C4.85582035 1.32091243 5.08548223 1.34498002 5.3108243 1.39252418L4.89087601.227624145C4.87603641.131401176 4.79577347.0587581332 4.69855187.0535586224L4.52326911.0535586224C4.42585545.0582952568 4.34534308.131164049 4.33094496.227624145L3.96577254 1.38765522C4.18214416 1.34393551 4.4023385 1.32191608 4.6230829 1.32192418M1.32070694 4.62551738C1.32047211 4.39023481 1.34536382 4.15559987 1.39495866 3.92560357L.225189662 4.290776C.128966693 4.3056156.0563236504 4.38587854.0511241395 4.48310014L.0511241395 4.92495877C.0568789733 5.02171325.129391637 5.10132506.225189662 5.11606568L1.35722418 5.11606568C1.33277513 4.95287866 1.32056865 4.78809121 1.32070694 4.6230829"/>
|
||||
<path fill-rule="nonzero" d="M5.62730707,3.71015184 L5.35586224,3.97551047 C4.95505847,3.62346286 4.34961562,3.6436939 3.97320721,4.02171227 C3.5967988,4.39973064 3.57915198,5.00525432 3.93290702,5.40455189 L3.66754839,5.66991052 C4.01762556,6.0199877 4.52787416,6.15670841 5.00608847,6.02857127 C5.48430278,5.90043413 5.85783068,5.52690623 5.98596782,5.04869192 C6.11410496,4.57047761 5.97738425,4.06022901 5.62730707,3.71015184 M5.07954843,5.07954843 C4.89583206,5.26361177 4.61929876,5.31882109 4.37898806,5.21941391 C4.13867737,5.12000674 3.98195646,4.88557703 3.98195646,4.62551738 C3.98195646,4.36545774 4.13867737,4.13102803 4.37898806,4.03162086 C4.61929876,3.93221368 4.89583206,3.987423 5.07954843,4.17148634 C5.20102023,4.29134 5.26940006,4.45487068 5.26940006,4.62551738 C5.26940006,4.79616409 5.20102023,4.95969477 5.07954843,5.07954843"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.8 KiB |
@@ -1,7 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports the code that is forbidden in Google App Engine applications.
|
||||
<p>Google App Engine Java applications aren't allowed to use some APIs (e.g. Thread's class constructor) and declare native methods.
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
action.upload.app.engine.application.text=Upload App Engine Application ''{0}''
|
||||
facet.not.found.in.0.artifact=App Engine facet not found in ''{0}'' artifact
|
||||
application.name.not.specified.message=<html>Application name is not specified in appengine-web.xml.<br>Enter application name (see your <a href="https://appengine.google.com">AppEngine account</a>):</html>
|
||||
dialog.message.google.app.engine.description=Google App Engine facets will be decoupled from Web facets
|
||||
sdk.browse.folder.action.title=Google App Engine SDK
|
||||
sdk.browse.folder.action.description=Specify google app engine java SDK home
|
||||
error.process.terminated.with.exit.code.0=Process terminated with exit code {0}
|
||||
plugin.name=Google App Engine
|
||||
message.cannot.start.uploading.0=Cannot start uploading: {0}
|
||||
migrate.to.google.cloud.notification.text=<html><body><p>It looks like your project is using the App Engine SDK. While the App Engine SDK is still supported, \
|
||||
Google recommends that you migrate to the <a href="https://cloud.google.com/sdk/">Google Cloud SDK</a>. The Cloud SDK provides new features \
|
||||
such as <a href="https://cloud.google.com/appengine/docs/flexible/">App Engine Flexible</a> support and \
|
||||
<a href="https://cloud.google.com/debugger/">Google Cloud Debugger</a> integration.\
|
||||
</p><p><a href="https://cloud.google.com/tools/intellij/docs/migrate">Learn more about migrating to the new Cloud tools</a>.</p></body></html>
|
||||
notification.title.app.engine.sdk.detected=App engine SDK detected
|
||||
output.path.isn.t.specified.for.0.artifact=Output path isn''t specified for ''{0}'' artifact
|
||||
path.to.app.engine.not.specified.correctly.message=Path to App Engine SDK isn't specified correctly in App Engine Facet settings
|
||||
path.to.app.engine.not.specified.message=Path to App Engine SDK isn't specified
|
||||
progress.title.uploading.application=Uploading application
|
||||
label.google.app.engine.sdk=Google app engine SDK:
|
||||
app.engine.sdk.download.link.text=App Engine SDK path not specified. <hyperlink>Download</hyperlink>
|
||||
error.app.engine.sdk.path.is.not.correct=App Engine SDK path is not correct
|
||||
inspection.message.native.methods.not.allowed=Native methods aren't allowed in App Engine application
|
||||
inspection.message.application.should.not.create.new.instances.0=App Engine application should not create new instances of ''{0}'' class
|
||||
inspection.message.application.should.not.call.method=AppEngine application should not call ''{0}.{1}'' method
|
||||
inspection.message.class.not.included.in.white.list=Class ''{0}'' is not included in App Engine JRE White List
|
||||
button.sdk.download.text=Download...
|
||||
sdk.file.not.found.message=''{0}'' is not valid App Engine SDK installation: ''{1}'' file not found
|
||||
|
||||
error.message.not.valid.port.number=''{0}'' is not valid port number
|
||||
error.message.artifact.isn.t.specified=Artifact isn't specified
|
||||
dev.server.configuration.name=Google AppEngine Dev Server
|
||||
dev.server.configuration.description=Google AppEngine dev server run configuration
|
||||
dev.server.integration.presentable.name=Google App Engine Dev Server
|
||||
|
||||
app.engine.inspection.group.name=Google app engine
|
||||
app.engine.inspection.forbidden.code.name=Forbidden code in App Engine applications
|
||||
|
||||
cloud.config.form.remember.password.checkbox.text=&Remember password
|
||||
cloud.config.form.password.label.text=&Password:
|
||||
cloud.config.form.email.label.text=&Email:
|
||||
cloud.config.form.email.and.password.radio.text=&Log in with email and password
|
||||
cloud.config.form.oauth2.radio.text=&Use passwordless login via OAuth2
|
||||
run.configuration.form.artifact.to.deploy.label.text=Artifact to &deploy:
|
||||
run.configuration.form.port.label.text=&Port:
|
||||
run.configuration.form.server.parameters.label.text=Server parameters:
|
||||
facet.editor.form.persistence.label.text=Persistence:
|
||||
facet.editor.form.run.enhancer.on.make.checkbox.text=&Run Enhancer for the following classes and packages on make:
|
||||
facet.editor.form.path.to.sdk.label.text=Path to Google App Engine SDK installation directory:
|
||||
support.config.form.persistence.label.text=Persistence:
|
||||
server.editor.app.engine.sdk.label.text=App Engine SDK:
|
||||
|
||||
persistence.api.item.name.none=None
|
||||
action.AppEngine.UploadApplication.text=Upload App Engine Application
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/source" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.rt;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public final class EnhancerRunner {
|
||||
public static void main(String[] args)
|
||||
throws IOException, NoSuchMethodException, ClassNotFoundException, InvocationTargetException, IllegalAccessException {
|
||||
File argsFile = new File(args[0]);
|
||||
String className = args[1];
|
||||
List<String> argsList = new ArrayList<String>(Arrays.asList(args).subList(2, args.length));
|
||||
BufferedReader reader = new BufferedReader(new FileReader(argsFile));
|
||||
try {
|
||||
while (reader.ready()) {
|
||||
final String arg = reader.readLine();
|
||||
argsList.add(arg);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
reader.close();
|
||||
}
|
||||
argsFile.delete();
|
||||
|
||||
final Class<?> delegate = Class.forName(className);
|
||||
final String[] allArgs = argsList.toArray(new String[0]);
|
||||
delegate.getMethod("main", String[].class).invoke(null, (Object)allArgs);
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine;
|
||||
|
||||
import com.intellij.DynamicBundle;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class JavaGoogleAppEngineBundle extends DynamicBundle {
|
||||
@NonNls private static final String BUNDLE = "messages.JavaGoogleAppEngineBundle";
|
||||
private static final JavaGoogleAppEngineBundle INSTANCE = new JavaGoogleAppEngineBundle();
|
||||
|
||||
private JavaGoogleAppEngineBundle() { super(BUNDLE); }
|
||||
|
||||
@NotNull
|
||||
public static @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
|
||||
return INSTANCE.getMessage(key, params);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Supplier<@Nls String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
|
||||
return INSTANCE.getLazyMessage(key, params);
|
||||
}
|
||||
}
|
||||
-243
@@ -1,243 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.actions;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.appengine.cloud.AppEngineAuthData;
|
||||
import com.intellij.appengine.cloud.AppEngineServerConfiguration;
|
||||
import com.intellij.appengine.descriptor.dom.AppEngineWebApp;
|
||||
import com.intellij.appengine.facet.AppEngineAccountDialog;
|
||||
import com.intellij.appengine.facet.AppEngineFacet;
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.appengine.util.AppEngineUtil;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.JavaParameters;
|
||||
import com.intellij.execution.configurations.ParametersList;
|
||||
import com.intellij.execution.process.*;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.CompileStatusNotification;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.elements.PackagingElementResolvingContext;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentRuntime;
|
||||
import com.intellij.remoteServer.runtime.deployment.ServerRuntimeInstance;
|
||||
import com.intellij.remoteServer.runtime.log.LoggingHandler;
|
||||
import com.intellij.util.net.HttpConfigurable;
|
||||
import com.intellij.util.xml.GenericDomValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Collections;
|
||||
|
||||
public final class AppEngineUploader {
|
||||
private static final Logger LOG = Logger.getInstance(AppEngineUploader.class);
|
||||
private final Project myProject;
|
||||
private final Artifact myArtifact;
|
||||
private final AppEngineFacet myAppEngineFacet;
|
||||
private final AppEngineSdk mySdk;
|
||||
private final AppEngineAuthData myAuthData;
|
||||
private final ServerRuntimeInstance.DeploymentOperationCallback myCallback;
|
||||
private final LoggingHandler myLoggingHandler;
|
||||
|
||||
private AppEngineUploader(Project project, Artifact artifact, AppEngineFacet appEngineFacet, AppEngineSdk sdk, AppEngineAuthData authData,
|
||||
ServerRuntimeInstance.DeploymentOperationCallback callback, @NotNull LoggingHandler loggingHandler) {
|
||||
myProject = project;
|
||||
myArtifact = artifact;
|
||||
myAppEngineFacet = appEngineFacet;
|
||||
mySdk = sdk;
|
||||
myAuthData = authData;
|
||||
myCallback = callback;
|
||||
myLoggingHandler = loggingHandler;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AppEngineUploader createUploader(@NotNull Project project,
|
||||
@NotNull Artifact artifact,
|
||||
@NotNull AppEngineServerConfiguration configuration,
|
||||
@NotNull ServerRuntimeInstance.DeploymentOperationCallback callback, @NotNull LoggingHandler loggingHandler) {
|
||||
final String explodedPath = artifact.getOutputPath();
|
||||
if (explodedPath == null) {
|
||||
callback.errorOccurred(JavaGoogleAppEngineBundle.message("output.path.isn.t.specified.for.0.artifact", artifact.getName()));
|
||||
return null;
|
||||
}
|
||||
|
||||
final AppEngineFacet appEngineFacet = AppEngineUtil.findAppEngineFacet(project, artifact);
|
||||
if (appEngineFacet == null) {
|
||||
callback.errorOccurred(JavaGoogleAppEngineBundle.message("facet.not.found.in.0.artifact", artifact.getName()));
|
||||
return null;
|
||||
}
|
||||
|
||||
final AppEngineSdk sdk = appEngineFacet.getSdk();
|
||||
if (!sdk.getAppCfgFile().exists()) {
|
||||
callback.errorOccurred(JavaGoogleAppEngineBundle.message("path.to.app.engine.not.specified.correctly.message"));
|
||||
return null;
|
||||
}
|
||||
|
||||
PackagingElementResolvingContext context = ArtifactManager.getInstance(project).getResolvingContext();
|
||||
VirtualFile descriptorFile = ArtifactUtil.findSourceFileByOutputPath(artifact, "WEB-INF/appengine-web.xml", context);
|
||||
final AppEngineWebApp root = AppEngineFacet.getDescriptorRoot(descriptorFile, appEngineFacet.getModule().getProject());
|
||||
if (root != null) {
|
||||
final GenericDomValue<String> application = root.getApplication();
|
||||
if (StringUtil.isEmptyOrSpaces(application.getValue())) {
|
||||
final String name = Messages.showInputDialog(project,
|
||||
JavaGoogleAppEngineBundle.message("application.name.not.specified.message"),
|
||||
CommonBundle.getErrorTitle(), null, "", null);
|
||||
if (name == null) return null;
|
||||
|
||||
final PsiFile file = application.getXmlTag().getContainingFile();
|
||||
WriteCommandAction.writeCommandAction(project, file).run(() -> application.setStringValue(name));
|
||||
final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
|
||||
if (document != null) {
|
||||
FileDocumentManager.getInstance().saveDocument(document);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AppEngineAuthData authData = AppEngineAccountDialog.createAuthData(project, configuration);
|
||||
if (authData == null) return null;
|
||||
|
||||
return new AppEngineUploader(project, artifact, appEngineFacet, sdk, authData, callback, loggingHandler);
|
||||
}
|
||||
|
||||
public void startUploading() {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(myProject, JavaGoogleAppEngineBundle
|
||||
.message("progress.title.uploading.application"), true, null) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
compileAndUpload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void compileAndUpload() {
|
||||
final Runnable startUploading = () -> ApplicationManager.getApplication().invokeLater(() -> startUploadingProcess());
|
||||
|
||||
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
|
||||
final CompileScope moduleScope = compilerManager.createModuleCompileScope(myAppEngineFacet.getModule(), true);
|
||||
final CompileScope compileScope = ArtifactCompileScope.createScopeWithArtifacts(moduleScope, Collections.singletonList(myArtifact));
|
||||
ApplicationManager.getApplication().invokeLater(() -> compilerManager.make(compileScope, new CompileStatusNotification() {
|
||||
@Override
|
||||
public void finished(boolean aborted, int errors, int warnings, @NotNull CompileContext compileContext) {
|
||||
if (!aborted && errors == 0) {
|
||||
startUploading.run();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void startUploadingProcess() {
|
||||
|
||||
final ProcessHandler processHandler;
|
||||
try {
|
||||
JavaParameters parameters = new JavaParameters();
|
||||
parameters.configureByModule(myAppEngineFacet.getModule(), JavaParameters.JDK_ONLY);
|
||||
parameters.setMainClass("com.google.appengine.tools.admin.AppCfg");
|
||||
parameters.getClassPath().add(mySdk.getToolsApiJarFile().getAbsolutePath());
|
||||
|
||||
HttpConfigurable.getInstance().getJvmProperties(false, null).forEach(p -> parameters.getVMParametersList().addProperty(p.first, p.second));
|
||||
|
||||
final ParametersList programParameters = parameters.getProgramParametersList();
|
||||
if (myAuthData.isOAuth2()) {
|
||||
programParameters.add("--oauth2");
|
||||
}
|
||||
else {
|
||||
programParameters.add("--email=" + myAuthData.getEmail());
|
||||
programParameters.add("--passin");
|
||||
programParameters.add("--no_cookies");
|
||||
}
|
||||
programParameters.add("update");
|
||||
programParameters.add(FileUtil.toSystemDependentName(myArtifact.getOutputPath()));
|
||||
|
||||
final GeneralCommandLine commandLine = parameters.toCommandLine();
|
||||
processHandler = new OSProcessHandler(commandLine);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
myCallback.errorOccurred(JavaGoogleAppEngineBundle.message("message.cannot.start.uploading.0", e.getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
processHandler.addProcessListener(new MyProcessListener(processHandler, null, myLoggingHandler));
|
||||
myLoggingHandler.attachToProcess(processHandler);
|
||||
processHandler.startNotify();
|
||||
}
|
||||
|
||||
private class MyProcessListener extends ProcessAdapter {
|
||||
private boolean myPasswordEntered;
|
||||
private final ProcessHandler myProcessHandler;
|
||||
@Nullable private final ConsoleView myConsole;
|
||||
@Nullable private final LoggingHandler myLoggingHandler;
|
||||
|
||||
MyProcessListener(ProcessHandler processHandler, @Nullable ConsoleView console, @Nullable LoggingHandler loggingHandler) {
|
||||
myProcessHandler = processHandler;
|
||||
myConsole = console;
|
||||
myLoggingHandler = loggingHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
|
||||
if (!myAuthData.isOAuth2() && !myPasswordEntered && !outputType.equals(ProcessOutputTypes.SYSTEM) && event.getText().contains(myAuthData.getEmail())) {
|
||||
myPasswordEntered = true;
|
||||
final OutputStream processInput = myProcessHandler.getProcessInput();
|
||||
if (processInput != null) {
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
final PrintWriter input = new PrintWriter(processInput);
|
||||
input.println(myAuthData.getPassword());
|
||||
input.flush();
|
||||
String message = StringUtil.repeatSymbol('*', myAuthData.getPassword().length()) + "\n";
|
||||
if (myConsole != null) {
|
||||
myConsole.print(message, ConsoleViewContentType.USER_INPUT);
|
||||
}
|
||||
else if (myLoggingHandler != null) {
|
||||
myLoggingHandler.print(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTerminated(@NotNull ProcessEvent event) {
|
||||
int exitCode = event.getExitCode();
|
||||
if (exitCode == 0) {
|
||||
myCallback.succeeded(new DeploymentRuntime() {
|
||||
@Override
|
||||
public boolean isUndeploySupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undeploy(@NotNull UndeploymentTaskCallback callback) {
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
myCallback.errorOccurred(JavaGoogleAppEngineBundle.message("error.process.terminated.with.exit.code.0", exitCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.actions;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.appengine.cloud.AppEngineCloudType;
|
||||
import com.intellij.appengine.cloud.AppEngineServerConfiguration;
|
||||
import com.intellij.appengine.facet.AppEngineFacet;
|
||||
import com.intellij.execution.ProgramRunnerUtil;
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.executors.DefaultRunExecutor;
|
||||
import com.intellij.facet.ProjectFacetManager;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.configuration.RemoteServersManager;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfigurationManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UploadApplicationAction extends AnAction {
|
||||
public static final String LAST_RUN_CONFIGURATION_PROPERTY = "JAVA_APP_ENGINE_LAST_RUN_CONFIGURATION";
|
||||
|
||||
@Override
|
||||
public @NotNull ActionUpdateThread getActionUpdateThread() {
|
||||
return ActionUpdateThread.BGT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
final Project project = e.getProject();
|
||||
e.getPresentation().setEnabledAndVisible(project != null &&
|
||||
ProjectFacetManager.getInstance(project).hasFacets(AppEngineFacet.ID));
|
||||
|
||||
if (project != null) {
|
||||
String text;
|
||||
RunnerAndConfigurationSettings configurationToRun = getConfigurationToRun(project);
|
||||
if (configurationToRun == null) {
|
||||
text = getTemplatePresentation().getText();
|
||||
}
|
||||
else {
|
||||
text = JavaGoogleAppEngineBundle.message("action.upload.app.engine.application.text", configurationToRun.getName());
|
||||
}
|
||||
e.getPresentation().setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static RunnerAndConfigurationSettings getConfigurationToRun(@NotNull Project project) {
|
||||
List<RunnerAndConfigurationSettings> configurations =
|
||||
DeploymentConfigurationManager.getInstance(project).getDeploymentConfigurations(AppEngineCloudType.getInstance());
|
||||
String lastName = PropertiesComponent.getInstance(project).getValue(LAST_RUN_CONFIGURATION_PROPERTY);
|
||||
if (lastName != null) {
|
||||
for (RunnerAndConfigurationSettings configuration : configurations) {
|
||||
if (configuration.getName().equals(lastName)) {
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ContainerUtil.getFirstItem(configurations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
|
||||
RunnerAndConfigurationSettings configurationToRun = getConfigurationToRun(project);
|
||||
if (configurationToRun != null) {
|
||||
ProgramRunnerUtil.executeConfiguration(configurationToRun, DefaultRunExecutor.getRunExecutorInstance());
|
||||
}
|
||||
else {
|
||||
AppEngineCloudType serverType = AppEngineCloudType.getInstance();
|
||||
List<RemoteServer<AppEngineServerConfiguration>> servers = RemoteServersManager.getInstance().getServers(serverType);
|
||||
DeploymentConfigurationManager.getInstance(project).createAndRunConfiguration(serverType,
|
||||
ContainerUtil.getFirstItem(servers),
|
||||
null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.cloud;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class AppEngineAuthData {
|
||||
private final boolean myOAuth2;
|
||||
private final String myEmail;
|
||||
private final String myPassword;
|
||||
|
||||
@NotNull
|
||||
public static AppEngineAuthData oauth2() {
|
||||
return new AppEngineAuthData(true, null, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AppEngineAuthData login(@NotNull String email, @NotNull String password) {
|
||||
return new AppEngineAuthData(false, email, password);
|
||||
}
|
||||
|
||||
private AppEngineAuthData(boolean OAuth2, String email, String password) {
|
||||
myOAuth2 = OAuth2;
|
||||
myEmail = email;
|
||||
myPassword = password;
|
||||
}
|
||||
|
||||
public boolean isOAuth2() {
|
||||
return myOAuth2;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return myEmail;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return myPassword;
|
||||
}
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.appengine.cloud.AppEngineCloudConfigurable">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="c25a8" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="ad0b0"/>
|
||||
<text resource-bundle="messages/JavaGoogleAppEngineBundle" key="cloud.config.form.email.label.text"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c19df" class="javax.swing.JTextField" binding="myEmailField">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<enabled value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6daeb" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="eebf6"/>
|
||||
<text resource-bundle="messages/JavaGoogleAppEngineBundle" key="cloud.config.form.password.label.text"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6bca0" class="com.intellij.ui.components.JBPasswordField" binding="myPasswordField">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="dad3a" class="com.intellij.ui.components.JBRadioButton" binding="myPasswordLoginButton">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaGoogleAppEngineBundle" key="cloud.config.form.email.and.password.radio.text"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a079" class="com.intellij.ui.components.JBRadioButton" binding="myOAuthLoginButton">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text resource-bundle="messages/JavaGoogleAppEngineBundle" key="cloud.config.form.oauth2.radio.text"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="d3a86">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="e48d1" class="javax.swing.JCheckBox" binding="myRememberPasswordCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaGoogleAppEngineBundle" key="cloud.config.form.remember.password.checkbox.text"/>
|
||||
<visible value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<buttonGroups>
|
||||
<group name="myGroup1">
|
||||
<member id="a079"/>
|
||||
<member id="dad3a"/>
|
||||
</group>
|
||||
</buttonGroups>
|
||||
</form>
|
||||
-165
@@ -1,165 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.cloud;
|
||||
|
||||
import com.intellij.appengine.facet.AppEngineAccountDialog;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.remoteServer.RemoteServerConfigurable;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.components.JBPasswordField;
|
||||
import com.intellij.ui.components.JBRadioButton;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class AppEngineCloudConfigurable extends RemoteServerConfigurable implements Configurable {
|
||||
public static final String EMAIL_KEY = "GOOGLE_APP_ENGINE_ACCOUNT_EMAIL";
|
||||
private final AppEngineServerConfiguration myConfiguration;
|
||||
@Nullable private final Project myProject;
|
||||
private JTextField myEmailField;
|
||||
private JBPasswordField myPasswordField;
|
||||
private JBRadioButton myPasswordLoginButton;
|
||||
private JBRadioButton myOAuthLoginButton;
|
||||
private JPanel myMainPanel;
|
||||
private JCheckBox myRememberPasswordCheckBox;
|
||||
private final boolean myAlwaysRememberPassword;
|
||||
|
||||
public AppEngineCloudConfigurable(@NotNull AppEngineServerConfiguration configuration,
|
||||
@Nullable Project project, boolean alwaysRememberPassword) {
|
||||
myConfiguration = configuration;
|
||||
myProject = project;
|
||||
ActionListener actionListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
updateControls();
|
||||
}
|
||||
};
|
||||
myPasswordLoginButton.addActionListener(actionListener);
|
||||
myOAuthLoginButton.addActionListener(actionListener);
|
||||
DocumentListener documentListener = new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(@NotNull DocumentEvent e) {
|
||||
updateControls();
|
||||
}
|
||||
};
|
||||
myEmailField.getDocument().addDocumentListener(documentListener);
|
||||
myPasswordField.getDocument().addDocumentListener(documentListener);
|
||||
myAlwaysRememberPassword = alwaysRememberPassword;
|
||||
updateControls();
|
||||
}
|
||||
|
||||
private void updateControls() {
|
||||
boolean passwordLogin = myPasswordLoginButton.isSelected();
|
||||
myEmailField.setEnabled(passwordLogin);
|
||||
myPasswordField.setEnabled(passwordLogin);
|
||||
myRememberPasswordCheckBox.setEnabled(passwordLogin);
|
||||
if (passwordLogin && myAlwaysRememberPassword && !getPassword().isEmpty()) {
|
||||
myRememberPasswordCheckBox.setSelected(true);
|
||||
myRememberPasswordCheckBox.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return StringUtil.nullize(myEmailField.getText(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCheckConnection() {
|
||||
//currently our App Engine implementation actually doesn't connect to the cloud so it makes no sense to show connection status in 'Settings'
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return IdeBundle.message("configurable.AppEngineCloudConfigurable.display.name");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
String email = myConfiguration.getEmail();
|
||||
if (email == null) {
|
||||
email = getOldEmail();
|
||||
}
|
||||
myEmailField.setText(StringUtil.notNullize(email));
|
||||
if (myConfiguration.isOAuth2()) {
|
||||
myOAuthLoginButton.setSelected(true);
|
||||
}
|
||||
else {
|
||||
myPasswordLoginButton.setSelected(true);
|
||||
}
|
||||
myRememberPasswordCheckBox.setSelected(myConfiguration.isPasswordStored());
|
||||
myPasswordField.setPasswordIsStored(myConfiguration.isPasswordStored());
|
||||
updateControls();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getOldEmail() {
|
||||
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
String value = PropertiesComponent.getInstance(project).getValue(EMAIL_KEY);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void removeOldEmail(@NotNull String email) {
|
||||
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
String value = PropertiesComponent.getInstance(project).getValue(EMAIL_KEY);
|
||||
if (email.equals(value)) {
|
||||
PropertiesComponent.getInstance(project).unsetValue(EMAIL_KEY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
String email = getEmail();
|
||||
if (email != null) {
|
||||
removeOldEmail(email);
|
||||
}
|
||||
myConfiguration.setEmail(email);
|
||||
myConfiguration.setOAuth2(isOAuth2());
|
||||
String password = getPassword();
|
||||
if (myRememberPasswordCheckBox.isSelected() && !StringUtil.isEmpty(email) && !password.isEmpty()) {
|
||||
AppEngineAccountDialog.storePassword(email, password);
|
||||
myConfiguration.setPasswordStored(true);
|
||||
}
|
||||
else {
|
||||
myConfiguration.setPasswordStored(false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOAuth2() {
|
||||
return myOAuthLoginButton.isSelected();
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return new String(myPasswordField.getPassword());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return !Comparing.strEqual(getEmail(), myConfiguration.getEmail()) || myConfiguration.isOAuth2() != isOAuth2()
|
||||
|| myRememberPasswordCheckBox.isSelected() != myConfiguration.isPasswordStored()
|
||||
|| myRememberPasswordCheckBox.isSelected() && !getPassword().isEmpty();
|
||||
}
|
||||
}
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.cloud;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.appengine.actions.AppEngineUploader;
|
||||
import com.intellij.appengine.util.AppEngineUtil;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.remoteServer.RemoteServerConfigurable;
|
||||
import com.intellij.remoteServer.ServerType;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.remoteServer.configuration.deployment.*;
|
||||
import com.intellij.remoteServer.runtime.ServerConnector;
|
||||
import com.intellij.remoteServer.runtime.ServerTaskExecutor;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager;
|
||||
import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
|
||||
import com.intellij.remoteServer.runtime.deployment.ServerRuntimeInstance;
|
||||
import icons.GoogleAppEngineIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
public class AppEngineCloudType extends ServerType<AppEngineServerConfiguration> {
|
||||
public static AppEngineCloudType getInstance() {
|
||||
return EP_NAME.findExtension(AppEngineCloudType.class);
|
||||
}
|
||||
|
||||
public AppEngineCloudType() {
|
||||
super("google-app-engine");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return JavaGoogleAppEngineBundle.message("plugin.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getDeploymentConfigurationFactoryId() {
|
||||
return "Google App Engine Deployment";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return GoogleAppEngineIcons.AppEngine;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AppEngineServerConfiguration createDefaultConfiguration() {
|
||||
return new AppEngineServerConfiguration();
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public RemoteServerConfigurable createServerConfigurable(@NotNull AppEngineServerConfiguration configuration) {
|
||||
return new AppEngineCloudConfigurable(configuration, null, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ServerConnector<?> createConnector(@NotNull AppEngineServerConfiguration configuration,
|
||||
@NotNull ServerTaskExecutor asyncTasksExecutor) {
|
||||
return new AppEngineServerConnector(configuration);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AppEngineDeploymentConfigurator createDeploymentConfigurator(Project project) {
|
||||
return new AppEngineDeploymentConfigurator(project);
|
||||
}
|
||||
|
||||
private static class AppEngineDeploymentConfigurator extends DeploymentConfigurator<DummyDeploymentConfiguration, AppEngineServerConfiguration> {
|
||||
private final Project myProject;
|
||||
|
||||
AppEngineDeploymentConfigurator(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<DeploymentSource> getAvailableDeploymentSources() {
|
||||
List<Artifact> artifacts = AppEngineUtil.collectAppEngineArtifacts(myProject, true);
|
||||
return JavaDeploymentSourceUtil.getInstance().createArtifactDeploymentSources(myProject, artifacts);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DummyDeploymentConfiguration createDefaultConfiguration(@NotNull DeploymentSource source) {
|
||||
return new DummyDeploymentConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsEditor<DummyDeploymentConfiguration> createEditor(@NotNull DeploymentSource source,
|
||||
@Nullable RemoteServer<AppEngineServerConfiguration> server) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class AppEngineServerConnector extends ServerConnector<DummyDeploymentConfiguration> {
|
||||
private final AppEngineServerConfiguration myConfiguration;
|
||||
|
||||
AppEngineServerConnector(AppEngineServerConfiguration configuration) {
|
||||
myConfiguration = configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(@NotNull final ConnectionCallback<DummyDeploymentConfiguration> callback) {
|
||||
callback.connected(new AppEngineRuntimeInstance(myConfiguration));
|
||||
}
|
||||
}
|
||||
|
||||
private static class AppEngineRuntimeInstance extends ServerRuntimeInstance<DummyDeploymentConfiguration> {
|
||||
private final AppEngineServerConfiguration myConfiguration;
|
||||
|
||||
AppEngineRuntimeInstance(AppEngineServerConfiguration configuration) {
|
||||
myConfiguration = configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deploy(@NotNull DeploymentTask<DummyDeploymentConfiguration> task, @NotNull DeploymentLogManager logManager,
|
||||
@NotNull DeploymentOperationCallback callback) {
|
||||
Artifact artifact = ((ArtifactDeploymentSource)task.getSource()).getArtifact();
|
||||
if (artifact == null) return;
|
||||
|
||||
AppEngineUploader uploader = AppEngineUploader.createUploader(task.getProject(), artifact, myConfiguration, callback,
|
||||
logManager.getMainLoggingHandler());
|
||||
if (uploader != null) {
|
||||
uploader.startUploading();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void computeDeployments(@NotNull ComputeDeploymentsCallback callback) {
|
||||
callback.succeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
}
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.cloud;
|
||||
|
||||
import com.intellij.remoteServer.configuration.ServerConfigurationBase;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
|
||||
public class AppEngineServerConfiguration extends ServerConfigurationBase<AppEngineServerConfiguration> {
|
||||
private String myEmail;
|
||||
private boolean myOAuth2;
|
||||
private boolean myPasswordStored;
|
||||
|
||||
@Attribute("email")
|
||||
public String getEmail() {
|
||||
return myEmail;
|
||||
}
|
||||
|
||||
@Attribute("oauth2")
|
||||
public boolean isOAuth2() {
|
||||
return myOAuth2;
|
||||
}
|
||||
|
||||
@Attribute("password-stored")
|
||||
public boolean isPasswordStored() {
|
||||
return myPasswordStored;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
myEmail = email;
|
||||
}
|
||||
|
||||
public void setOAuth2(boolean OAuth2) {
|
||||
myOAuth2 = OAuth2;
|
||||
}
|
||||
|
||||
public void setPasswordStored(boolean passwordStored) {
|
||||
myPasswordStored = passwordStored;
|
||||
}
|
||||
}
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.converter;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.appengine.facet.AppEngineFacetType;
|
||||
import com.intellij.conversion.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.serialization.facet.JpsFacetSerializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
final class AppEngineFacetConverterProvider extends ConverterProvider {
|
||||
AppEngineFacetConverterProvider() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectConverter createConverter(@NotNull ConversionContext context) {
|
||||
return new ProjectConverter() {
|
||||
@NotNull
|
||||
@Override
|
||||
public ConversionProcessor<ModuleSettings> createModuleFileConverter() {
|
||||
return new GoogleAppEngineFacetConversionProcessor();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getConversionDescription() {
|
||||
return JavaGoogleAppEngineBundle.message("dialog.message.google.app.engine.description");
|
||||
}
|
||||
|
||||
private static class GoogleAppEngineFacetConversionProcessor extends ConversionProcessor<ModuleSettings> {
|
||||
@Override
|
||||
public boolean isConversionNeeded(ModuleSettings settings) {
|
||||
return !getAppEngineFacetTags(settings).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ModuleSettings settings) {
|
||||
List<Element> facetTags = getAppEngineFacetTags(settings);
|
||||
for (Element tag : facetTags) {
|
||||
tag.detach();
|
||||
}
|
||||
Element facetTag = ContainerUtil.getFirstItem(facetTags);
|
||||
if (facetTag != null) {
|
||||
String facetName = facetTag.getAttributeValue(JpsFacetSerializer.NAME_ATTRIBUTE);
|
||||
Element configuration = facetTag.getChild(JpsFacetSerializer.CONFIGURATION_TAG);
|
||||
settings.addFacetElement(AppEngineFacetType.STRING_ID, facetName, configuration.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Element> getAppEngineFacetTags(@NotNull ModuleSettings settings) {
|
||||
List<Element> appEngineFacetTags = new ArrayList<>();
|
||||
for (Element webFacetTag : settings.getFacetElements("web")) {
|
||||
for (Element childFacetTag : webFacetTag.getChildren(JpsFacetSerializer.FACET_TAG)) {
|
||||
if (AppEngineFacetType.STRING_ID.equals(childFacetTag.getAttributeValue(JpsFacetSerializer.TYPE_ATTRIBUTE))) {
|
||||
appEngineFacetTags.add(childFacetTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return appEngineFacetTags;
|
||||
}
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.converter;
|
||||
|
||||
import com.intellij.ide.plugins.PluginReplacement;
|
||||
|
||||
public class AppEnginePluginReplacement extends PluginReplacement {
|
||||
public AppEnginePluginReplacement() {
|
||||
super("com.google.gct.core");
|
||||
}
|
||||
}
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.appengine.converter;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.appengine.facet.AppEngineFacet;
|
||||
import com.intellij.facet.ProjectFacetManager;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
|
||||
public class MigrateToCloudToolsNotification implements StartupActivity.DumbAware {
|
||||
@Override
|
||||
public void runActivity(@NotNull Project project) {
|
||||
boolean hasFacets = ReadAction.compute(() -> ProjectFacetManager.getInstance(project).hasFacets(AppEngineFacet.ID));
|
||||
if (hasFacets && isAppEngineSdkDeprecated()) {
|
||||
String text = JavaGoogleAppEngineBundle.message("migrate.to.google.cloud.notification.text");
|
||||
Notification notification = new Notification("Migrate to Google Cloud SDK",
|
||||
JavaGoogleAppEngineBundle.message("notification.title.app.engine.sdk.detected"),
|
||||
text, NotificationType.WARNING)
|
||||
.setSuggestionType(true)
|
||||
.setListener(new NotificationListener.UrlOpeningListener(false));
|
||||
/*
|
||||
//currently Google Cloud Tools plugin doesn't provide seamless migration for all project, so we don't want to provide a direct link which installs it.
|
||||
notification.addAction(new AnAction("Install 'Google Cloud Tools' plugin") {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
PluginsAdvertiser.installAndEnablePlugins(ContainerUtil.set("com.google.gct.core", "com.google.gct.login"),
|
||||
() -> {
|
||||
notification.expire();
|
||||
PluginManagerCore.disablePlugin("com.intellij.appengine");
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
notification.notify(project);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAppEngineSdkDeprecated() {
|
||||
return SystemProperties.getBooleanProperty("idea.enable.migration.to.google.cloud.sdk", LocalDate.now().isAfter(LocalDate.of(2017, Month.MAY, 5)));
|
||||
}
|
||||
}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.descriptor;
|
||||
|
||||
import com.intellij.appengine.facet.AppEngineFacet;
|
||||
import com.intellij.appengine.util.AppEngineUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xml.XmlSchemaProvider;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
public class AppEngineWebSchemaProvider extends XmlSchemaProvider {
|
||||
private static final Set<String> FILE_NAMES = ContainerUtil.set(AppEngineUtil.APP_ENGINE_WEB_XML_NAME,
|
||||
AppEngineUtil.APP_ENGINE_APPLICATION_XML_NAME,
|
||||
AppEngineUtil.JDO_CONFIG_XML_NAME);
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull XmlFile file) {
|
||||
if (!FILE_NAMES.contains(file.getName())) {
|
||||
return false;
|
||||
}
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
|
||||
return AppEngineFacet.getAppEngineFacetByModule(module) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlFile getSchema(@NotNull @NonNls String url, @Nullable Module module, @NotNull PsiFile baseFile) {
|
||||
if (module == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (url.startsWith("http://appengine.google.com/ns/")) {
|
||||
AppEngineFacet facet = AppEngineFacet.getAppEngineFacetByModule(module);
|
||||
if (facet != null) {
|
||||
final File file;
|
||||
if (isApplicationXmlFile(baseFile)) {
|
||||
file = facet.getSdk().getApplicationSchemeFile();
|
||||
}
|
||||
else {
|
||||
file = facet.getSdk().getWebSchemeFile();
|
||||
}
|
||||
final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
|
||||
if (virtualFile != null) {
|
||||
final PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(virtualFile);
|
||||
if (psiFile instanceof XmlFile) {
|
||||
return (XmlFile)psiFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (url.startsWith("http://java.sun.com/xml/ns/jdo/jdoconfig")) {
|
||||
final PsiPackage jdoPackage = JavaPsiFacade.getInstance(module.getProject()).findPackage("javax.jdo");
|
||||
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
|
||||
if (jdoPackage != null) {
|
||||
for (PsiDirectory directory : jdoPackage.getDirectories(scope)) {
|
||||
final PsiFile file = directory.findFile("jdoconfig_2_3.xsd");
|
||||
if (file instanceof XmlFile) {
|
||||
return (XmlFile)file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isApplicationXmlFile(PsiFile baseFile) {
|
||||
if (!(baseFile instanceof XmlFile)) return false;
|
||||
|
||||
XmlTag rootTag = ((XmlFile)baseFile).getRootTag();
|
||||
return rootTag != null && rootTag.getName().equals("appengine-application");
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.descriptor.dom;
|
||||
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.GenericDomValue;
|
||||
|
||||
public interface AppEngineWebApp extends DomElement {
|
||||
GenericDomValue<String> getApplication();
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.descriptor.dom;
|
||||
|
||||
import com.intellij.appengine.util.AppEngineUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.util.xml.DomFileDescription;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AppEngineWebFileDescription extends DomFileDescription<AppEngineWebApp> {
|
||||
public AppEngineWebFileDescription() {
|
||||
super(AppEngineWebApp.class, "appengine-web-app");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMyFile(@NotNull XmlFile file, @Nullable Module module) {
|
||||
return file.getName().equals(AppEngineUtil.APP_ENGINE_WEB_XML_NAME);
|
||||
}
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.cloud.AppEngineAuthData;
|
||||
import com.intellij.appengine.cloud.AppEngineCloudConfigurable;
|
||||
import com.intellij.appengine.cloud.AppEngineServerConfiguration;
|
||||
import com.intellij.credentialStore.CredentialAttributesKt;
|
||||
import com.intellij.credentialStore.Credentials;
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.intellij.credentialStore.CredentialAttributesKt.CredentialAttributes;
|
||||
|
||||
public final class AppEngineAccountDialog {
|
||||
private static final String PASSWORD_KEY = "GOOGLE_APP_ENGINE_PASSWORD";
|
||||
|
||||
@Nullable
|
||||
public static AppEngineAuthData createAuthData(@NotNull Project project, @NotNull AppEngineServerConfiguration configuration) {
|
||||
if (configuration.isOAuth2()) {
|
||||
return AppEngineAuthData.oauth2();
|
||||
}
|
||||
|
||||
String email = configuration.getEmail();
|
||||
if (!StringUtil.isEmpty(email) && configuration.isPasswordStored()) {
|
||||
String password = getStoredPassword(email);
|
||||
if (!StringUtil.isEmpty(password)) {
|
||||
return AppEngineAuthData.login(email, password);
|
||||
}
|
||||
}
|
||||
|
||||
AppEngineCloudConfigurable configurable = new AppEngineCloudConfigurable(configuration, project, false);
|
||||
boolean ok = ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
|
||||
if (!ok) {
|
||||
return null;
|
||||
}
|
||||
if (configurable.isOAuth2()) {
|
||||
return AppEngineAuthData.oauth2();
|
||||
}
|
||||
return AppEngineAuthData.login(configurable.getEmail(), configurable.getPassword());
|
||||
}
|
||||
|
||||
public static void storePassword(@NotNull String email, @NotNull String password) {
|
||||
String accountName = getPasswordKey(email);
|
||||
PasswordSafe.getInstance().set(CredentialAttributes(AppEngineAccountDialog.class, accountName), new Credentials(accountName, password));
|
||||
}
|
||||
|
||||
private static String getPasswordKey(String email) {
|
||||
return PASSWORD_KEY + "_" + email;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getStoredPassword(String email) {
|
||||
if (StringUtil.isEmpty(email)) {
|
||||
return null;
|
||||
}
|
||||
return PasswordSafe.getInstance().getPassword(CredentialAttributesKt.CredentialAttributes(AppEngineAccountDialog.class, getPasswordKey(email)));
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.descriptor.dom.AppEngineWebApp;
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.appengine.sdk.AppEngineSdkManager;
|
||||
import com.intellij.facet.*;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.DomFileElement;
|
||||
import com.intellij.util.xml.DomManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AppEngineFacet extends Facet<AppEngineFacetConfiguration> {
|
||||
public static final FacetTypeId<AppEngineFacet> ID = new FacetTypeId<>("appEngine");
|
||||
|
||||
public AppEngineFacet(@NotNull FacetType facetType,
|
||||
@NotNull Module module,
|
||||
@NotNull String name,
|
||||
@NotNull AppEngineFacetConfiguration configuration) {
|
||||
super(facetType, module, name, configuration, null);
|
||||
}
|
||||
|
||||
public static FacetType<AppEngineFacet, AppEngineFacetConfiguration> getFacetType() {
|
||||
return FacetTypeRegistry.getInstance().findFacetType(ID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AppEngineFacet getAppEngineFacetByModule(@Nullable Module module) {
|
||||
if (module == null) return null;
|
||||
return FacetManager.getInstance(module).getFacetByType(ID);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public AppEngineSdk getSdk() {
|
||||
return AppEngineSdkManager.getInstance().findSdk(getConfiguration().getSdkHomePath());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AppEngineWebApp getDescriptorRoot(@Nullable VirtualFile descriptorFile, @NotNull final Project project) {
|
||||
if (descriptorFile == null) return null;
|
||||
|
||||
Module module = ModuleUtilCore.findModuleForFile(descriptorFile, project);
|
||||
if (module == null) return null;
|
||||
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(descriptorFile);
|
||||
if (psiFile == null) return null;
|
||||
|
||||
return getRootElement(psiFile, AppEngineWebApp.class, module);
|
||||
}
|
||||
|
||||
//todo[nik] copied from JamCommonUtil
|
||||
@Nullable
|
||||
private static <T> T getRootElement(final PsiFile file, final Class<T> domClass, final Module module) {
|
||||
if (!(file instanceof XmlFile)) return null;
|
||||
final DomManager domManager = DomManager.getDomManager(file.getProject());
|
||||
final DomFileElement<DomElement> element = domManager.getFileElement((XmlFile)file, DomElement.class);
|
||||
if (element == null) return null;
|
||||
final DomElement root = element.getRootElement();
|
||||
if (!ReflectionUtil.isAssignable(domClass, root.getClass())) return null;
|
||||
return (T)root;
|
||||
}
|
||||
|
||||
|
||||
public boolean shouldRunEnhancerFor(@NotNull VirtualFile file) {
|
||||
for (String path : getConfiguration().getFilesToEnhance()) {
|
||||
final VirtualFile toEnhance = LocalFileSystem.getInstance().findFileByPath(path);
|
||||
if (toEnhance != null && VfsUtilCore.isAncestor(toEnhance, file, false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.facet.FacetConfiguration;
|
||||
import com.intellij.facet.ui.FacetEditorContext;
|
||||
import com.intellij.facet.ui.FacetEditorTab;
|
||||
import com.intellij.facet.ui.FacetValidatorsManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.appengine.model.PersistenceApi;
|
||||
import org.jetbrains.jps.appengine.model.impl.AppEngineModuleExtensionProperties;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AppEngineFacetConfiguration implements FacetConfiguration, PersistentStateComponent<AppEngineModuleExtensionProperties> {
|
||||
private AppEngineModuleExtensionProperties myProperties = new AppEngineModuleExtensionProperties();
|
||||
|
||||
@Override
|
||||
public FacetEditorTab[] createEditorTabs(FacetEditorContext editorContext, FacetValidatorsManager validatorsManager) {
|
||||
return new FacetEditorTab[] {
|
||||
new AppEngineFacetEditor(this, editorContext, validatorsManager)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngineModuleExtensionProperties getState() {
|
||||
return myProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(@NotNull AppEngineModuleExtensionProperties state) {
|
||||
myProperties = state;
|
||||
}
|
||||
|
||||
public String getSdkHomePath() {
|
||||
return myProperties.mySdkHomePath;
|
||||
}
|
||||
|
||||
public boolean isRunEnhancerOnMake() {
|
||||
return myProperties.myRunEnhancerOnMake;
|
||||
}
|
||||
|
||||
public List<String> getFilesToEnhance() {
|
||||
return myProperties.myFilesToEnhance;
|
||||
}
|
||||
|
||||
public PersistenceApi getPersistenceApi() {
|
||||
return myProperties.myPersistenceApi;
|
||||
}
|
||||
|
||||
public void setSdkHomePath(String sdkHomePath) {
|
||||
myProperties.mySdkHomePath = sdkHomePath;
|
||||
}
|
||||
|
||||
public void setPersistenceApi(PersistenceApi persistenceApi) {
|
||||
myProperties.myPersistenceApi = persistenceApi;
|
||||
}
|
||||
|
||||
public void setFilesToEnhance(List<String> filesToEnhance) {
|
||||
myProperties.myFilesToEnhance = filesToEnhance;
|
||||
}
|
||||
|
||||
public void setRunEnhancerOnMake(boolean runEnhancerOnMake) {
|
||||
myProperties.myRunEnhancerOnMake = runEnhancerOnMake;
|
||||
}
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.appengine.facet.AppEngineFacetEditor">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="795a6" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaGoogleAppEngineBundle" key="facet.editor.form.path.to.sdk.label.text"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="e3c2c">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="51af7" binding="mySdkEditorPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="5bbab" class="javax.swing.JCheckBox" binding="myRunEnhancerOnMakeCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaGoogleAppEngineBundle" key="facet.editor.form.run.enhancer.on.make.checkbox.text"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="58aa7" binding="myFilesToEnhancePanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="1" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="f7d21" binding="myFilesPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="8354a" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="47a19" class="javax.swing.JComboBox" binding="myPersistenceApiComboBox">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<model/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e1e60" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaGoogleAppEngineBundle" key="facet.editor.form.persistence.label.text"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
-178
@@ -1,178 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.sdk.impl.AppEngineSdkUtil;
|
||||
import com.intellij.appengine.util.AppEngineUtil;
|
||||
import com.intellij.facet.Facet;
|
||||
import com.intellij.facet.ui.*;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.presentation.VirtualFilePresentation;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.roots.ModuleRootModel;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AppEngineFacetEditor extends FacetEditorTab {
|
||||
private final AppEngineFacetConfiguration myFacetConfiguration;
|
||||
private final FacetEditorContext myContext;
|
||||
private JPanel myMainPanel;
|
||||
private JPanel mySdkEditorPanel;
|
||||
private JCheckBox myRunEnhancerOnMakeCheckBox;
|
||||
private JPanel myFilesToEnhancePanel;
|
||||
private final JList<String> myFilesList;
|
||||
private JComboBox<String> myPersistenceApiComboBox;
|
||||
private JPanel myFilesPanel;
|
||||
private final AppEngineSdkEditor mySdkEditor;
|
||||
private final DefaultListModel<@NlsSafe String> myFilesListModel;
|
||||
|
||||
public AppEngineFacetEditor(AppEngineFacetConfiguration facetConfiguration, FacetEditorContext context, FacetValidatorsManager validatorsManager) {
|
||||
myFacetConfiguration = facetConfiguration;
|
||||
myContext = context;
|
||||
mySdkEditor = new AppEngineSdkEditor(myContext.getProject());
|
||||
validatorsManager.registerValidator(new FacetEditorValidator() {
|
||||
@NotNull
|
||||
@Override
|
||||
public ValidationResult check() {
|
||||
return AppEngineSdkUtil.checkPath(mySdkEditor.getPath());
|
||||
}
|
||||
}, mySdkEditor.getComboBox());
|
||||
|
||||
myRunEnhancerOnMakeCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
GuiUtils.enableChildren(myRunEnhancerOnMakeCheckBox.isSelected(), myFilesToEnhancePanel);
|
||||
if (myRunEnhancerOnMakeCheckBox.isSelected() && myFilesListModel.isEmpty()) {
|
||||
fillFilesList(AppEngineUtil.getDefaultSourceRootsToEnhance(myContext.getRootModel()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myFilesListModel = new DefaultListModel<>();
|
||||
myFilesList = new JBList<>(myFilesListModel);
|
||||
myFilesList.setCellRenderer(new FilesListCellRenderer());
|
||||
myFilesPanel.add(ToolbarDecorator.createDecorator(myFilesList)
|
||||
.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
doAdd();
|
||||
}
|
||||
}).disableUpDownActions().createPanel(), BorderLayout.CENTER);
|
||||
|
||||
PersistenceApiComboboxUtil.setComboboxModel(myPersistenceApiComboBox, false);
|
||||
}
|
||||
|
||||
private void doAdd() {
|
||||
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true);
|
||||
final ModuleRootModel rootModel = myContext.getRootModel();
|
||||
descriptor.setRoots(rootModel.getSourceRoots(JavaModuleSourceRootTypes.SOURCES));
|
||||
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myContext.getProject(), null);
|
||||
for (VirtualFile file : files) {
|
||||
myFilesListModel.addElement(file.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nls
|
||||
public String getDisplayName() {
|
||||
return IdeBundle.message("configurable.AppEngineFacetEditor.display.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JComponent createComponent() {
|
||||
mySdkEditorPanel.add(BorderLayout.CENTER, mySdkEditor.getMainComponent());
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return myRunEnhancerOnMakeCheckBox.isSelected() != myFacetConfiguration.isRunEnhancerOnMake()
|
||||
|| !mySdkEditor.getPath().equals(myFacetConfiguration.getSdkHomePath())
|
||||
|| !getConfiguredFiles().equals(myFacetConfiguration.getFilesToEnhance())
|
||||
|| PersistenceApiComboboxUtil.getSelectedApi(myPersistenceApiComboBox) != myFacetConfiguration.getPersistenceApi();
|
||||
}
|
||||
|
||||
private List<String> getConfiguredFiles() {
|
||||
final List<String> files = new ArrayList<>();
|
||||
for (int i = 0; i < myFilesListModel.getSize(); i++) {
|
||||
files.add(myFilesListModel.getElementAt(i));
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
myFacetConfiguration.setSdkHomePath(mySdkEditor.getPath());
|
||||
myFacetConfiguration.setRunEnhancerOnMake(myRunEnhancerOnMakeCheckBox.isSelected());
|
||||
myFacetConfiguration.setFilesToEnhance(getConfiguredFiles());
|
||||
myFacetConfiguration.setPersistenceApi(PersistenceApiComboboxUtil.getSelectedApi(myPersistenceApiComboBox));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
mySdkEditor.setPath(myFacetConfiguration.getSdkHomePath());
|
||||
if (myContext.isNewFacet() && myFacetConfiguration.getSdkHomePath().length() == 0) {
|
||||
mySdkEditor.setDefaultPath();
|
||||
}
|
||||
myFilesListModel.removeAllElements();
|
||||
fillFilesList(myFacetConfiguration.getFilesToEnhance());
|
||||
myRunEnhancerOnMakeCheckBox.setSelected(myFacetConfiguration.isRunEnhancerOnMake());
|
||||
myPersistenceApiComboBox.setSelectedItem(myFacetConfiguration.getPersistenceApi().getDisplayName());
|
||||
}
|
||||
|
||||
private void fillFilesList(final List<@NlsSafe String> paths) {
|
||||
for (@NlsSafe String path : paths) {
|
||||
myFilesListModel.addElement(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpTopic() {
|
||||
return "Google_App_Engine_Facet";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFacetInitialized(@NotNull Facet facet) {
|
||||
AppEngineWebIntegration.getInstance().setupDevServer(((AppEngineFacet)facet).getSdk());
|
||||
}
|
||||
|
||||
private final class FilesListCellRenderer extends DefaultListCellRenderer {
|
||||
private FilesListCellRenderer() {
|
||||
setUI(new RightAlignedLabelUI());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (value instanceof String) {
|
||||
final String path = (String)value;
|
||||
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
|
||||
if (file == null) {
|
||||
setForeground(JBColor.RED);
|
||||
setIcon(null);
|
||||
}
|
||||
else {
|
||||
setForeground(myFilesList.getForeground());
|
||||
setIcon(file.isDirectory() ? PlatformIcons.FOLDER_ICON : VirtualFilePresentation.getIcon(file));
|
||||
}
|
||||
setText(path);
|
||||
}
|
||||
return rendererComponent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.facet.Facet;
|
||||
import com.intellij.facet.FacetType;
|
||||
import com.intellij.openapi.module.JavaModuleType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import icons.GoogleAppEngineIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class AppEngineFacetType extends FacetType<AppEngineFacet, AppEngineFacetConfiguration> {
|
||||
public static final String STRING_ID = "google-app-engine";
|
||||
|
||||
public AppEngineFacetType() {
|
||||
super(AppEngineFacet.ID, STRING_ID, JavaGoogleAppEngineBundle.message("plugin.name"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngineFacetConfiguration createDefaultConfiguration() {
|
||||
return new AppEngineFacetConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngineFacet createFacet(@NotNull Module module,
|
||||
String name,
|
||||
@NotNull AppEngineFacetConfiguration configuration,
|
||||
@Nullable Facet underlyingFacet) {
|
||||
return new AppEngineFacet(this, module, name, configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuitableModuleType(ModuleType moduleType) {
|
||||
return moduleType instanceof JavaModuleType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDefaultFacetName() {
|
||||
return "Google App Engine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return GoogleAppEngineIcons.AppEngine;
|
||||
}
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.appengine.sdk.AppEngineSdkManager;
|
||||
import com.intellij.appengine.util.AppEngineUtil;
|
||||
import com.intellij.facet.FacetType;
|
||||
import com.intellij.framework.FrameworkType;
|
||||
import com.intellij.framework.detection.FacetBasedFrameworkDetector;
|
||||
import com.intellij.framework.detection.FileContentPattern;
|
||||
import com.intellij.ide.highlighter.XmlFileType;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.util.indexing.FileContent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AppEngineFrameworkDetector extends FacetBasedFrameworkDetector<AppEngineFacet, AppEngineFacetConfiguration> {
|
||||
public AppEngineFrameworkDetector() {
|
||||
super("appengine-java");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FacetType<AppEngineFacet, AppEngineFacetConfiguration> getFacetType() {
|
||||
return FacetType.findInstance(AppEngineFacetType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull FrameworkType getFrameworkType() {
|
||||
return AppEngineFrameworkType.getFrameworkType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupFacet(@NotNull AppEngineFacet facet, ModifiableRootModel model) {
|
||||
final List<? extends AppEngineSdk> sdks = AppEngineSdkManager.getInstance().getValidSdks();
|
||||
if (!sdks.isEmpty()) {
|
||||
facet.getConfiguration().setSdkHomePath(sdks.get(0).getSdkHomePath());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FileType getFileType() {
|
||||
return XmlFileType.INSTANCE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ElementPattern<FileContent> createSuitableFilePattern() {
|
||||
return FileContentPattern.fileContent().withName(AppEngineUtil.APP_ENGINE_WEB_XML_NAME).xmlWithRootTag("appengine-web-app");
|
||||
}
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.framework.FrameworkTypeEx;
|
||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
|
||||
import icons.GoogleAppEngineIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class AppEngineFrameworkType extends FrameworkTypeEx {
|
||||
public static final String ID = "appengine-java";
|
||||
|
||||
public AppEngineFrameworkType() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
static AppEngineFrameworkType getFrameworkType() {
|
||||
return EP_NAME.findExtension(AppEngineFrameworkType.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FrameworkSupportInModuleProvider createProvider() {
|
||||
return new AppEngineSupportProvider();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return JavaGoogleAppEngineBundle.message("plugin.name");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return GoogleAppEngineIcons.AppEngine;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.appengine.sdk.AppEngineSdkManager;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.openapi.ui.ComponentWithBrowseButton;
|
||||
import com.intellij.openapi.ui.TextComponentAccessor;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.ui.ComboboxWithBrowseButton;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class AppEngineSdkEditor {
|
||||
private final ComboboxWithBrowseButton myPathEditor;
|
||||
|
||||
public AppEngineSdkEditor(final @Nullable Project project) {
|
||||
myPathEditor = new ComboboxWithBrowseButton(new ComboBox(100));
|
||||
myPathEditor.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<>(
|
||||
JavaGoogleAppEngineBundle.message("sdk.browse.folder.action.title"),
|
||||
JavaGoogleAppEngineBundle.message("sdk.browse.folder.action.description"),
|
||||
myPathEditor, project, FileChooserDescriptorFactory.createSingleFolderDescriptor(), TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT));
|
||||
final JComboBox comboBox = myPathEditor.getComboBox();
|
||||
comboBox.setEditable(true);
|
||||
comboBox.removeAllItems();
|
||||
for (AppEngineSdk sdk : AppEngineSdkManager.getInstance().getValidSdks()) {
|
||||
comboBox.addItem(FileUtil.toSystemDependentName(sdk.getSdkHomePath()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public JPanel getMainComponent() {
|
||||
return myPathEditor;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return FileUtil.toSystemIndependentName((String)myPathEditor.getComboBox().getEditor().getItem());
|
||||
}
|
||||
|
||||
public void setPath(final String path) {
|
||||
myPathEditor.getComboBox().setSelectedItem(FileUtil.toSystemDependentName(path));
|
||||
}
|
||||
|
||||
public void setDefaultPath() {
|
||||
final JComboBox comboBox = myPathEditor.getComboBox();
|
||||
if (comboBox.getItemCount() > 0) {
|
||||
comboBox.setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
public JComboBox getComboBox() {
|
||||
return myPathEditor.getComboBox();
|
||||
}
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.appengine.facet.AppEngineSupportProvider.AppEngineSupportConfigurable">
|
||||
<grid id="7dca6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="88"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="27dc6" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<hspacer id="1969f">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="8525d" class="javax.swing.JComboBox" binding="myPersistenceApiComboBox">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<model/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9accf" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaGoogleAppEngineBundle" key="support.config.form.persistence.label.text"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="9fcfc" binding="mySdkPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="2bae7" binding="myErrorPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
-316
@@ -1,316 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.appengine.sdk.impl.AppEngineSdkUtil;
|
||||
import com.intellij.appengine.util.AppEngineUtil;
|
||||
import com.intellij.facet.FacetManager;
|
||||
import com.intellij.facet.FacetType;
|
||||
import com.intellij.facet.ui.ValidationResult;
|
||||
import com.intellij.framework.FrameworkTypeEx;
|
||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable;
|
||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel;
|
||||
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModelListener;
|
||||
import com.intellij.ide.util.frameworkSupport.FrameworkSupportProvider;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.JavaModuleType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModifiableModelsProvider;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.ui.configuration.FacetsProvider;
|
||||
import com.intellij.openapi.ui.LabeledComponent;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.packaging.elements.ArtifactRootElement;
|
||||
import com.intellij.packaging.elements.PackagingElementFactory;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.HyperlinkLabel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jps.appengine.model.PersistenceApi;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AppEngineSupportProvider extends FrameworkSupportInModuleProvider {
|
||||
private static final Logger LOG = Logger.getInstance(AppEngineSupportProvider.class);
|
||||
public static final String JPA_FRAMEWORK_ID = "facet:jpa";
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FrameworkTypeEx getFrameworkType() {
|
||||
return AppEngineFrameworkType.getFrameworkType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FrameworkDependency> getDependenciesFrameworkIds() {
|
||||
return AppEngineWebIntegration.getInstance().getAppEngineFrameworkDependencies();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForModuleBuilder(@NotNull ModuleBuilder builder) {
|
||||
return "LegacyJavaEE".equals(builder.getBuilderId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForModuleType(@NotNull ModuleType moduleType) {
|
||||
return moduleType instanceof JavaModuleType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupportAlreadyAdded(@NotNull Module module, @NotNull FacetsProvider facetsProvider) {
|
||||
return !facetsProvider.getFacetsByType(module, AppEngineFacet.ID).isEmpty();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile createFileFromTemplate(final String templateName, final VirtualFile parent, final String fileName) {
|
||||
parent.refresh(false, false);
|
||||
final FileTemplate template = FileTemplateManager.getDefaultInstance().getJ2eeTemplate(templateName);
|
||||
try {
|
||||
final String text = template.getText(FileTemplateManager.getDefaultInstance().getDefaultProperties());
|
||||
VirtualFile file = parent.findChild(fileName);
|
||||
if (file == null) {
|
||||
file = parent.createChildData(AppEngineSupportProvider.class, fileName);
|
||||
}
|
||||
VfsUtil.saveText(file, text);
|
||||
return file;
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void addSupport(final Module module,
|
||||
final ModifiableRootModel rootModel,
|
||||
FrameworkSupportModel frameworkSupportModel,
|
||||
String sdkPath,
|
||||
@Nullable PersistenceApi persistenceApi) {
|
||||
FacetType<AppEngineFacet, AppEngineFacetConfiguration> facetType = AppEngineFacet.getFacetType();
|
||||
AppEngineFacet appEngineFacet = FacetManager.getInstance(module).addFacet(facetType, facetType.getDefaultFacetName(), null);
|
||||
AppEngineWebIntegration webIntegration = AppEngineWebIntegration.getInstance();
|
||||
webIntegration.registerFrameworkInModel(frameworkSupportModel, appEngineFacet);
|
||||
final AppEngineFacetConfiguration facetConfiguration = appEngineFacet.getConfiguration();
|
||||
facetConfiguration.setSdkHomePath(sdkPath);
|
||||
final AppEngineSdk sdk = appEngineFacet.getSdk();
|
||||
final Artifact webArtifact = findOrCreateWebArtifact(appEngineFacet);
|
||||
|
||||
final VirtualFile webDescriptorDir = webIntegration.suggestParentDirectoryForAppEngineWebXml(module, rootModel);
|
||||
if (webDescriptorDir != null) {
|
||||
VirtualFile descriptor = createFileFromTemplate(AppEngineTemplateGroupDescriptorFactory.APP_ENGINE_WEB_XML_TEMPLATE, webDescriptorDir,
|
||||
AppEngineUtil.APP_ENGINE_WEB_XML_NAME);
|
||||
if (descriptor != null) {
|
||||
webIntegration.addDescriptor(webArtifact, module.getProject(), descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
final Project project = module.getProject();
|
||||
webIntegration.addDevServerToModuleDependencies(rootModel, sdk);
|
||||
|
||||
final Library apiJar = addProjectLibrary(module, "AppEngine API", sdk.getUserLibraryPaths(), VirtualFile.EMPTY_ARRAY);
|
||||
rootModel.addLibraryEntry(apiJar);
|
||||
webIntegration.addLibraryToArtifact(apiJar, webArtifact, project);
|
||||
|
||||
if (persistenceApi != null) {
|
||||
facetConfiguration.setRunEnhancerOnMake(true);
|
||||
facetConfiguration.setPersistenceApi(persistenceApi);
|
||||
facetConfiguration.getFilesToEnhance().addAll(AppEngineUtil.getDefaultSourceRootsToEnhance(rootModel));
|
||||
try {
|
||||
final VirtualFile[] sourceRoots = rootModel.getSourceRoots();
|
||||
final VirtualFile sourceRoot;
|
||||
if (sourceRoots.length > 0) {
|
||||
sourceRoot = sourceRoots[0];
|
||||
}
|
||||
else {
|
||||
sourceRoot = findOrCreateChildDirectory(rootModel.getContentRoots()[0], "src");
|
||||
}
|
||||
VirtualFile metaInf = findOrCreateChildDirectory(sourceRoot, "META-INF");
|
||||
if (persistenceApi == PersistenceApi.JDO || persistenceApi == PersistenceApi.JDO3) {
|
||||
createFileFromTemplate(AppEngineTemplateGroupDescriptorFactory.APP_ENGINE_JDO_CONFIG_TEMPLATE, metaInf, AppEngineUtil.JDO_CONFIG_XML_NAME);
|
||||
}
|
||||
else {
|
||||
final VirtualFile file = createFileFromTemplate(AppEngineTemplateGroupDescriptorFactory.APP_ENGINE_JPA_CONFIG_TEMPLATE, metaInf, AppEngineUtil.JPA_CONFIG_XML_NAME);
|
||||
if (file != null) {
|
||||
webIntegration.setupJpaSupport(module, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
final Library library = addProjectLibrary(module, "AppEngine ORM", Collections.singletonList(sdk.getOrmLibDirectoryPath()), sdk.getOrmLibSources());
|
||||
rootModel.addLibraryEntry(library);
|
||||
webIntegration.addLibraryToArtifact(library, webArtifact, project);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Artifact findOrCreateWebArtifact(AppEngineFacet appEngineFacet) {
|
||||
Module module = appEngineFacet.getModule();
|
||||
ArtifactType webArtifactType = AppEngineWebIntegration.getInstance().getAppEngineWebArtifactType();
|
||||
final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
|
||||
for (Artifact artifact : artifacts) {
|
||||
if (webArtifactType.equals(artifact.getArtifactType())) {
|
||||
return artifact;
|
||||
}
|
||||
}
|
||||
ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
|
||||
PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
|
||||
ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
|
||||
elementFactory.getOrCreateDirectory(root, "WEB-INF/classes").addOrFindChild(elementFactory.createModuleOutput(module));
|
||||
return artifactManager.addArtifact(module.getName(), webArtifactType, root);
|
||||
}
|
||||
|
||||
private static Library addProjectLibrary(final Module module, final String name, final List<String> jarDirectories, final VirtualFile[] sources) {
|
||||
return WriteAction.computeAndWait(() -> {
|
||||
final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(module.getProject());
|
||||
Library library = libraryTable.getLibraryByName(name);
|
||||
if (library == null) {
|
||||
library = libraryTable.createLibrary(name);
|
||||
final Library.ModifiableModel model = library.getModifiableModel();
|
||||
for (String path : jarDirectories) {
|
||||
String url = VfsUtilCore.pathToUrl(path);
|
||||
VirtualFileManager.getInstance().refreshAndFindFileByUrl(url);
|
||||
model.addJarDirectory(url, false);
|
||||
}
|
||||
for (VirtualFile sourceRoot : sources) {
|
||||
model.addRoot(sourceRoot, OrderRootType.SOURCES);
|
||||
}
|
||||
model.commit();
|
||||
}
|
||||
return library;
|
||||
});
|
||||
}
|
||||
|
||||
private VirtualFile findOrCreateChildDirectory(VirtualFile parent, final String name) throws IOException {
|
||||
VirtualFile child = parent.findChild(name);
|
||||
if (child != null) {
|
||||
return child;
|
||||
}
|
||||
return parent.createChildDirectory(this, name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FrameworkSupportInModuleConfigurable createConfigurable(@NotNull FrameworkSupportModel model) {
|
||||
return new AppEngineSupportConfigurable(model);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static void setSdkPath(FrameworkSupportInModuleConfigurable configurable, String path) {
|
||||
((AppEngineSupportConfigurable)configurable).mySdkEditor.setPath(path);
|
||||
}
|
||||
|
||||
private final class AppEngineSupportConfigurable extends FrameworkSupportInModuleConfigurable implements FrameworkSupportModelListener {
|
||||
private final FrameworkSupportModel myFrameworkSupportModel;
|
||||
private JPanel myMainPanel;
|
||||
private final AppEngineSdkEditor mySdkEditor;
|
||||
private JComboBox<String> myPersistenceApiComboBox;
|
||||
private JPanel mySdkPanel;
|
||||
private final HyperlinkLabel myErrorLabel;
|
||||
private JPanel myErrorPanel;
|
||||
|
||||
private AppEngineSupportConfigurable(FrameworkSupportModel model) {
|
||||
myFrameworkSupportModel = model;
|
||||
mySdkEditor = new AppEngineSdkEditor(model.getProject());
|
||||
mySdkPanel.add(LabeledComponent.create(mySdkEditor.getMainComponent(), JavaGoogleAppEngineBundle.message("label.google.app.engine.sdk")), BorderLayout.CENTER);
|
||||
PersistenceApiComboboxUtil.setComboboxModel(myPersistenceApiComboBox, true);
|
||||
if (model.isFrameworkSelected(JPA_FRAMEWORK_ID)) {
|
||||
myPersistenceApiComboBox.setSelectedItem(PersistenceApi.JPA.getDisplayName());
|
||||
}
|
||||
model.addFrameworkListener(this);
|
||||
|
||||
myErrorLabel = new HyperlinkLabel();
|
||||
myErrorLabel.setIcon(AllIcons.General.BalloonError);
|
||||
myErrorLabel.setVisible(false);
|
||||
myErrorLabel.setHyperlinkTarget(AppEngineSdkUtil.APP_ENGINE_DOWNLOAD_URL);
|
||||
myErrorPanel.add(BorderLayout.CENTER, myErrorLabel);
|
||||
|
||||
final Component component = mySdkEditor.getComboBox().getEditor().getEditorComponent();
|
||||
if (component instanceof JTextComponent) {
|
||||
((JTextComponent)component).getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(@NotNull DocumentEvent e) {
|
||||
checkSdk();
|
||||
}
|
||||
});
|
||||
}
|
||||
checkSdk();
|
||||
}
|
||||
|
||||
private void checkSdk() {
|
||||
final String path = mySdkEditor.getPath();
|
||||
if (StringUtil.isEmptyOrSpaces(path)) {
|
||||
myErrorLabel.setVisible(true);
|
||||
myErrorLabel.setTextWithHyperlink(JavaGoogleAppEngineBundle.message("app.engine.sdk.download.link.text"));
|
||||
myMainPanel.repaint();
|
||||
return;
|
||||
}
|
||||
|
||||
final ValidationResult result = AppEngineSdkUtil.checkPath(path);
|
||||
myErrorLabel.setVisible(!result.isOk());
|
||||
if (!result.isOk()) {
|
||||
myErrorLabel.setText(JavaGoogleAppEngineBundle.message("error.app.engine.sdk.path.is.not.correct"));
|
||||
}
|
||||
myMainPanel.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void frameworkSelected(@NotNull FrameworkSupportProvider provider) {
|
||||
if (provider.getId().equals(JPA_FRAMEWORK_ID)) {
|
||||
myPersistenceApiComboBox.setSelectedItem(PersistenceApi.JPA.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void frameworkUnselected(@NotNull FrameworkSupportProvider provider) {
|
||||
if (provider.getId().equals(JPA_FRAMEWORK_ID)) {
|
||||
myPersistenceApiComboBox.setSelectedItem(PersistenceApiComboboxUtil.NONE_ITEM_SUPPLIER.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wizardStepUpdated() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSupport(@NotNull Module module,
|
||||
@NotNull ModifiableRootModel rootModel,
|
||||
@NotNull ModifiableModelsProvider modifiableModelsProvider) {
|
||||
AppEngineSupportProvider.this.addSupport(module, rootModel, myFrameworkSupportModel, mySdkEditor.getPath(), PersistenceApiComboboxUtil.getSelectedApi(myPersistenceApiComboBox));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
return myMainPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateDescriptor;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateGroupDescriptor;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateGroupDescriptorFactory;
|
||||
import com.intellij.ide.highlighter.XmlFileType;
|
||||
import icons.GoogleAppEngineIcons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class AppEngineTemplateGroupDescriptorFactory implements FileTemplateGroupDescriptorFactory {
|
||||
@NonNls public static final String APP_ENGINE_WEB_XML_TEMPLATE = "AppEngineWeb.xml";
|
||||
@NonNls public static final String APP_ENGINE_APPLICATION_XML_TEMPLATE = "AppEngineApplication.xml";
|
||||
@NonNls public static final String APP_ENGINE_JDO_CONFIG_TEMPLATE = "AppEngineJdoConfig.xml";
|
||||
@NonNls public static final String APP_ENGINE_JPA_CONFIG_TEMPLATE = "AppEngineJpaConfig.xml";
|
||||
|
||||
@Override
|
||||
public FileTemplateGroupDescriptor getFileTemplatesDescriptor() {
|
||||
final FileTemplateDescriptor appEngineXml = new FileTemplateDescriptor(APP_ENGINE_WEB_XML_TEMPLATE, XmlFileType.INSTANCE.getIcon());
|
||||
final FileTemplateDescriptor appEngineApplicationXml = new FileTemplateDescriptor(APP_ENGINE_APPLICATION_XML_TEMPLATE, XmlFileType.INSTANCE.getIcon());
|
||||
final FileTemplateDescriptor jdoConfigXml = new FileTemplateDescriptor(APP_ENGINE_JDO_CONFIG_TEMPLATE, XmlFileType.INSTANCE.getIcon());
|
||||
final FileTemplateDescriptor jpaConfigXml = new FileTemplateDescriptor(APP_ENGINE_JPA_CONFIG_TEMPLATE, XmlFileType.INSTANCE.getIcon());
|
||||
return new FileTemplateGroupDescriptor(JavaGoogleAppEngineBundle.message("plugin.name"), GoogleAppEngineIcons.AppEngine, appEngineXml,
|
||||
appEngineApplicationXml, jdoConfigXml, jpaConfigXml);
|
||||
}
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
|
||||
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AppEngineWebIntegration {
|
||||
public static AppEngineWebIntegration getInstance() {
|
||||
return ApplicationManager.getApplication().getService(AppEngineWebIntegration.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract VirtualFile suggestParentDirectoryForAppEngineWebXml(@NotNull Module module, @NotNull ModifiableRootModel rootModel);
|
||||
|
||||
@NotNull
|
||||
public List<ArtifactType> getAppEngineTargetArtifactTypes() {
|
||||
return ContainerUtil.packNullables(getAppEngineWebArtifactType(), getAppEngineApplicationArtifactType());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract ArtifactType getAppEngineWebArtifactType();
|
||||
|
||||
@Nullable
|
||||
public abstract ArtifactType getAppEngineApplicationArtifactType();
|
||||
|
||||
@NotNull
|
||||
public abstract List<FrameworkSupportInModuleProvider.FrameworkDependency> getAppEngineFrameworkDependencies();
|
||||
|
||||
public abstract void setupJpaSupport(@NotNull Module module, @NotNull VirtualFile persistenceXml);
|
||||
|
||||
public abstract void setupRunConfiguration(@NotNull AppEngineSdk sdk, @Nullable Artifact artifact, @NotNull Project project);
|
||||
|
||||
public abstract void setupDevServer(@NotNull AppEngineSdk sdk);
|
||||
|
||||
public abstract void addDevServerToModuleDependencies(@NotNull ModifiableRootModel rootModel, @NotNull AppEngineSdk sdk);
|
||||
|
||||
public abstract void addLibraryToArtifact(@NotNull Library library, @NotNull Artifact artifact, @NotNull Project project);
|
||||
|
||||
public abstract List<? extends AppEngineSdk> getSdkForConfiguredDevServers();
|
||||
|
||||
public void addDescriptor(@NotNull Artifact artifact, @NotNull Project project, @NotNull VirtualFile descriptor) {
|
||||
}
|
||||
|
||||
public void registerFrameworkInModel(FrameworkSupportModel model, AppEngineFacet appEngineFacet) {
|
||||
}
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.facet;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.appengine.model.PersistenceApi;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class PersistenceApiComboboxUtil {
|
||||
public static final Supplier<@Nls @NotNull String> NONE_ITEM_SUPPLIER = JavaGoogleAppEngineBundle.messagePointer("persistence.api.item.name.none");
|
||||
|
||||
private PersistenceApiComboboxUtil() {
|
||||
}
|
||||
|
||||
public static void setComboboxModel(final JComboBox<String> comboBox, final boolean addNoneItem) {
|
||||
final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
|
||||
if (addNoneItem) {
|
||||
model.addElement(NONE_ITEM_SUPPLIER.get());
|
||||
}
|
||||
for (PersistenceApi api : PersistenceApi.values()) {
|
||||
model.addElement(api.getDisplayName());
|
||||
}
|
||||
comboBox.setModel(model);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PersistenceApi getSelectedApi(final JComboBox<String> comboBox) {
|
||||
final String apiName = (String)comboBox.getSelectedItem();
|
||||
PersistenceApi api = null;
|
||||
for (PersistenceApi value : PersistenceApi.values()) {
|
||||
if (value.getDisplayName().equals(apiName)) {
|
||||
api = value;
|
||||
}
|
||||
}
|
||||
return api;
|
||||
}
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.facet.impl;
|
||||
|
||||
import com.intellij.appengine.facet.AppEngineWebIntegration;
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.packaging.elements.PackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElementFactory;
|
||||
import com.intellij.packaging.impl.artifacts.PlainArtifactType;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AppEngineCommunityWebIntegration extends AppEngineWebIntegration {
|
||||
private static final Logger LOG = Logger.getInstance(AppEngineCommunityWebIntegration.class);
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile suggestParentDirectoryForAppEngineWebXml(@NotNull Module module, @NotNull ModifiableRootModel rootModel) {
|
||||
final VirtualFile root = ArrayUtil.getFirstElement(rootModel.getContentRoots());
|
||||
if (root != null) {
|
||||
try {
|
||||
return VfsUtil.createDirectoryIfMissing(root, "WEB-INF");
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArtifactType getAppEngineWebArtifactType() {
|
||||
return PlainArtifactType.getInstance();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ArtifactType getAppEngineApplicationArtifactType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupJpaSupport(@NotNull Module module, @NotNull VirtualFile persistenceXml) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRunConfiguration(@NotNull AppEngineSdk sdk,
|
||||
@Nullable Artifact artifact,
|
||||
@NotNull Project project) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupDevServer(@NotNull AppEngineSdk sdk) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDevServerToModuleDependencies(@NotNull ModifiableRootModel rootModel, @NotNull AppEngineSdk sdk) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLibraryToArtifact(@NotNull Library library, @NotNull Artifact artifact, @NotNull Project project) {
|
||||
final ArtifactManager artifactManager = ArtifactManager.getInstance(project);
|
||||
for (PackagingElement<?> element : PackagingElementFactory.getInstance().createLibraryElements(library)) {
|
||||
final String dir = element.getFilesKind(artifactManager.getResolvingContext()).containsDirectoriesWithClasses() ? "classes" : "lib";
|
||||
artifactManager.addElementsToDirectory(artifact, "WEB-INF/" + dir, element);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends AppEngineSdk> getSdkForConfiguredDevServers() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDescriptor(@NotNull Artifact artifact, @NotNull Project project, @NotNull VirtualFile descriptor) {
|
||||
ArtifactManager.getInstance(project).addElementsToDirectory(artifact, "WEB-INF", PackagingElementFactory.getInstance().createFileCopy(descriptor.getPath(), null));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<FrameworkSupportInModuleProvider.FrameworkDependency> getAppEngineFrameworkDependencies() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.inspections;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AppEngineForbiddenCodeHandler {
|
||||
public static final ExtensionPointName<AppEngineForbiddenCodeHandler> EP_NAME = ExtensionPointName.create("com.intellij.appengine.forbiddenCodeHandler");
|
||||
|
||||
public abstract boolean isNativeMethodAllowed(@NotNull PsiMethod method);
|
||||
}
|
||||
-163
@@ -1,163 +0,0 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.inspections;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.appengine.facet.AppEngineFacet;
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.JdkOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.util.ClassUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AppEngineForbiddenCodeInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||
|
||||
@Override
|
||||
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
|
||||
final Project project = manager.getProject();
|
||||
Module module = ModuleUtilCore.findModuleForPsiElement(file);
|
||||
final AppEngineFacet appEngineFacet = AppEngineFacet.getAppEngineFacetByModule(module);
|
||||
if (appEngineFacet == null) {
|
||||
return null;
|
||||
}
|
||||
final AppEngineSdk appEngineSdk = appEngineFacet.getSdk();
|
||||
if (!appEngineSdk.isValid()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
final List<ProblemDescriptor> problems = new ArrayList<>();
|
||||
file.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitDocComment(@NotNull PsiDocComment comment) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethod(@NotNull PsiMethod method) {
|
||||
final PsiModifierList modifierList = method.getModifierList();
|
||||
if (modifierList.hasModifierProperty(PsiModifier.NATIVE)) {
|
||||
if (!isNativeMethodAllowed(method)) {
|
||||
problems.add(manager.createProblemDescriptor(modifierList, JavaGoogleAppEngineBundle.message(
|
||||
"inspection.message.native.methods.not.allowed"), isOnTheFly,
|
||||
LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
|
||||
}
|
||||
}
|
||||
super.visitMethod(method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitNewExpression(@NotNull PsiNewExpression expression) {
|
||||
final PsiJavaCodeReferenceElement classReference = expression.getClassReference();
|
||||
if (classReference != null) {
|
||||
final PsiElement resolved = classReference.resolve();
|
||||
if (resolved instanceof PsiClass) {
|
||||
final String qualifiedName = ((PsiClass)resolved).getQualifiedName();
|
||||
if (qualifiedName != null && appEngineSdk.isMethodInBlacklist(qualifiedName, "new")) {
|
||||
final String message = JavaGoogleAppEngineBundle
|
||||
.message("inspection.message.application.should.not.create.new.instances.0", qualifiedName);
|
||||
problems.add(manager.createProblemDescriptor(classReference, message, isOnTheFly, LocalQuickFix.EMPTY_ARRAY,
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
|
||||
}
|
||||
}
|
||||
}
|
||||
super.visitNewExpression(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
|
||||
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
|
||||
final PsiElement element = methodExpression.resolve();
|
||||
if (element instanceof PsiMethod) {
|
||||
final PsiMethod method = (PsiMethod)element;
|
||||
final PsiClass psiClass = method.getContainingClass();
|
||||
if (psiClass != null) {
|
||||
final String qualifiedName = psiClass.getQualifiedName();
|
||||
final String methodName = method.getName();
|
||||
if (qualifiedName != null && appEngineSdk.isMethodInBlacklist(qualifiedName, methodName)) {
|
||||
final String message = JavaGoogleAppEngineBundle.message("inspection.message.application.should.not.call.method",
|
||||
StringUtil.getShortName(qualifiedName), methodName);
|
||||
problems.add(manager.createProblemDescriptor(methodExpression, message, isOnTheFly, LocalQuickFix.EMPTY_ARRAY,
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
|
||||
}
|
||||
}
|
||||
}
|
||||
super.visitMethodCallExpression(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceElement(@NotNull PsiJavaCodeReferenceElement reference) {
|
||||
final PsiElement resolved = reference.resolve();
|
||||
if (resolved instanceof PsiClass) {
|
||||
final PsiFile psiFile = resolved.getContainingFile();
|
||||
if (psiFile != null) {
|
||||
final VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
if (virtualFile != null && !fileIndex.isInSource(virtualFile)) {
|
||||
final List<OrderEntry> list = fileIndex.getOrderEntriesForFile(virtualFile);
|
||||
for (OrderEntry entry : list) {
|
||||
if (entry instanceof JdkOrderEntry) {
|
||||
final String className = ClassUtil.getJVMClassName((PsiClass)resolved);
|
||||
if (className != null && !appEngineSdk.isClassInWhiteList(className)) {
|
||||
problems.add(manager.createProblemDescriptor(reference,
|
||||
JavaGoogleAppEngineBundle
|
||||
.message("inspection.message.class.not.included.in.white.list", className),
|
||||
isOnTheFly, LocalQuickFix.EMPTY_ARRAY,
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.visitReferenceElement(reference);
|
||||
}
|
||||
});
|
||||
return problems.toArray(ProblemDescriptor.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
private static boolean isNativeMethodAllowed(PsiMethod method) {
|
||||
for (AppEngineForbiddenCodeHandler handler : AppEngineForbiddenCodeHandler.EP_NAME.getExtensions()) {
|
||||
if (handler.isNativeMethodAllowed(method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HighlightDisplayLevel getDefaultLevel() {
|
||||
return HighlightDisplayLevel.ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nls
|
||||
@NotNull
|
||||
public String getGroupDisplayName() {
|
||||
return JavaGoogleAppEngineBundle.message("plugin.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getShortName() {
|
||||
return "AppEngineForbiddenCode";
|
||||
}
|
||||
}
|
||||
-114
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.maven;
|
||||
|
||||
import com.intellij.appengine.facet.AppEngineFacet;
|
||||
import com.intellij.appengine.facet.AppEngineFacetConfiguration;
|
||||
import com.intellij.appengine.facet.AppEngineFacetType;
|
||||
import com.intellij.appengine.facet.AppEngineWebIntegration;
|
||||
import com.intellij.appengine.sdk.impl.AppEngineSdkUtil;
|
||||
import com.intellij.facet.FacetType;
|
||||
import com.intellij.openapi.externalSystem.project.PackagingModifiableModel;
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.util.io.ZipUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.importing.FacetImporter;
|
||||
import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
|
||||
import org.jetbrains.idea.maven.model.MavenArtifact;
|
||||
import org.jetbrains.idea.maven.model.MavenArtifactInfo;
|
||||
import org.jetbrains.idea.maven.model.MavenPlugin;
|
||||
import org.jetbrains.idea.maven.model.MavenRemoteRepository;
|
||||
import org.jetbrains.idea.maven.project.*;
|
||||
import org.jetbrains.idea.maven.server.MavenEmbedderWrapper;
|
||||
import org.jetbrains.idea.maven.server.NativeMavenProjectHolder;
|
||||
import org.jetbrains.idea.maven.utils.MavenLog;
|
||||
import org.jetbrains.idea.maven.utils.MavenProcessCanceledException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AppEngineFacetImporter extends FacetImporter<AppEngineFacet, AppEngineFacetConfiguration, AppEngineFacetType> {
|
||||
public AppEngineFacetImporter() {
|
||||
super("com.google.appengine", "appengine-maven-plugin", FacetType.findInstance(AppEngineFacetType.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve(Project project,
|
||||
MavenProject mavenProject,
|
||||
NativeMavenProjectHolder nativeMavenProject,
|
||||
MavenEmbedderWrapper embedder,
|
||||
ResolveContext context) throws MavenProcessCanceledException {
|
||||
String version = getVersion(mavenProject);
|
||||
if (version != null) {
|
||||
List<MavenRemoteRepository> repos = mavenProject.getRemoteRepositories();
|
||||
MavenArtifactInfo artifactInfo = new MavenArtifactInfo("com.google.appengine", "appengine-java-sdk", version, "zip", null);
|
||||
MavenArtifact artifact = embedder.resolve(artifactInfo, repos);
|
||||
File file = artifact.getFile();
|
||||
File unpackedSdkPath = new File(file.getParentFile(), "appengine-java-sdk");
|
||||
if (file.exists() && !AppEngineSdkUtil.checkPath(FileUtil.toSystemIndependentName(unpackedSdkPath.getAbsolutePath())).isOk()) {
|
||||
try {
|
||||
ZipUtil.extract(file, unpackedSdkPath, null, false);
|
||||
}
|
||||
catch (IOException e) {
|
||||
MavenLog.LOG.warn("cannot unpack AppEngine SDK", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getVersion(MavenProject project) {
|
||||
for (MavenArtifact artifact : project.findDependencies("com.google.appengine", "appengine-api-1.0-sdk")) {
|
||||
String artifactVersion = artifact.getVersion();
|
||||
if (artifactVersion != null) return artifactVersion;
|
||||
}
|
||||
MavenPlugin plugin = project.findPlugin(myPluginGroupID, myPluginArtifactID);
|
||||
return plugin != null ? plugin.getVersion() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupFacet(AppEngineFacet f, MavenProject mavenProject) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reimportFacet(IdeModifiableModelsProvider modelsProvider,
|
||||
Module module,
|
||||
MavenRootModelAdapter rootModel,
|
||||
AppEngineFacet facet,
|
||||
MavenProjectsTree mavenTree,
|
||||
MavenProject mavenProject,
|
||||
MavenProjectChanges changes,
|
||||
Map<MavenProject, String> mavenProjectToModuleName,
|
||||
List<MavenProjectsProcessorTask> postTasks) {
|
||||
String version = getVersion(mavenProject);
|
||||
if (version != null) {
|
||||
String relativePath = "/com/google/appengine/appengine-java-sdk/" + version + "/appengine-java-sdk/appengine-java-sdk-" + version;
|
||||
facet.getConfiguration().setSdkHomePath(FileUtil.toSystemIndependentName(mavenProject.getLocalRepository().getPath()) + relativePath);
|
||||
AppEngineWebIntegration.getInstance().setupDevServer(facet.getSdk());
|
||||
final String artifactName = module.getName() + ":war exploded";
|
||||
final Artifact webArtifact = modelsProvider.getModifiableModel(PackagingModifiableModel.class)
|
||||
.getModifiableArtifactModel().findArtifact(artifactName);
|
||||
AppEngineWebIntegration.getInstance().setupRunConfiguration(facet.getSdk(), webArtifact, module.getProject());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.sdk;
|
||||
|
||||
import com.intellij.execution.configurations.ParametersList;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public interface AppEngineSdk {
|
||||
|
||||
@NotNull
|
||||
String getSdkHomePath();
|
||||
|
||||
@NotNull
|
||||
File getAppCfgFile();
|
||||
|
||||
@NotNull
|
||||
File getToolsApiJarFile();
|
||||
|
||||
File @NotNull [] getLibraries();
|
||||
|
||||
boolean isClassInWhiteList(@NotNull String className);
|
||||
|
||||
@Nullable
|
||||
String getVersion();
|
||||
|
||||
boolean isMethodInBlacklist(@NotNull String className, @NotNull String methodName);
|
||||
|
||||
boolean isValid();
|
||||
|
||||
@NotNull
|
||||
String getOrmLibDirectoryPath();
|
||||
|
||||
@NotNull
|
||||
List<String> getUserLibraryPaths();
|
||||
|
||||
VirtualFile @NotNull [] getOrmLibSources();
|
||||
|
||||
@NotNull
|
||||
File getApplicationSchemeFile();
|
||||
|
||||
@NotNull
|
||||
File getWebSchemeFile();
|
||||
|
||||
File @NotNull [] getJspLibraries();
|
||||
|
||||
void patchJavaParametersForDevServer(@NotNull ParametersList vmParameters);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.sdk;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AppEngineSdkManager {
|
||||
|
||||
public static AppEngineSdkManager getInstance() {
|
||||
return ApplicationManager.getApplication().getService(AppEngineSdkManager.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract AppEngineSdk findSdk(@NotNull String sdkPath);
|
||||
|
||||
@NotNull
|
||||
public abstract List<? extends AppEngineSdk> getValidSdks();
|
||||
|
||||
}
|
||||
-236
@@ -1,236 +0,0 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.sdk.impl;
|
||||
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.appengine.util.AppEngineUtil;
|
||||
import com.intellij.execution.configurations.ParametersList;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.JarUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.appengine.model.impl.JpsAppEngineModuleExtensionImpl;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.jar.Attributes;
|
||||
|
||||
public class AppEngineSdkImpl implements AppEngineSdk {
|
||||
private static final Logger LOG = Logger.getInstance(AppEngineSdkImpl.class);
|
||||
private Map<String, Set<String>> myClassesWhiteList;
|
||||
private Map<String, Set<String>> myMethodsBlackList;
|
||||
private final String myHomePath;
|
||||
|
||||
public AppEngineSdkImpl(String homePath) {
|
||||
myHomePath = homePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File getAppCfgFile() {
|
||||
final String extension = SystemInfo.isWindows ? "cmd" : "sh";
|
||||
return new File(myHomePath, "bin/appcfg." + extension);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File getWebSchemeFile() {
|
||||
return new File(myHomePath, "docs/appengine-web.xsd");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getApplicationSchemeFile() {
|
||||
return new File(myHomePath, "docs/appengine-application.xsd");
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File getToolsApiJarFile() {
|
||||
return new File(myHomePath, JpsAppEngineModuleExtensionImpl.LIB_APPENGINE_TOOLS_API_JAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File @NotNull [] getLibraries() {
|
||||
return getJarsFromDirectory(new File(myHomePath, "lib/shared"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public File @NotNull [] getJspLibraries() {
|
||||
return getJarsFromDirectory(new File(myHomePath, "lib/shared/jsp"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void patchJavaParametersForDevServer(@NotNull ParametersList vmParameters) {
|
||||
final String agentPath = myHomePath + "/lib/agent/appengine-agent.jar";
|
||||
if (new File(FileUtil.toSystemDependentName(agentPath)).exists()) {
|
||||
vmParameters.add("-javaagent:" + agentPath);
|
||||
}
|
||||
String patchPath = myHomePath + "/lib/override/appengine-dev-jdk-overrides.jar";
|
||||
if (new File(FileUtil.toSystemDependentName(patchPath)).exists()) {
|
||||
vmParameters.add("-Xbootclasspath/p:" + patchPath);
|
||||
}
|
||||
}
|
||||
|
||||
private static File[] getJarsFromDirectory(File libFolder) {
|
||||
List<File> jars = new ArrayList<>();
|
||||
final File[] files = libFolder.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isFile() && file.getName().endsWith(".jar")) {
|
||||
jars.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
return jars.toArray(new File[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getSdkHomePath() {
|
||||
return myHomePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClassInWhiteList(@NotNull String className) {
|
||||
if (!isValid()) return true;
|
||||
|
||||
if (myClassesWhiteList == null) {
|
||||
File cachedWhiteList = getCachedWhiteListFile();
|
||||
if (cachedWhiteList.exists()) {
|
||||
try {
|
||||
myClassesWhiteList = AppEngineSdkUtil.loadWhiteList(cachedWhiteList);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
myClassesWhiteList = Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
else {
|
||||
myClassesWhiteList = AppEngineSdkUtil.computeWhiteList(getToolsApiJarFile());
|
||||
if (!myClassesWhiteList.isEmpty()) {
|
||||
AppEngineSdkUtil.saveWhiteList(cachedWhiteList, myClassesWhiteList);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myClassesWhiteList.isEmpty()) {
|
||||
//don't report errors if white-list wasn't properly loaded
|
||||
return true;
|
||||
}
|
||||
|
||||
final String packageName = StringUtil.getPackageName(className);
|
||||
final String name = StringUtil.getShortName(className);
|
||||
final Set<String> classes = myClassesWhiteList.get(packageName);
|
||||
return classes != null && classes.contains(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getVersion() {
|
||||
return JarUtil.getJarAttribute(getToolsApiJarFile(), "com/google/appengine/tools/info/", Attributes.Name.SPECIFICATION_VERSION);
|
||||
}
|
||||
|
||||
private File getCachedWhiteListFile() {
|
||||
String fileName = StringUtil.getShortName(myHomePath, '/') + Integer.toHexString(myHomePath.hashCode()) + "_" + Long.toHexString(getToolsApiJarFile().lastModified());
|
||||
return new File(AppEngineUtil.getAppEngineSystemDir(), fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMethodInBlacklist(@NotNull String className, @NotNull String methodName) {
|
||||
if (myMethodsBlackList == null) {
|
||||
try {
|
||||
myMethodsBlackList = loadBlackList();
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
myMethodsBlackList = new HashMap<>();
|
||||
}
|
||||
}
|
||||
final Set<String> methods = myMethodsBlackList.get(className);
|
||||
return methods != null && methods.contains(methodName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return getToolsApiJarFile().exists() && getAppCfgFile().exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getOrmLibDirectoryPath() {
|
||||
return getLibUserDirectoryPath() + "/orm";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> getUserLibraryPaths() {
|
||||
List<String> result = new ArrayList<>();
|
||||
result.add(getLibUserDirectoryPath());
|
||||
File opt = new File(myHomePath, "lib/opt/user");
|
||||
ContainerUtil.addIfNotNull(result, findLatestVersion(new File(opt, "appengine-endpoints")));
|
||||
ContainerUtil.addIfNotNull(result, findLatestVersion(new File(opt, "jsr107")));
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String findLatestVersion(File dir) {
|
||||
String[] names = dir.list();
|
||||
if (names != null && names.length > 0) {
|
||||
String max = Collections.max(Arrays.asList(names));
|
||||
return FileUtil.toSystemIndependentName(new File(dir, max).getAbsolutePath());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualFile @NotNull [] getOrmLibSources() {
|
||||
final File libsDir = new File(myHomePath, "src/orm");
|
||||
final File[] files = libsDir.listFiles();
|
||||
List<VirtualFile> roots = new ArrayList<>();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
final String url = VfsUtil.getUrlForLibraryRoot(file);
|
||||
final VirtualFile zipRoot = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
if (zipRoot != null && zipRoot.isDirectory()) {
|
||||
String fileName = file.getName();
|
||||
final String srcDirName = StringUtil.trimEnd(fileName, "-src.zip");
|
||||
final VirtualFile sourcesDir = zipRoot.findFileByRelativePath(srcDirName + "/src/java");
|
||||
if (sourcesDir != null) {
|
||||
roots.add(sourcesDir);
|
||||
}
|
||||
else {
|
||||
roots.add(zipRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return VfsUtilCore.toVirtualFileArray(roots);
|
||||
}
|
||||
|
||||
public String getLibUserDirectoryPath() {
|
||||
return myHomePath + "/lib/user";
|
||||
}
|
||||
|
||||
private Map<String, Set<String>> loadBlackList() throws IOException {
|
||||
final InputStream stream = getClass().getResourceAsStream("/data/methodsBlacklist.txt");
|
||||
LOG.assertTrue(stream != null, "/data/methodsBlacklist.txt not found");
|
||||
final Map<String, Set<String>> map = new HashMap<>();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
final int i = line.indexOf(':');
|
||||
String className = line.substring(0, i);
|
||||
String methods = line.substring(i + 1);
|
||||
map.put(className, new HashSet<>(StringUtil.split(methods, ",")));
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.sdk.impl;
|
||||
|
||||
import com.intellij.appengine.facet.AppEngineWebIntegration;
|
||||
import com.intellij.appengine.sdk.AppEngineSdk;
|
||||
import com.intellij.appengine.sdk.AppEngineSdkManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AppEngineSdkManagerImpl extends AppEngineSdkManager {
|
||||
private final Map<String, AppEngineSdkImpl> myPath2Sdk = new HashMap<>();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AppEngineSdk findSdk(@NotNull String sdkPath) {
|
||||
sdkPath = StringUtil.trimEnd(sdkPath, "/");
|
||||
if (!myPath2Sdk.containsKey(sdkPath)) {
|
||||
myPath2Sdk.put(sdkPath, new AppEngineSdkImpl(sdkPath));
|
||||
}
|
||||
return myPath2Sdk.get(sdkPath);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends AppEngineSdk> getValidSdks() {
|
||||
return AppEngineWebIntegration.getInstance().getSdkForConfiguredDevServers();
|
||||
}
|
||||
}
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.sdk.impl;
|
||||
|
||||
import com.intellij.appengine.JavaGoogleAppEngineBundle;
|
||||
import com.intellij.facet.ui.FacetConfigurationQuickFix;
|
||||
import com.intellij.facet.ui.ValidationResult;
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public final class AppEngineSdkUtil {
|
||||
private static final Logger LOG = Logger.getInstance(AppEngineSdkUtil.class);
|
||||
@NonNls public static final String APP_ENGINE_DOWNLOAD_URL = "https://code.google.com/appengine/downloads.html#Google_App_Engine_SDK_for_Java";
|
||||
private static final FacetConfigurationQuickFix DOWNLOAD_SDK_QUICK_FIX =
|
||||
new FacetConfigurationQuickFix(JavaGoogleAppEngineBundle.message("button.sdk.download.text")) {
|
||||
@Override
|
||||
public void run(JComponent place) {
|
||||
BrowserUtil.browse(APP_ENGINE_DOWNLOAD_URL);
|
||||
}
|
||||
};
|
||||
|
||||
private AppEngineSdkUtil() {
|
||||
}
|
||||
|
||||
public static void saveWhiteList(File cachedWhiteList, Map<String, Set<String>> classesWhiteList) {
|
||||
try {
|
||||
FileUtil.createParentDirs(cachedWhiteList);
|
||||
try (PrintWriter writer = new PrintWriter(cachedWhiteList)) {
|
||||
for (String packageName : classesWhiteList.keySet()) {
|
||||
writer.println("." + packageName);
|
||||
final Set<String> classes = classesWhiteList.get(packageName);
|
||||
for (String aClass : classes) {
|
||||
writer.println(aClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Set<String>> loadWhiteList(File input) throws IOException {
|
||||
Map<String, Set<String>> map = new HashMap<>();
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(input))) {
|
||||
String line;
|
||||
Set<String> currentClasses = new HashSet<>();
|
||||
map.put("", currentClasses);
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.startsWith(".")) {
|
||||
String packageName = line.substring(1);
|
||||
currentClasses = new HashSet<>();
|
||||
map.put(packageName, currentClasses);
|
||||
}
|
||||
else {
|
||||
currentClasses.add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static Map<String, Set<String>> computeWhiteList(final File toolsApiJarFile) {
|
||||
try {
|
||||
Map<String, Set<String>> map = new HashMap<>();
|
||||
final ClassLoader loader = UrlClassLoader.build().files(Collections.singletonList(toolsApiJarFile.toPath())).parent(
|
||||
AppEngineSdkUtil.class.getClassLoader()).get();
|
||||
final Class<?> whiteListClass = Class.forName("com.google.apphosting.runtime.security.WhiteList", true, loader);
|
||||
final Set<String> classes = (Set<String>)whiteListClass.getMethod("getWhiteList").invoke(null);
|
||||
for (String qualifiedName : classes) {
|
||||
final String packageName = StringUtil.getPackageName(qualifiedName);
|
||||
Set<String> classNames = map.get(packageName);
|
||||
if (classNames == null) {
|
||||
classNames = new HashSet<>();
|
||||
map.put(packageName, classNames);
|
||||
}
|
||||
classNames.add(StringUtil.getShortName(qualifiedName));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
catch (UnsupportedClassVersionError e) {
|
||||
LOG.warn(e);
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ValidationResult checkPath(String path) {
|
||||
final AppEngineSdkImpl sdk = new AppEngineSdkImpl(path);
|
||||
|
||||
final File appCfgFile = sdk.getAppCfgFile();
|
||||
if (!appCfgFile.exists()) {
|
||||
return createNotFoundMessage(path, appCfgFile);
|
||||
}
|
||||
|
||||
final File toolsApiJarFile = sdk.getToolsApiJarFile();
|
||||
if (!toolsApiJarFile.exists()) {
|
||||
return createNotFoundMessage(path, toolsApiJarFile);
|
||||
}
|
||||
|
||||
return ValidationResult.OK;
|
||||
}
|
||||
|
||||
private static ValidationResult createNotFoundMessage(@NotNull String path, @NotNull File file) {
|
||||
return new ValidationResult(JavaGoogleAppEngineBundle.message("sdk.file.not.found.message", path, file), DOWNLOAD_SDK_QUICK_FIX);
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.util;
|
||||
|
||||
import com.intellij.appengine.facet.AppEngineFacet;
|
||||
import com.intellij.appengine.facet.AppEngineWebIntegration;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootModel;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.ui.SimpleListCellRenderer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public final class AppEngineUtil {
|
||||
@NonNls public static final String APP_ENGINE_WEB_XML_NAME = "appengine-web.xml";
|
||||
@NonNls public static final String APP_ENGINE_APPLICATION_XML_NAME = "appengine-application.xml";
|
||||
@NonNls public static final String JDO_CONFIG_XML_NAME = "jdoconfig.xml";
|
||||
@NonNls public static final String JPA_CONFIG_XML_NAME = "persistence.xml";
|
||||
|
||||
private AppEngineUtil() {
|
||||
}
|
||||
|
||||
public static void setupAppEngineArtifactCombobox(@NotNull Project project, final @NotNull JComboBox<Artifact> comboBox, final boolean withAppEngineFacetOnly) {
|
||||
comboBox.setRenderer(SimpleListCellRenderer.create((label, value, index) -> {
|
||||
if (value != null) {
|
||||
label.setIcon(value.getArtifactType().getIcon());
|
||||
label.setText(value.getName());
|
||||
}
|
||||
}));
|
||||
|
||||
comboBox.removeAllItems();
|
||||
for (Artifact artifact : collectAppEngineArtifacts(project, withAppEngineFacetOnly)) {
|
||||
comboBox.addItem(artifact);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Artifact> collectAppEngineArtifacts(@NotNull Project project, final boolean withAppEngineFacetOnly) {
|
||||
final List<Artifact> artifacts = new ArrayList<>();
|
||||
if (project.isDefault()) return artifacts;
|
||||
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
|
||||
if (AppEngineWebIntegration.getInstance().getAppEngineTargetArtifactTypes().contains(artifact.getArtifactType()) &&
|
||||
(!withAppEngineFacetOnly || findAppEngineFacet(project, artifact) != null)) {
|
||||
artifacts.add(artifact);
|
||||
}
|
||||
}
|
||||
artifacts.sort(ArtifactManager.ARTIFACT_COMPARATOR);
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AppEngineFacet findAppEngineFacet(@NotNull Project project, @NotNull Artifact artifact) {
|
||||
final Set<Module> modules = ArtifactUtil.getModulesIncludedInArtifacts(Collections.singletonList(artifact), project);
|
||||
for (Module module : modules) {
|
||||
final AppEngineFacet appEngineFacet = AppEngineFacet.getAppEngineFacetByModule(module);
|
||||
if (appEngineFacet != null) {
|
||||
return appEngineFacet;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static File getAppEngineSystemDir() {
|
||||
return new File(PathManager.getSystemPath(), "GoogleAppEngine");
|
||||
}
|
||||
|
||||
public static List<String> getDefaultSourceRootsToEnhance(ModuleRootModel rootModel) {
|
||||
List<String> paths = new ArrayList<>();
|
||||
for (String url : rootModel.getSourceRootUrls(false)) {
|
||||
paths.add(VfsUtil.urlToPath(url));
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/appEngineGuestbook.iml" filepath="$PROJECT_DIR$/appEngineGuestbook.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
|
||||
</descriptors>
|
||||
<webroots>
|
||||
<root url="file://$MODULE_DIR$/web" relative="/" />
|
||||
</webroots>
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="google-app-engine" name="Google App Engine">
|
||||
<configuration>
|
||||
<files-to-enhance>
|
||||
<file path="$MODULE_DIR$/src" />
|
||||
</files-to-enhance>
|
||||
<persistence-api>JPA</persistence-api>
|
||||
<run-enhancer-on-make>true</run-enhancer-on-make>
|
||||
<sdk-home-path>$USER_HOME$/applications/appengine-java-sdk-1.7.3</sdk-home-path>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="AppEngine API" level="project" />
|
||||
<orderEntry type="library" name="AppEngine ORM" level="project" />
|
||||
<orderEntry type="library" name="Java EE 6" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/appEngineGuestbook.iml" filepath="$PROJECT_DIR$/appEngineGuestbook.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
|
||||
</descriptors>
|
||||
<webroots>
|
||||
<root url="file://$MODULE_DIR$/web" relative="/" />
|
||||
</webroots>
|
||||
</configuration>
|
||||
<facet type="google-app-engine" name="Google App Engine">
|
||||
<configuration>
|
||||
<files-to-enhance>
|
||||
<file path="$MODULE_DIR$/src" />
|
||||
</files-to-enhance>
|
||||
<persistence-api>JPA</persistence-api>
|
||||
<run-enhancer-on-make>true</run-enhancer-on-make>
|
||||
<sdk-home-path>$USER_HOME$/applications/appengine-java-sdk-1.7.3</sdk-home-path>
|
||||
</configuration>
|
||||
</facet>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="AppEngine API" level="project" />
|
||||
<orderEntry type="library" name="AppEngine ORM" level="project" />
|
||||
<orderEntry type="library" name="Java EE 6" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<appengine-application xmlns="http://appengine.google.com/ns/1.0">
|
||||
<application>app</application>
|
||||
</appengine-application>
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
|
||||
<application>app</application>
|
||||
<version>1</version>
|
||||
</appengine-web-app>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
|
||||
|
||||
<persistence-manager-factory name="transactions-optional">
|
||||
<property name="javax.jdo.PersistenceManagerFactoryClass"
|
||||
value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
|
||||
<property name="javax.jdo.option.ConnectionURL" value="appengine"/>
|
||||
<property name="javax.jdo.option.NontransactionalRead" value="true"/>
|
||||
<property name="javax.jdo.option.NontransactionalWrite" value="true"/>
|
||||
<property name="javax.jdo.option.RetainValues" value="true"/>
|
||||
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
|
||||
</persistence-manager-factory>
|
||||
</jdoconfig>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://appengine.google.com/ns/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="appengine-application" type="ns:appengine-applicationType" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:complexType name="appengine-applicationType">
|
||||
<xs:all>
|
||||
<xs:element type="xs:string" name="application"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://appengine.google.com/ns/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="appengine-web-app" type="ns:appengine-web-appType" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:complexType name="env-varType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:string" name="name" use="required"/>
|
||||
<xs:attribute type="xs:string" name="value" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="system-propertiesType">
|
||||
<xs:sequence>
|
||||
<xs:element type="ns:propertyType" name="property" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="propertyType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:string" name="name" use="required"/>
|
||||
<xs:attribute type="xs:string" name="value" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="appengine-web-appType">
|
||||
<xs:all>
|
||||
<xs:element type="xs:string" name="application"/>
|
||||
<xs:element type="xs:string" name="version"/>
|
||||
<xs:element type="ns:static-filesType" name="static-files" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="ns:resource-filesType" name="resource-files" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="ns:system-propertiesType" name="system-properties" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="ns:env-variablesType" name="env-variables" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="xs:boolean" name="ssl-enabled" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="xs:boolean" name="sessions-enabled" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="ns:userPermissionsType" name="user-permissions" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="xs:string" name="public-root" minOccurs="0"/>
|
||||
<xs:element type="ns:inboundServicesType" name="inbound-services" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="xs:boolean" name="precompilation-enabled" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="ns:admin-console" name="admin-console" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="ns:static-error-handlers" name="static-error-handlers" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="env-variablesType">
|
||||
<xs:sequence>
|
||||
<xs:element type="ns:env-varType" name="env-var" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="includeType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:string" name="path" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="staticIncludeType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="ns:includeType" xmlns:ns="http://appengine.google.com/ns/1.0">
|
||||
<xs:attribute type="ns:expirationType" name="expiration" use="optional" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="resource-filesType">
|
||||
<xs:sequence>
|
||||
<xs:element type="ns:includeType" name="include" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="ns:excludeType" name="exclude" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="static-filesType">
|
||||
<xs:sequence>
|
||||
<xs:element type="ns:staticIncludeType" name="include" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
<xs:element type="ns:excludeType" name="exclude" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="excludeType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:string" name="path" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="userPermissionsType">
|
||||
<xs:sequence>
|
||||
<xs:element type="ns:permissionType" name="permission" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="permissionType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:string" name="class" use="required"/>
|
||||
<xs:attribute type="xs:string" name="name" use="required"/>
|
||||
<xs:attribute type="xs:string" name="actions" use="optional"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="inboundServicesType">
|
||||
<xs:sequence>
|
||||
<xs:element type="xs:string" name="service" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="expirationType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="\s*(([0-9]+)([DdHhMm]|[sS]?))(\s+([0-9]+)([DdHhMm]|[sS]?))*\s*"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="admin-console">
|
||||
<xs:sequence>
|
||||
<xs:element type="ns:admin-console-pageType" name="page" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="admin-console-pageType">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:string" name="name" use="required"/>
|
||||
<xs:attribute type="xs:string" name="url" use="required"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="static-error-handlers">
|
||||
<xs:sequence>
|
||||
<xs:element type="ns:static-error-handlers-handler" name="handler" maxOccurs="unbounded" minOccurs="0" xmlns:ns="http://appengine.google.com/ns/1.0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="static-error-handlers-handler">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:string" name="file" use="required"/>
|
||||
<xs:attribute type="xs:string" name="error-code" use="optional"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
||||
|
||||
Binary file not shown.
-95
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine;
|
||||
|
||||
import com.intellij.appengine.facet.AppEngineFacet;
|
||||
import com.intellij.facet.FacetManager;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
|
||||
import com.intellij.testFramework.fixtures.*;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public abstract class AppEngineCodeInsightTestCase extends UsefulTestCase {
|
||||
@NonNls private static final String DEFAULT_VERSION = "1.3.7";
|
||||
private JavaModuleFixtureBuilder myModuleBuilder;
|
||||
private IdeaProjectTestFixture myProjectFixture;
|
||||
protected CodeInsightTestFixture myCodeInsightFixture;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
final TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = JavaTestFixtureFactory.createFixtureBuilder(getName());
|
||||
myModuleBuilder = fixtureBuilder.addModule(JavaModuleFixtureBuilder.class);
|
||||
myProjectFixture = fixtureBuilder.getFixture();
|
||||
myCodeInsightFixture = createCodeInsightFixture(getBaseDirectoryPath());
|
||||
WriteAction.runAndWait(() -> addAppEngineSupport(myProjectFixture.getModule()));
|
||||
}
|
||||
|
||||
protected abstract String getBaseDirectoryPath();
|
||||
|
||||
private void addAppEngineSupport(Module module) {
|
||||
final AppEngineFacet appEngine = FacetManager.getInstance(module).addFacet(AppEngineFacet.getFacetType(), "AppEngine", null);
|
||||
appEngine.getConfiguration().setSdkHomePath(getSdkPath());
|
||||
|
||||
ModuleRootModificationUtil.addModuleLibrary(module, VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, getSdkPath()) + "/lib/user/orm/jdo.jar!/");
|
||||
}
|
||||
|
||||
public static String getSdkPath() {
|
||||
return FileUtil.toSystemIndependentName(new File(getTestDataPath(), "sdk/" + DEFAULT_VERSION).getAbsolutePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
myCodeInsightFixture.tearDown();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
addSuppressedException(e);
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
protected CodeInsightTestFixture createCodeInsightFixture(final String relativeTestDataPath) throws Exception {
|
||||
final String testDataPath = new File(getTestDataPath(), relativeTestDataPath).getAbsolutePath();
|
||||
final CodeInsightTestFixture codeInsightFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(myProjectFixture);
|
||||
codeInsightFixture.setTestDataPath(testDataPath);
|
||||
final TempDirTestFixture tempDir = codeInsightFixture.getTempDirFixture();
|
||||
myModuleBuilder.addSourceContentRoot(tempDir.getTempDirPath());
|
||||
codeInsightFixture.setUp();
|
||||
final VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByPath(testDataPath);
|
||||
Assert.assertNotNull("Test data directory not found: " + testDataPath, dir);
|
||||
VfsUtil.processFilesRecursively(dir, new CommonProcessors.CollectProcessor<>());
|
||||
dir.refresh(false, true);
|
||||
tempDir.copyAll(testDataPath, "", file -> !file.getName().contains("_after"));
|
||||
return codeInsightFixture;
|
||||
}
|
||||
|
||||
private static File getTestDataPath() {
|
||||
return PathManagerEx.findFileUnderCommunityHome("plugins/google-app-engine/testData");
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.appengine.converter;
|
||||
|
||||
import com.intellij.conversion.ProjectConversionTestUtil;
|
||||
import com.intellij.conversion.impl.ProjectConversionUtil;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.testFramework.HeavyPlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AppEngineFacetConverterTest extends HeavyPlatformTestCase {
|
||||
public void testConvert() throws IOException {
|
||||
String testDataPath = "plugins/google-app-engine/testData/conversion/appEngineFacet/";
|
||||
File testData = PathManagerEx.findFileUnderProjectHome(testDataPath + "before", getClass());
|
||||
File tempDir = FileUtil.createTempDirectory("app-engine-project", null);
|
||||
FileUtil.copyDir(testData, tempDir);
|
||||
ProjectConversionTestUtil.convert(tempDir.toPath().toAbsolutePath());
|
||||
File expectedDataDir = PathManagerEx.findFileUnderProjectHome(testDataPath + "after", getClass());
|
||||
PlatformTestUtil.assertDirectoriesEqual(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(expectedDataDir),
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir),
|
||||
file -> !file.getName().startsWith(ProjectConversionUtil.PROJECT_FILES_BACKUP));
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.appengine.highlighting;
|
||||
|
||||
import com.intellij.appengine.AppEngineCodeInsightTestCase;
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import com.intellij.xml.util.CheckXmlFileWithXercesValidatorInspection;
|
||||
|
||||
@TestDataPath("$CONTENT_ROOT/testData/highlighting/descriptor/")
|
||||
public class AppEngineDescriptorHighlightingTest extends AppEngineCodeInsightTestCase {
|
||||
public void testAppEngineWeb() {
|
||||
myCodeInsightFixture.configureByFile("appengine-web.xml");
|
||||
checkXmlHighlighting();
|
||||
}
|
||||
|
||||
public void testJdoConfig() {
|
||||
myCodeInsightFixture.configureByFile("jdoconfig.xml");
|
||||
checkXmlHighlighting();
|
||||
}
|
||||
|
||||
public void testApplication() {
|
||||
myCodeInsightFixture.configureByFile("appengine-application.xml");
|
||||
checkXmlHighlighting();
|
||||
}
|
||||
|
||||
private void checkXmlHighlighting() {
|
||||
myCodeInsightFixture.enableInspections(CheckXmlFileWithXercesValidatorInspection.class);
|
||||
myCodeInsightFixture.checkHighlighting();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBaseDirectoryPath() {
|
||||
return "highlighting/descriptor";
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# suppress inspection "WrongPropertyKeyValueDelimiter" for whole file
|
||||
[APP_ENGINE_TESTS]
|
||||
com.intellij.appengine.*
|
||||
Reference in New Issue
Block a user