Skip to content

Commit

Permalink
Only adjust .idea/vcs.xml if it exists
Browse files Browse the repository at this point in the history
Whilst working on junit-pioneer#491, I saw that buildSrc/build.gradle was
failing if the .idea directory existed but .idea/vcs.xml did not,
which is what was happened for me with my version of IntelliJ IDEA.

This commit makes the build script more lenient by only trying to
append issue-related XML tags to .idea/vcs.xml if it exists,
rather than relying on the presence of just the .idea directory.

junit-pioneer#491 (comment)
PR: junit-pioneer#532
  • Loading branch information
jbduncan committed Oct 8, 2021
1 parent 394a983 commit 72725d8
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions buildSrc/build.gradle
Expand Up @@ -3,24 +3,26 @@ import groovy.xml.XmlUtil
build {
doLast {
def ideaFolder = new File('.idea');
if(ideaFolder.exists() && ideaFolder.isDirectory()) {
if (ideaFolder.exists() && ideaFolder.isDirectory()) {
def xmlFile = new File(".idea/vcs.xml")
def xml = new XmlSlurper().parse(xmlFile)
xml.component.find {it.@name == 'IssueNavigationConfiguration'}.replaceNode {}
xml.appendNode {
component(name: "IssueNavigationConfiguration") {
option(name: 'links') {
list {
IssueNavigationLink {
option(name: "issueRegexp", value: '#(\\d+)')
option(name: "linkRegexp", value: 'https://github.com/junit-pioneer/junit-pioneer/issues/$1')
if (xmlFile.exists() && xmlFile.isFile()) {
def xml = new XmlSlurper().parse(xmlFile)
xml.component.find { it.@name == 'IssueNavigationConfiguration' }.replaceNode {}
xml.appendNode {
component(name: "IssueNavigationConfiguration") {
option(name: 'links') {
list {
IssueNavigationLink {
option(name: "issueRegexp", value: '#(\\d+)')
option(name: "linkRegexp", value: 'https://github.com/junit-pioneer/junit-pioneer/issues/$1')
}
}
}
}
}
}
xmlFile.withWriter {out->
XmlUtil.serialize(xml, out)
xmlFile.withWriter { out ->
XmlUtil.serialize(xml, out)
}
}
}
}
Expand Down

0 comments on commit 72725d8

Please sign in to comment.