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 34e84780ff0f..8df1b9c352e8 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 @@ -5,6 +5,8 @@ + diff --git a/plugins/google-app-engine/source/com/intellij/appengine/facet/impl/AppEngineCommunityWebIntegration.java b/plugins/google-app-engine/source/com/intellij/appengine/facet/impl/AppEngineCommunityWebIntegration.java new file mode 100644 index 000000000000..060355357829 --- /dev/null +++ b/plugins/google-app-engine/source/com/intellij/appengine/facet/impl/AppEngineCommunityWebIntegration.java @@ -0,0 +1,97 @@ +/* + * 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.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; + +/** + * @author nik + */ +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 getAppEngineTargetArtifactType() { + return PlainArtifactType.getInstance(); + } + + @Override + public void setupJpaSupport(@NotNull Module module, @NotNull VirtualFile persistenceXml) { + } + + @Override + public void setupRunConfiguration(@NotNull ModifiableRootModel rootModel, + @NotNull AppEngineSdk sdk, + @Nullable Artifact artifact, + @NotNull Project project) { + } + + @Override + public void setupDevServer(@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 getSdkForConfiguredDevServers() { + return Collections.emptyList(); + } +}