diff --git a/platform/lang-impl/src/com/intellij/conversion/impl/ProjectConversionUtil.java b/platform/lang-impl/src/com/intellij/conversion/impl/ProjectConversionUtil.java
index 34cd3d0e1d4a..8624ca5478d8 100644
--- a/platform/lang-impl/src/com/intellij/conversion/impl/ProjectConversionUtil.java
+++ b/platform/lang-impl/src/com/intellij/conversion/impl/ProjectConversionUtil.java
@@ -27,7 +27,7 @@ import java.util.Collection;
* @author nik
*/
public class ProjectConversionUtil {
- @NonNls private static final String PROJECT_FILES_BACKUP = "projectFilesBackup";
+ @NonNls public static final String PROJECT_FILES_BACKUP = "projectFilesBackup";
@NonNls private static final String BACKUP_EXTENSION = "backup";
private ProjectConversionUtil() {
diff --git a/plugins/google-app-engine/resources/META-INF/google-app-engine-plugin.xml b/plugins/google-app-engine/resources/META-INF/google-app-engine-plugin.xml
index 8df1b9c352e8..9ce7afc50bb8 100644
--- a/plugins/google-app-engine/resources/META-INF/google-app-engine-plugin.xml
+++ b/plugins/google-app-engine/resources/META-INF/google-app-engine-plugin.xml
@@ -11,6 +11,7 @@
+
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/converter/AppEngineFacetConverterProvider.java b/plugins/google-app-engine/source/com/intellij/appengine/converter/AppEngineFacetConverterProvider.java
new file mode 100644
index 000000000000..a970ab659744
--- /dev/null
+++ b/plugins/google-app-engine/source/com/intellij/appengine/converter/AppEngineFacetConverterProvider.java
@@ -0,0 +1,90 @@
+/*
+ * 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.converter;
+
+import com.intellij.appengine.facet.AppEngineFacetType;
+import com.intellij.conversion.*;
+import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.util.containers.ContainerUtil;
+import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jps.model.serialization.facet.JpsFacetSerializer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author nik
+ */
+public class AppEngineFacetConverterProvider extends ConverterProvider {
+ public AppEngineFacetConverterProvider() {
+ super("google-app-engine-facet");
+ }
+
+ @NotNull
+ @Override
+ public ProjectConverter createConverter(@NotNull ConversionContext context) {
+ return new ProjectConverter() {
+ @Nullable
+ @Override
+ public ConversionProcessor createModuleFileConverter() {
+ return new GoogleAppEngineFacetConversionProcessor();
+ }
+ };
+ }
+
+ @NotNull
+ @Override
+ public String getConversionDescription() {
+ return "Google App Engine facets will be decoupled from Web facets";
+ }
+
+ private static class GoogleAppEngineFacetConversionProcessor extends ConversionProcessor {
+
+ @Override
+ public boolean isConversionNeeded(ModuleSettings settings) {
+ return !getAppEngineFacetTags(settings).isEmpty();
+ }
+
+ @Override
+ public void process(ModuleSettings settings) throws CannotConvertException {
+ List 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, (Element)configuration.clone());
+ }
+ }
+
+ @NotNull
+ private static List getAppEngineFacetTags(@NotNull ModuleSettings settings) {
+ List appEngineFacetTags = new ArrayList();
+ for (Element webFacetTag : settings.getFacetElements("web")) {
+ for (Element childFacetTag : JDOMUtil.getChildren(webFacetTag, JpsFacetSerializer.FACET_TAG)) {
+ if (AppEngineFacetType.STRING_ID.equals(childFacetTag.getAttributeValue(JpsFacetSerializer.TYPE_ATTRIBUTE))) {
+ appEngineFacetTags.add(childFacetTag);
+ }
+ }
+ }
+ return appEngineFacetTags;
+ }
+ }
+}
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineFacetType.java b/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineFacetType.java
index 68c3ba93de32..3a43335baedb 100644
--- a/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineFacetType.java
+++ b/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineFacetType.java
@@ -30,8 +30,10 @@ import javax.swing.*;
* @author nik
*/
public class AppEngineFacetType extends FacetType {
+ public static final String STRING_ID = "google-app-engine";
+
public AppEngineFacetType() {
- super(AppEngineFacet.ID, "google-app-engine", "Google App Engine");
+ super(AppEngineFacet.ID, STRING_ID, "Google App Engine");
}
public AppEngineFacetConfiguration createDefaultConfiguration() {
diff --git a/plugins/google-app-engine/testData/conversion/appEngineFacet/after/.idea/modules.xml b/plugins/google-app-engine/testData/conversion/appEngineFacet/after/.idea/modules.xml
new file mode 100644
index 000000000000..f4bc20a811f3
--- /dev/null
+++ b/plugins/google-app-engine/testData/conversion/appEngineFacet/after/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/plugins/google-app-engine/testData/conversion/appEngineFacet/after/appEngineGuestbook.iml b/plugins/google-app-engine/testData/conversion/appEngineFacet/after/appEngineGuestbook.iml
new file mode 100644
index 000000000000..df0677eccba6
--- /dev/null
+++ b/plugins/google-app-engine/testData/conversion/appEngineFacet/after/appEngineGuestbook.iml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JPA
+ true
+ $USER_HOME$/applications/appengine-java-sdk-1.7.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/google-app-engine/testData/conversion/appEngineFacet/before/.idea/modules.xml b/plugins/google-app-engine/testData/conversion/appEngineFacet/before/.idea/modules.xml
new file mode 100644
index 000000000000..f4bc20a811f3
--- /dev/null
+++ b/plugins/google-app-engine/testData/conversion/appEngineFacet/before/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/plugins/google-app-engine/testData/conversion/appEngineFacet/before/appEngineGuestbook.iml b/plugins/google-app-engine/testData/conversion/appEngineFacet/before/appEngineGuestbook.iml
new file mode 100644
index 000000000000..251f829501c5
--- /dev/null
+++ b/plugins/google-app-engine/testData/conversion/appEngineFacet/before/appEngineGuestbook.iml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JPA
+ true
+ $USER_HOME$/applications/appengine-java-sdk-1.7.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/google-app-engine/testSource/com/intellij/appengine/converter/AppEngineFacetConverterTest.java b/plugins/google-app-engine/testSource/com/intellij/appengine/converter/AppEngineFacetConverterTest.java
new file mode 100644
index 000000000000..48342541d027
--- /dev/null
+++ b/plugins/google-app-engine/testSource/com/intellij/appengine/converter/AppEngineFacetConverterTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.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.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileFilter;
+import com.intellij.testFramework.PlatformTestCase;
+import com.intellij.testFramework.PlatformTestUtil;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author nik
+ */
+public class AppEngineFacetConverterTest extends PlatformTestCase {
+ 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.getAbsolutePath());
+ File expectedDataDir = PathManagerEx.findFileUnderProjectHome(testDataPath + "after", getClass());
+ PlatformTestUtil.assertDirectoriesEqual(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(expectedDataDir),
+ LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir),
+ new VirtualFileFilter() {
+ @Override
+ public boolean accept(VirtualFile file) {
+ return !file.getName().startsWith(ProjectConversionUtil.PROJECT_FILES_BACKUP);
+ }
+ });
+ }
+}