diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/javaee/JavaEEGradleProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/javaee/JavaEEGradleProjectResolverExtension.java index 805c8ff08d21..9779d6eab523 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/javaee/JavaEEGradleProjectResolverExtension.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/integrations/javaee/JavaEEGradleProjectResolverExtension.java @@ -25,7 +25,10 @@ import com.intellij.util.containers.ContainerUtil; import org.gradle.tooling.model.idea.IdeaModule; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.model.WebConfiguration; +import org.jetbrains.plugins.gradle.model.data.War; +import org.jetbrains.plugins.gradle.model.data.WarDirectory; import org.jetbrains.plugins.gradle.model.data.WebConfigurationModelData; +import org.jetbrains.plugins.gradle.model.data.WebResource; import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension; import org.jetbrains.plugins.gradle.util.GradleConstants; @@ -47,13 +50,14 @@ public class JavaEEGradleProjectResolverExtension extends AbstractProjectResolve public void populateModuleExtraModels(@NotNull IdeaModule gradleModule, @NotNull DataNode ideModule) { final WebConfiguration webConfiguration = resolverCtx.getExtraProject(gradleModule, WebConfiguration.class); if (webConfiguration != null) { - List warModels = - ContainerUtil.map(webConfiguration.getWarModels(), new Function() { + List warModels = + ContainerUtil.map(webConfiguration.getWarModels(), new Function() { @Override - public WebConfigurationModelData.War fun(WebConfiguration.WarModel model) { - WebConfigurationModelData.War war = new WebConfigurationModelData.War(model.getWarName(), model.getWebAppDirName(), model.getWebAppDir()); + public War fun(WebConfiguration.WarModel model) { + War war = + new War(model.getWarName(), model.getWebAppDirName(), model.getWebAppDir()); war.setWebXml(model.getWebXml()); - war.setWebRoots(model.getWebRoots()); + war.setWebResources(map(model.getWebResources())); war.setClasspath(model.getClasspath()); war.setManifestContent(model.getManifestContent()); return war; @@ -71,4 +75,18 @@ public class JavaEEGradleProjectResolverExtension extends AbstractProjectResolve public Set getExtraProjectModelClasses() { return Collections.singleton(WebConfiguration.class); } + + private static List map(List webResources) { + return ContainerUtil.mapNotNull(webResources, new Function() { + @Override + public WebResource fun(WebConfiguration.WebResource resource) { + if (resource == null) return null; + + final WarDirectory warDirectory = + WarDirectory.fromPath(resource.getWarDirectory()); + if (warDirectory == null) return null; + return new WebResource(warDirectory, resource.getRelativePath(), resource.getFile()); + } + }); + } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/War.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/War.java new file mode 100644 index 000000000000..b73add7f103a --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/War.java @@ -0,0 +1,142 @@ +/* + * 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 org.jetbrains.plugins.gradle.model.data; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** +* @author Vladislav.Soroka +* @since 2/10/14 +*/ +public class War { + + @NotNull + private final String myName; + + @NotNull + private final String myWebAppDirName; + @NotNull + private final File myWebAppDir; + @Nullable + private File myWebXml; + @NotNull + private List myWebResources; + @NotNull + private Set myClasspath; + @Nullable + private String myManifestContent; + + + public War(@NotNull String name, @NotNull String webAppDirName, @NotNull File webAppDir) { + myName = name; + myWebAppDirName = webAppDirName; + myWebAppDir = webAppDir; + myWebResources = Collections.emptyList(); + myClasspath = Collections.emptySet(); + } + + @NotNull + public String getName() { + return myName; + } + + @NotNull + public String getWebAppDirName() { + return myWebAppDirName; + } + + @NotNull + public File getWebAppDir() { + return myWebAppDir; + } + + public void setWebXml(@Nullable File webXml) { + myWebXml = webXml; + } + + @Nullable + public File getWebXml() { + return myWebXml; + } + + public void setWebResources(@Nullable List webResources) { + myWebResources = webResources == null ? Collections.emptyList() : webResources; + } + + @NotNull + public List getWebResources() { + return myWebResources; + } + + public void setClasspath(@Nullable Set classpath) { + myClasspath = classpath == null ? Collections.emptySet() : classpath; + } + + @NotNull + public Set getClasspath() { + return myClasspath; + } + + public void setManifestContent(@Nullable String manifestContent) { + myManifestContent = manifestContent; + } + + @Nullable + public String getManifestContent() { + return myManifestContent; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + + War that = (War)o; + + if (!myName.equals(that.myName)) return false; + if (!myWebAppDirName.equals(that.myWebAppDirName)) return false; + if (!myWebResources.equals(that.myWebResources)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + myName.hashCode(); + result = 31 * result + myWebAppDirName.hashCode(); + result = 31 * result + myWebResources.hashCode(); + return result; + } + + @Override + public String toString() { + return "War{" + + "myName='" + myName + '\'' + + ", myWebAppDirName='" + myWebAppDirName + '\'' + + ", myWebAppDir=" + myWebAppDir + + ", myWebXml=" + myWebXml + + ", myWebResources=" + myWebResources + + '}'; + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WarDirectory.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WarDirectory.java new file mode 100644 index 000000000000..b59dcbb12d57 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WarDirectory.java @@ -0,0 +1,75 @@ +/* + * 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 org.jetbrains.plugins.gradle.model.data; + +import com.intellij.openapi.util.text.StringUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Vladislav.Soroka + * @since 2/10/14 + */ +public enum WarDirectory { + /** + * Public files typically include the following: + * HTML files. + * JSP files. + * Image files and other multimedia files -- it is a common convention to store image files in an images subdirectory. + */ + WAR_ROOT("/"), + /** + * directory can contain the following file: + * META-INF/MANIFEST.MF -- an optional file that can be used to specify additional meta-information for the WAR. + */ + META_INF("/META-INF"), + /** + * Directory contains a Web archive's private files and directories. + * That is, when the Web archive is deployed, the files and directories under the WEB-INF/ directory cannot be accessed directly by Web clients. + */ + WEB_INF("/WEB-INF"), + /** + * Subdirectory can store JAR files used by the Web module. + * The JAR files in this directory are automatically accessible to the Web module without needing to be added to the class path. + */ + WEB_INF_LIB("/WEB-INF/lib"), + /** + * Subdirectory contains the compiled Java code for the Web module. + */ + WEB_INF_CLASSES("/WEB-INF/classes"); + @NotNull + private final String myRelativePath; + + WarDirectory(@NotNull final String relativePath) { + myRelativePath = relativePath; + } + + @NotNull + public String getRelativePath() { + return myRelativePath; + } + + @Nullable + public static WarDirectory fromPath(final @NotNull String path) { + if (StringUtil.isEmpty(path)) return WAR_ROOT; + + final String adjustedPath = path.charAt(0) != '/' ? '/' + path : path; + for (WarDirectory warDirectory : values()) { + if (warDirectory.myRelativePath.equals(adjustedPath)) return warDirectory; + } + return null; + } +} diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WebConfigurationModelData.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WebConfigurationModelData.java index 92097ab79d7a..6874703acd10 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WebConfigurationModelData.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WebConfigurationModelData.java @@ -20,13 +20,8 @@ import com.intellij.openapi.externalSystem.model.ProjectKeys; import com.intellij.openapi.externalSystem.model.ProjectSystemId; import com.intellij.openapi.externalSystem.model.project.AbstractExternalEntityData; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.io.File; -import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.Set; /** * @author Vladislav.Soroka @@ -36,7 +31,8 @@ public class WebConfigurationModelData extends AbstractExternalEntityData { private static final long serialVersionUID = 1L; @NotNull - public static final Key KEY = Key.create(WebConfigurationModelData.class, ProjectKeys.LIBRARY_DEPENDENCY.getProcessingWeight() + 1); + public static final Key KEY = + Key.create(WebConfigurationModelData.class, ProjectKeys.LIBRARY_DEPENDENCY.getProcessingWeight() + 1); @NotNull private final List myWars; @@ -51,120 +47,6 @@ public class WebConfigurationModelData extends AbstractExternalEntityData { return myWars; } - public static class War { - - @NotNull - private final String myName; - - @NotNull - private final String myWebAppDirName; - @NotNull - private final File myWebAppDir; - @Nullable - private File myWebXml; - @NotNull - private Map> myWebRoots; - @NotNull - private Set myClasspath; - @Nullable - private String myManifestContent; - - - public War(@NotNull String name, @NotNull String webAppDirName, @NotNull File webAppDir) { - myName = name; - myWebAppDirName = webAppDirName; - myWebAppDir = webAppDir; - myWebRoots = Collections.emptyMap(); - myClasspath = Collections.emptySet(); - } - - @NotNull - public String getName() { - return myName; - } - - @NotNull - public String getWebAppDirName() { - return myWebAppDirName; - } - - @NotNull - public File getWebAppDir() { - return myWebAppDir; - } - - public void setWebXml(@Nullable File webXml) { - myWebXml = webXml; - } - - @Nullable - public File getWebXml() { - return myWebXml; - } - - public void setWebRoots(@Nullable Map> webRoots) { - myWebRoots = webRoots == null ? Collections.>emptyMap() : webRoots; - } - - @NotNull - public Map> getWebRoots() { - return myWebRoots; - } - - public void setClasspath(@Nullable Set classpath) { - myClasspath = classpath == null ? Collections.emptySet() : classpath; - } - - @NotNull - public Set getClasspath() { - return myClasspath; - } - - public void setManifestContent(@Nullable String manifestContent) { - myManifestContent = manifestContent; - } - - @Nullable - public String getManifestContent() { - return myManifestContent; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - War that = (War)o; - - if (!myName.equals(that.myName)) return false; - if (!myWebAppDirName.equals(that.myWebAppDirName)) return false; - if (!myWebRoots.equals(that.myWebRoots)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + myName.hashCode(); - result = 31 * result + myWebAppDirName.hashCode(); - result = 31 * result + myWebRoots.hashCode(); - return result; - } - - @Override - public String toString() { - return "War{" + - "myName='" + myName + '\'' + - ", myWebAppDirName='" + myWebAppDirName + '\'' + - ", myWebAppDir=" + myWebAppDir + - ", myWebXml=" + myWebXml + - ", myWebRoots=" + myWebRoots + - '}'; - } - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WebResource.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WebResource.java new file mode 100644 index 000000000000..573509e68505 --- /dev/null +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/model/data/WebResource.java @@ -0,0 +1,84 @@ +/* + * 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 org.jetbrains.plugins.gradle.model.data; + +import org.jetbrains.annotations.NotNull; + +import java.io.File; + +/** +* @author Vladislav.Soroka +* @since 2/10/14 +*/ +public class WebResource { + @NotNull + private final WarDirectory myWarDirectory; + @NotNull + private final String warRelativePath; + @NotNull + private final File file; + + public WebResource(@NotNull WarDirectory warDirectory, @NotNull String warRelativePath, @NotNull File file) { + myWarDirectory = warDirectory; + this.warRelativePath = warRelativePath; + this.file = file; + } + + @NotNull + public WarDirectory getWarDirectory() { + return myWarDirectory; + } + + @NotNull + public String getWarRelativePath() { + return warRelativePath; + } + + @NotNull + public File getFile() { + return file; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof WebResource)) return false; + + WebResource resource = (WebResource)o; + if (!file.getPath().equals(resource.file.getPath())) return false; + if (myWarDirectory != resource.myWarDirectory) return false; + if (!warRelativePath.equals(resource.warRelativePath)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = myWarDirectory.hashCode(); + result = 31 * result + warRelativePath.hashCode(); + result = 31 * result + file.getPath().hashCode(); + return result; + } + + @Override + public String toString() { + return "WebResource{" + + "myWarDirectory=" + myWarDirectory + + ", warRelativePath='" + warRelativePath + '\'' + + ", file=" + file + + '}'; + } +} diff --git a/plugins/gradle/tooling-extension-v1.9/src/org/jetbrains/plugins/gradle/tooling/v1_9/builder/WarModelBuilderImpl.java b/plugins/gradle/tooling-extension-v1.9/src/org/jetbrains/plugins/gradle/tooling/v1_9/builder/WarModelBuilderImpl.java index a0558e6a164f..20606533fd3a 100644 --- a/plugins/gradle/tooling-extension-v1.9/src/org/jetbrains/plugins/gradle/tooling/v1_9/builder/WarModelBuilderImpl.java +++ b/plugins/gradle/tooling-extension-v1.9/src/org/jetbrains/plugins/gradle/tooling/v1_9/builder/WarModelBuilderImpl.java @@ -27,11 +27,14 @@ import org.gradle.api.tasks.bundling.War; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.gradle.model.WebConfiguration; import org.jetbrains.plugins.gradle.tooling.ModelBuilderService; +import org.jetbrains.plugins.gradle.tooling.internal.WarModelImpl; import org.jetbrains.plugins.gradle.tooling.internal.WebConfigurationImpl; +import org.jetbrains.plugins.gradle.tooling.internal.WebResourceImpl; import java.io.File; import java.io.StringWriter; -import java.util.*; +import java.util.ArrayList; +import java.util.List; /** * @author Vladislav.Soroka @@ -66,14 +69,13 @@ public class WarModelBuilderImpl implements ModelBuilderService { for (Task task : project.getTasks()) { if (task instanceof War) { - final WebConfigurationImpl.WarModelImpl warModel = new WebConfigurationImpl.WarModelImpl(((War)task).getArchiveName(), webAppDirName, webAppDir); + final WarModelImpl warModel = + new WarModelImpl(((War)task).getArchiveName(), webAppDirName, webAppDir); + final List webResources = new ArrayList(); final War warTask = (War)task; warModel.setWebXml(warTask.getWebXml()); - final Map> webRoots = new HashMap>(); - addPath(webRoots, "", webAppDir.getPath()); - warTask.getRootSpec().walk(new Action() { @Override public void execute(CopySpecInternal internal) { @@ -82,7 +84,7 @@ public class WarModelBuilderImpl implements ModelBuilderService { @Override public void visitDir(FileVisitDetails dirDetails) { try { - addPath(webRoots, relativePath, dirDetails.getFile().getPath()); + addPath(webResources, relativePath, dirDetails.getPath(), dirDetails.getFile()); } catch (Exception ignore) { } @@ -93,7 +95,7 @@ public class WarModelBuilderImpl implements ModelBuilderService { try { if (warTask.getWebXml() == null || !fileDetails.getFile().getCanonicalPath().equals(warTask.getWebXml().getCanonicalPath())) { - addPath(webRoots, relativePath, fileDetails.getFile().getParent()); + addPath(webResources, relativePath, fileDetails.getPath(), fileDetails.getFile()); } } catch (Exception ignore) { @@ -103,11 +105,11 @@ public class WarModelBuilderImpl implements ModelBuilderService { } }); - warModel.setWebRoots(webRoots); + warModel.setWebResources(webResources); warModel.setClasspath(warTask.getClasspath().getFiles()); Manifest manifest = warTask.getManifest(); - if(manifest != null) { + if (manifest != null) { StringWriter writer = new StringWriter(); manifest.writeTo(writer); warModel.setManifestContent(writer.toString()); @@ -119,13 +121,10 @@ public class WarModelBuilderImpl implements ModelBuilderService { return new WebConfigurationImpl(warModels); } - private static void addPath(Map> webRoots, String relativePath, String path) { - relativePath = relativePath == null ? "" : relativePath; - Set paths = webRoots.get(relativePath); - if (paths == null) { - paths = new LinkedHashSet(); - webRoots.put(relativePath, paths); - } - paths.add(path); + private static void addPath(List webResources, String warRelativePath, String fileRelativePath, File file) { + warRelativePath = warRelativePath == null ? "" : warRelativePath; + + WebConfiguration.WebResource webResource = new WebResourceImpl(warRelativePath, fileRelativePath, file); + webResources.add(webResource); } } diff --git a/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/model/WebConfiguration.java b/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/model/WebConfiguration.java index 6ae82dbb039d..c2ed1eb577f7 100644 --- a/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/model/WebConfiguration.java +++ b/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/model/WebConfiguration.java @@ -15,13 +15,11 @@ */ package org.jetbrains.plugins.gradle.model; -import org.gradle.tooling.model.DomainObjectSet; import org.jetbrains.annotations.NotNull; import java.io.File; import java.io.Serializable; import java.util.List; -import java.util.Map; import java.util.Set; /** @@ -42,10 +40,22 @@ public interface WebConfiguration extends Serializable { File getWebXml(); - Map> getWebRoots(); + List getWebResources(); Set getClasspath(); String getManifestContent(); } + + interface WebResource extends Serializable { + + @NotNull + String getWarDirectory(); + + @NotNull + String getRelativePath(); + + @NotNull + File getFile(); + } } diff --git a/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WarModelImpl.java b/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WarModelImpl.java new file mode 100644 index 000000000000..67d492d6f7e7 --- /dev/null +++ b/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WarModelImpl.java @@ -0,0 +1,96 @@ +/* + * 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 org.jetbrains.plugins.gradle.tooling.internal; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.gradle.model.WebConfiguration; + +import java.io.File; +import java.util.List; +import java.util.Set; + +/** +* @author Vladislav.Soroka +* @since 2/10/14 +*/ +public class WarModelImpl implements WebConfiguration.WarModel { + @NotNull + private final String warName; + private final String myWebAppDirName; + private final File myWebAppDir; + private File myWebXml; + private List myWebResources; + private Set myClasspath; + private String myManifestContent; + + public WarModelImpl(@NotNull String name, String webAppDirName, File webAppDir) { + warName = name; + myWebAppDirName = webAppDirName; + myWebAppDir = webAppDir; + } + + @NotNull + @Override + public String getWarName() { + return warName; + } + + @Override + public String getWebAppDirName() { + return myWebAppDirName; + } + + @Override + public File getWebAppDir() { + return myWebAppDir; + } + + public void setWebXml(File webXml) { + myWebXml = webXml; + } + + @Override + public File getWebXml() { + return myWebXml; + } + + @Override + public List getWebResources() { + return myWebResources; + } + + public void setWebResources(List webResources) { + myWebResources = webResources; + } + + public void setClasspath(Set classpath) { + myClasspath = classpath; + } + + @Override + public Set getClasspath() { + return myClasspath; + } + + public void setManifestContent(String manifestContent) { + myManifestContent = manifestContent; + } + + @Override + public String getManifestContent() { + return myManifestContent; + } +} diff --git a/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WebConfigurationImpl.java b/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WebConfigurationImpl.java index 1384c530152b..8c0c9a5316fd 100644 --- a/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WebConfigurationImpl.java +++ b/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WebConfigurationImpl.java @@ -20,7 +20,6 @@ import org.jetbrains.plugins.gradle.model.WebConfiguration; import java.io.File; import java.util.List; -import java.util.Map; import java.util.Set; /** @@ -40,73 +39,4 @@ public class WebConfigurationImpl implements WebConfiguration { public List getWarModels() { return myWarModels; } - - public static class WarModelImpl implements WarModel { - @NotNull - private final String warName; - private final String myWebAppDirName; - private final File myWebAppDir; - private File myWebXml; - private Map> myWebRoots; - private Set myClasspath; - private String myManifestContent; - - public WarModelImpl(@NotNull String name, String webAppDirName, File webAppDir) { - warName = name; - myWebAppDirName = webAppDirName; - myWebAppDir = webAppDir; - } - - @NotNull - @Override - public String getWarName() { - return warName; - } - - @Override - public String getWebAppDirName() { - return myWebAppDirName; - } - - @Override - public File getWebAppDir() { - return myWebAppDir; - } - - public void setWebXml(File webXml) { - myWebXml = webXml; - } - - @Override - public File getWebXml() { - return myWebXml; - } - - @Override - public Map> getWebRoots() { - return myWebRoots; - } - - public void setWebRoots(Map> webRoots) { - myWebRoots = webRoots; - } - - public void setClasspath(Set classpath) { - myClasspath = classpath; - } - - @Override - public Set getClasspath() { - return myClasspath; - } - - public void setManifestContent(String manifestContent) { - myManifestContent = manifestContent; - } - - @Override - public String getManifestContent() { - return myManifestContent; - } - } } diff --git a/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WebResourceImpl.java b/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WebResourceImpl.java new file mode 100644 index 000000000000..e449f06580d6 --- /dev/null +++ b/plugins/gradle/tooling-extension/src/org/jetbrains/plugins/gradle/tooling/internal/WebResourceImpl.java @@ -0,0 +1,88 @@ +/* + * 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 org.jetbrains.plugins.gradle.tooling.internal; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.gradle.model.WebConfiguration; + +import java.io.File; + +/** +* @author Vladislav.Soroka +* @since 2/10/14 +*/ +public class WebResourceImpl implements WebConfiguration.WebResource { + @NotNull + private final String myWarDirectory; + @NotNull + private final String myRelativePath; + @NotNull + private final File file; + + public WebResourceImpl(@NotNull String warDirectory, @NotNull String relativePath, @NotNull File file) { + myWarDirectory = warDirectory; + this.myRelativePath = relativePath; + this.file = file; + } + + @NotNull + @Override + public String getWarDirectory() { + return myWarDirectory; + } + + @NotNull + @Override + public String getRelativePath() { + return myRelativePath; + } + + @NotNull + @Override + public File getFile() { + return file; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof WebResourceImpl)) return false; + + WebResourceImpl resource = (WebResourceImpl)o; + if (!file.getPath().equals(resource.file.getPath())) return false; + if (myWarDirectory != resource.myWarDirectory) return false; + if (!myRelativePath.equals(resource.myRelativePath)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = myWarDirectory.hashCode(); + result = 31 * result + myRelativePath.hashCode(); + result = 31 * result + file.getPath().hashCode(); + return result; + } + + @Override + public String toString() { + return "WebResourceImpl{" + + "myWarDirectory=" + myWarDirectory + + ", warRelativePath='" + myRelativePath + '\'' + + ", file=" + file + + '}'; + } +}