diff --git a/sbt-idea-core/src/main/scala/IdeaProjectDescriptor.scala b/sbt-idea-core/src/main/scala/IdeaProjectDescriptor.scala
index 3557562..d78e412 100644
--- a/sbt-idea-core/src/main/scala/IdeaProjectDescriptor.scala
+++ b/sbt-idea-core/src/main/scala/IdeaProjectDescriptor.scala
@@ -74,15 +74,17 @@ class IdeaProjectDescriptor(val project: BasicDependencyProject, val log: Logger
if (projectPath.exists) {
val configDir = new File(projectPath, ".idea")
+ def configFile(name: String) = new File(configDir, name)
configDir.mkdirs
Seq(
"modules.xml" -> project(projectModuleManagerComponent),
- "misc.xml" -> miscTransformer.transform(miscXml(configDir)).firstOption.get,
- "vcs.xml" -> project(vcsComponent)
+ "misc.xml" -> miscTransformer.transform(miscXml(configDir)).firstOption.get
) foreach { case (fileName, xmlNode) => saveFile(configDir, fileName, xmlNode) }
- val librariesDir = new File(configDir, "libraries")
+ if (!configFile("vcs.xml").exists) saveFile(configDir, "vcs.xml", project(vcsComponent))
+
+ val librariesDir = configFile("libraries")
librariesDir.mkdirs
saveFile(librariesDir, "buildScala.xml", libraryTableComponent("buildScala", buildScalaJarDir, true))
saveFile(librariesDir, "defScala.xml", libraryTableComponent("defScala", defScalaJarDir, false))
diff --git a/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/.idea/vcs.xml b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/.idea/vcs.xml
new file mode 100644
index 0000000..ddc1d39
--- /dev/null
+++ b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/.idea/vcs.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/.idea/vcs.xml.expected b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/.idea/vcs.xml.expected
new file mode 100644
index 0000000..ddc1d39
--- /dev/null
+++ b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/.idea/vcs.xml.expected
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/project/build.properties b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/project/build.properties
new file mode 100644
index 0000000..b702aa0
--- /dev/null
+++ b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/project/build.properties
@@ -0,0 +1,6 @@
+project.organization=foo
+project.name=scripted-test
+sbt.version=0.7.4
+project.version=1.0
+build.scala.versions=2.7.7
+project.initialize=false
diff --git a/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/project/build/ScriptedTestProject.scala b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/project/build/ScriptedTestProject.scala
new file mode 100644
index 0000000..0e76f1a
--- /dev/null
+++ b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/project/build/ScriptedTestProject.scala
@@ -0,0 +1,3 @@
+import sbt._
+
+class ScriptedTestProject(info: ProjectInfo) extends DefaultProject(info) with ScriptedTestAssertTasks with IdeaProject
diff --git a/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/project/plugins/Plugins.scala b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/project/plugins/Plugins.scala
new file mode 100644
index 0000000..85b5d28
--- /dev/null
+++ b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/project/plugins/Plugins.scala
@@ -0,0 +1,9 @@
+import sbt._
+
+class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
+ val testedVersion = "0.2-SNAPSHOT"
+ val groupId = "com.github.mpeltonen"
+ val ideaPlugin = groupId % "sbt-idea-plugin" % testedVersion
+ val scriptedTestUtils = groupId % "sbt-idea-tests_2.7.7" % testedVersion
+}
+
diff --git a/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/test b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/test
new file mode 100644
index 0000000..fd3ffe3
--- /dev/null
+++ b/sbt-idea-tests/src/sbt-test/idea-plugin/preserve-existing-vcs-xml/test
@@ -0,0 +1,3 @@
+> update
+> idea
+> assert-expected-xml-files