From 8d683f4dc615a8cebb1aaa0ff8d3772fda3a6a95 Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Mon, 4 Aug 2014 11:41:12 +0400 Subject: [PATCH] gradle: war artifact generation, war overlay support fix --- .../test/ExternalSystemTestCase.java | 9 +++++--- .../builder/WarModelBuilderImpl.groovy | 21 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java index 770578ae44f5..449de84f4627 100644 --- a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/test/ExternalSystemTestCase.java @@ -39,6 +39,7 @@ import com.intellij.openapi.roots.ModuleRootModificationUtil; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.impl.compiler.ArtifactCompileScope; @@ -455,9 +456,11 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase { } protected void assertArtifactOutput(String artifactName, TestFileSystemItem fs) { - final String outputPath = ArtifactsTestUtil.findArtifact(myProject, artifactName).getOutputPath(); - assert outputPath != null; - fs.assertDirectoryEqual(new File(outputPath)); + final Artifact artifact = ArtifactsTestUtil.findArtifact(myProject, artifactName); + final VirtualFile outputFile = artifact.getOutputFile(); + assert outputFile != null; + final File file = VfsUtilCore.virtualToIoFile(outputFile); + fs.assertFileEqual(file); } private static void setFileContent(final VirtualFile file, final String content, final boolean advanceStamps) throws IOException { diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/WarModelBuilderImpl.groovy b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/WarModelBuilderImpl.groovy index 00f4c8bb0b6e..2eb7137949e2 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/WarModelBuilderImpl.groovy +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/WarModelBuilderImpl.groovy @@ -88,20 +88,25 @@ class WarModelBuilderImpl implements ModelBuilderService { if (resolver.metaClass.respondsTo(resolver, 'getSourcePaths')) { sourcePaths = resolver.getSourcePaths() - } else if (resolver.this$0.metaClass.respondsTo(resolver, 'getSourcePaths')) { + } else if (resolver.hasProperty('sourcePaths')) { + sourcePaths = resolver.sourcePaths + } else if (resolver.hasProperty('this$0') && resolver.this$0.metaClass.respondsTo(resolver, 'getSourcePaths')) { sourcePaths = resolver.this$0.getSourcePaths() - } else { + } else if (resolver.hasProperty('this$0') && resolver.this$0.hasProperty('sourcePaths')) { + sourcePaths = resolver.this$0.sourcePaths + } /*else { throw new RuntimeException("${GradleVersion.current()} is not supported by web artifact importer") - } + }*/ - (sourcePaths.flatten() as List).each { def path -> - if (path instanceof String) { - def file = new File(warTask.project.projectDir, path) - addPath(webResources, relativePath, "", file) + if(sourcePaths) { + (sourcePaths.flatten() as List).each { def path -> + if (path instanceof String) { + def file = new File(warTask.project.projectDir, path) + addPath(webResources, relativePath, "", file) + } } } - resolver.source.visit(new FileVisitor() { @Override public void visitDir(FileVisitDetails dirDetails) {