diff --git a/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/IdeaPlugin.groovy b/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/IdeaPlugin.groovy
index 04e7342..e48dd4e 100644
--- a/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/IdeaPlugin.groovy
+++ b/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/IdeaPlugin.groovy
@@ -73,6 +73,7 @@ class IdeaPlugin implements Plugin<Project> {
                 subprojects = project.rootProject.allprojects
                 javaVersion = JavaVersion.VERSION_1_6.toString()
                 wildcards = ['!?*.java', '!?*.groovy']
+                useDirConfiguration = false
             }
             project.idea.dependsOn 'ideaProject'
 
diff --git a/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/IdeaProject.groovy b/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/IdeaProject.groovy
index 5d6a0f1..3a9e531 100644
--- a/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/IdeaProject.groovy
+++ b/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/IdeaProject.groovy
@@ -57,6 +57,14 @@ public class IdeaProject extends DefaultTask {
     @Input
     Set wildcards
 
+
+
+    /**
+    *  switch beween dir- and file-based configuration output
+     */
+    @Input
+    Boolean useDirConfiguration = false
+
     private ListenerBroadcast<Action> beforeConfiguredActions = new ListenerBroadcast<Action>(Action.class);
     private ListenerBroadcast<Action> whenConfiguredActions = new ListenerBroadcast<Action>(Action.class);
     private ListenerBroadcast<Action> withXmlActions = new ListenerBroadcast<Action>(Action.class);
@@ -75,6 +83,13 @@ public class IdeaProject extends DefaultTask {
             }
         }
         Project ideaProject = new Project(modules, javaVersion, wildcards, xmlreader, beforeConfiguredActions, whenConfiguredActions, withXmlActions)
+        ideaProject.useDirConfiguration = useDirConfiguration
+        
+        if(useDirConfiguration){
+            ideaProject.toXmlDirectory(new File(project.projectDir,".idea/modules.xml"), new File(project.projectDir,".idea/misc.xml"))
+            return
+        }
+
         ideaProject.toXml(new FileWriter(outputFile))
     }
 
diff --git a/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/model/Project.groovy b/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/model/Project.groovy
index c002ede..c52d1ed 100644
--- a/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/model/Project.groovy
+++ b/subprojects/gradle-idea/src/main/groovy/org/gradle/plugins/idea/model/Project.groovy
@@ -15,8 +15,8 @@
  */
 package org.gradle.plugins.idea.model
 
-import org.gradle.listener.ListenerBroadcast
 import org.gradle.api.Action
