gradle: remove obsolete code - usage of resourceDirs/testResourceDirs ext properties
authorVladislav.Soroka <Vladislav.Soroka@jetbrains.com>
Thu, 27 Nov 2014 13:00:51 +0000 (16:00 +0300)
committerVladislav.Soroka <Vladislav.Soroka@jetbrains.com>
Mon, 8 Dec 2014 09:00:10 +0000 (12:00 +0300)
plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/ModuleExtendedModelBuilderImpl.java
plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/internal/init/init.gradle
plugins/gradle/tooling-extension-impl/testData/testGradleSourcesSetsInterpretation/build.gradle
plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ModuleExtendedModelBuilderImplTest.java

index e52f8c01a083845bada27d3a0f0cb769768a2e16..214dad27db0ec0ea99b43c8dbbdaddd2910b99de 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.jetbrains.plugins.gradle.tooling.builder;
 
-import groovy.lang.GroovyObject;
 import org.gradle.api.Project;
 import org.gradle.api.Task;
 import org.gradle.api.tasks.SourceSet;
@@ -134,12 +133,9 @@ public class ModuleExtendedModelBuilderImpl implements ModelBuilderService {
     final Set<String> ideaSourceDirectories = new HashSet<String>();
     final Set<String> ideaTestDirectories = new HashSet<String>();
     final Set<String> ideaGeneratedDirectories = new HashSet<String>();
-    final Set<String> ideaExtResourceDirectories = new HashSet<String>();
-    final Set<String> ideaExtTestResourceDirectories = new HashSet<String>();
     final Set<File> excludeDirectories = new HashSet<File>();
 
-    enrichDataFromIdeaPlugin(project, excludeDirectories, ideaSourceDirectories, ideaTestDirectories,
-                             ideaExtResourceDirectories, ideaExtTestResourceDirectories, ideaGeneratedDirectories);
+    enrichDataFromIdeaPlugin(project, excludeDirectories, ideaSourceDirectories, ideaTestDirectories, ideaGeneratedDirectories);
 
     if (ideaSourceDirectories.isEmpty()) {
       sourceDirectories.clear();
@@ -156,11 +152,6 @@ public class ModuleExtendedModelBuilderImpl implements ModelBuilderService {
     ideaTestDirectories.removeAll(testResourceDirectories);
     testDirectories.addAll(ideaTestDirectories);
 
-    resourceDirectories.removeAll(ideaExtTestResourceDirectories);
-    resourceDirectories.addAll(ideaExtResourceDirectories);
-    testResourceDirectories.removeAll(ideaExtResourceDirectories);
-    testResourceDirectories.addAll(ideaExtTestResourceDirectories);
-
     // ensure disjoint directories with different type
     resourceDirectories.removeAll(sourceDirectories);
     testDirectories.removeAll(sourceDirectories);
@@ -224,8 +215,6 @@ public class ModuleExtendedModelBuilderImpl implements ModelBuilderService {
                                                Set<File> excludeDirectories,
                                                Set<String> javaDirectories,
                                                Set<String> testDirectories,
-                                               Set<String> ideaExtResourceDirectories,
-                                               Set<String> ideaExtTestResourceDirectories,
                                                Set<String> ideaGeneratedDirectories) {
 
     IdeaPlugin ideaPlugin = project.getPlugins().getPlugin(IdeaPlugin.class);
@@ -249,25 +238,5 @@ public class ModuleExtendedModelBuilderImpl implements ModelBuilderService {
         ideaGeneratedDirectories.add(file.getPath());
       }
     }
-
-    ideaExtResourceDirectories.addAll(getExtDirs("resourceDirs", ideaModel.getModule()));
-    ideaExtTestResourceDirectories.addAll(getExtDirs("testResourceDirs", ideaModel.getModule()));
-  }
-
-  private static List<String> getExtDirs(String propertyName, GroovyObject ideaModule) {
-    List<String> directories = new ArrayList<String>();
-    Object resourceDirs = ideaModule.getProperty(propertyName);
-    if (resourceDirs instanceof Iterable) {
-      for (Object o : Iterable.class.cast(resourceDirs)) {
-        if (o instanceof File) {
-          directories.add(File.class.cast(o).getPath());
-        }
-        else if (o instanceof String) {
-          directories.add((String)o);
-        }
-      }
-    }
-
-    return directories;
   }
 }
index d9c1e3bc538e53ae08686ded342cc68b94cfa391..a08155c0d0017766dc879452c9973d2631eb9046 100644 (file)
@@ -35,10 +35,6 @@ try {
   URLClassLoader classLoader = new URLClassLoader(urls, getClass().classLoader)
   Class modelClass = classLoader.loadClass('org.jetbrains.plugins.gradle.tooling.internal.ExtraModelBuilder')
   allprojects {
-    apply plugin: 'idea'
-    idea.module.ext.set('resourceDirs', [])
-    idea.module.ext.set('testResourceDirs', [])
-
     ext.jetExtraModelBuilderClass = modelClass
     apply plugin: JetGradlePlugin
   }
index 21dd96dfbefe0164b64f47856a3c29ed1a10eef0..f0d130c1b56a875631ceba89ad0a0caee5143a84 100644 (file)
@@ -56,6 +56,7 @@ project("withIntegrationTests") {
 
 project("withIdeaPluginCustomization1") {
   apply plugin: 'java'
+  apply plugin: 'idea'
 
   idea {
     module {
@@ -69,13 +70,12 @@ project("withIdeaPluginCustomization1") {
 // see http://youtrack.jetbrains.com/issue/IDEA-119365
 project("withIdeaPluginCustomization2") {
   apply plugin: 'java'
+  apply plugin: 'idea'
 
   idea {
     module {
       sourceDirs += testSourceDirs
       testSourceDirs = []
-      ext.resourceDirs += file('some-extra-resource-folder')
-      ext.testResourceDirs += file('some-extra-test-resource-folder')
     }
   }
 }
@@ -89,8 +89,6 @@ project("withIdeaPluginCustomization3") {
     module {
       sourceDirs += file('src/main/java')
       testSourceDirs += file('src/awesome-test/java')
-      testSourceDirs += file('src/awesome-with-resource-test/java')
-      ext.testResourceDirs += file('src/awesome-with-resource-test/resources')
     }
   }
 
@@ -101,10 +99,5 @@ project("withIdeaPluginCustomization3") {
       }
       compileClasspath += sourceSets.main.runtimeClasspath
     }
-    'awesome-with-resource-test' {
-      java {
-        srcDir 'src/awesome-with-resource-test/java'
-      }
-    }
   }
 }
index 8a1936a51dfb31d15046f8eea3901ae142d95af1..c8e604c7fc55582b8eed2fa3bf179e7c98f0730e 100644 (file)
@@ -118,19 +118,16 @@ public class ModuleExtendedModelBuilderImplTest extends AbstractModelBuilderTest
           }
           else if (module.getName().equals("withIdeaPluginCustomization2")) {
             assertEquals(ContainerUtil.newArrayList("src/main/java", "src/test/java", "src/test/resources"), sourceDirectories);
-            assertEquals(ContainerUtil.newArrayList("some-extra-resource-folder", "src/main/resources"), resourceDirectories);
+            assertEquals(ContainerUtil.newArrayList("src/main/resources"), resourceDirectories);
             assertTrue(testDirectories.isEmpty());
-            assertEquals(ContainerUtil.newArrayList("some-extra-test-resource-folder"), testResourceDirectories);
+            assertTrue(testResourceDirectories.isEmpty());
             assertEquals(ContainerUtil.newArrayList(".gradle", "build"), excludeDirectories);
           }
           else if (module.getName().equals("withIdeaPluginCustomization3")) {
             assertEquals(ContainerUtil.newArrayList("src/main/java"), sourceDirectories);
-            assertEquals(ContainerUtil.newArrayList(
-              "src/awesome-test/resources", "src/main/resources"), resourceDirectories);
-            assertEquals(ContainerUtil.newArrayList(
-              "src/awesome-test/java", "src/awesome-with-resource-test/java", "src/test/java"), testDirectories);
-            assertEquals(ContainerUtil.newArrayList(
-              "src/awesome-with-resource-test/resources", "src/test/resources"), testResourceDirectories);
+            assertEquals(ContainerUtil.newArrayList("src/awesome-test/resources", "src/main/resources"), resourceDirectories);
+            assertEquals(ContainerUtil.newArrayList("src/awesome-test/java", "src/test/java"), testDirectories);
+            assertEquals(ContainerUtil.newArrayList("src/test/resources"), testResourceDirectories);
             assertEquals(ContainerUtil.newArrayList(".gradle", "build"), excludeDirectories);
           }
           else {