+import org.gradle.listener.ListenerBroadcast
 
 /**
  * Represents the customizable elements of an ipr (via XML hooks everything of the ipr is customizable).
@@ -25,7 +25,7 @@ import org.gradle.api.Action
  */
 class Project {
     /**
-     * A set of {@link ModulePath} instances pointing to the modules contained in the ipr.
+     * A set of         {@link ModulePath}         instances pointing to the modules contained in the ipr.
      */
     Set modulePaths = []
 
@@ -39,21 +39,25 @@ class Project {
      */
     Jdk jdk
 
+    Boolean useDirConfiguration = false
+
     private Node xml
-    
+
     private ListenerBroadcast<Action> withXmlActions
 
     def Project(Set modulePaths, String javaVersion, Set wildcards, Reader inputXml, ListenerBroadcast<Action> beforeConfiguredActions,
                 ListenerBroadcast<Action> whenConfiguredActions, ListenerBroadcast<Action> withXmlActions) {
-        initFromXml(inputXml, javaVersion)
+        if (!useDirConfiguration) {
+            initFromXml(inputXml, javaVersion)
 
-        beforeConfiguredActions.source.execute(this)
+            beforeConfiguredActions.source.execute(this)
 
-        this.modulePaths.addAll(modulePaths)
-        this.wildcards.addAll(wildcards)
-        this.withXmlActions = withXmlActions
+            this.modulePaths.addAll(modulePaths)
+            this.wildcards.addAll(wildcards)
+            this.withXmlActions = withXmlActions
 
-        whenConfiguredActions.source.execute(this)
+            whenConfiguredActions.source.execute(this)
+        }
     }
 
     private def initFromXml(Reader inputXml, String javaVersion) {
@@ -67,14 +71,67 @@ class Project {
         findWildcardResourcePatterns().entry.each { entry ->
             this.wildcards.add(entry.@name)
         }
-        def jdkValues = findProjectRootManager().attributes()
+        def jdkValues = findProjectRootManager(xml).attributes()
 
         if (javaVersion) {
             jdk = new Jdk(javaVersion)
         } else {
             jdk = new Jdk(Boolean.parseBoolean(jdkValues.'assert-keyword'), Boolean.parseBoolean(jdkValues.'jdk-15'),
-                          jdkValues.languageLevel, jdkValues.'project-jdk-name')
+                    jdkValues.languageLevel, jdkValues.'project-jdk-name')
+        }
+    }
+
+    def toXmlDirectory(File modulesFile, File miscFile) {
+        File ideaDir = new File(".idea")
+        if (!ideaDir.exists()) {
+            ideaDir.mkdir()
+        }
+        def modulesXmlDoc = new groovy.xml.StreamingMarkupBuilder().bind {
+            mkp.xmlDeclaration(encoding: "UTF-8")
+
+            project(version: "4") {
+                component(name: "ProjectModuleManager") {
+                    modules {
+                        modulePaths.each { ModulePath modulePath ->
+                            module(fileurl: modulePath.url, filepath: modulePath.path)
+                        }
+                    }
+                }
+            }
+        }
+        Node modulesXml = new XmlParser().parse(new StringReader(modulesXmlDoc.toString()))
+        new XmlNodePrinter(new PrintWriter(modulesFile)).print(modulesXml)
+
+
+        Node miscXml
+
+        Reader miscReader = miscFile.exists() ? new FileReader(miscFile) : null;
+
+        if (miscReader != null) {
+            miscXml = new XmlParser().parse(miscReader)
+
+
+            def jdkValues = findProjectRootManager(miscXml).attributes()
+
+            jdk = new Jdk(Boolean.parseBoolean(jdkValues.'assert-keyword'), Boolean.parseBoolean(jdkValues.'jdk-15'),
+                    jdkValues.languageLevel, jdkValues.'project-jdk-name')
+        } else {
+            def xmlMiscTemplate = new groovy.xml.StreamingMarkupBuilder().bind {
+                mkp.xmlDeclaration(encoding: "UTF-8")
+                project(version: "4") {
+                    component(name: "ProjectRootManager")
+                }
+            }
+            miscXml = new XmlParser().parse(new StringReader(xmlMiscTemplate.toString()))
         }
+
+        findProjectRootManager(miscXml).@'assert-keyword' = jdk.assertKeyword
+        findProjectRootManager(miscXml).@'assert-jdk-15' = jdk.jdk15
+        findProjectRootManager(miscXml).@languageLevel = jdk.languageLevel
+        findProjectRootManager(miscXml).@'project-jdk-name' = jdk.projectJdkName
+
+        new XmlNodePrinter(new PrintWriter(miscFile)).print(miscXml)
+
     }
 
     def toXml(Writer writer) {
@@ -92,18 +149,18 @@ class Project {
                 }
             }
         }
-        findProjectRootManager().@'assert-keyword' = jdk.assertKeyword
-        findProjectRootManager().@'assert-jdk-15' = jdk.jdk15
-        findProjectRootManager().@languageLevel = jdk.languageLevel
-        findProjectRootManager().@'project-jdk-name' = jdk.projectJdkName
+        findProjectRootManager(xml).@'assert-keyword' = jdk.assertKeyword
+        findProjectRootManager(xml).@'assert-jdk-15' = jdk.jdk15
+        findProjectRootManager(xml).@languageLevel = jdk.languageLevel
+        findProjectRootManager(xml).@'project-jdk-name' = jdk.projectJdkName
 
         withXmlActions.source.execute(xml)
 
         new XmlNodePrinter(new PrintWriter(writer)).print(xml)
     }
 
-    private def findProjectRootManager() {
-        return xml.component.find { it.@name == 'ProjectRootManager'}
+    private def findProjectRootManager(Node inXml) {
+        return inXml.component.find { it.@name == 'ProjectRootManager'}
     }
 
     private def findWildcardResourcePatterns() {
