Skip to content

Commit

Permalink
Only adjust .idea/vcs.xml if it exists (#532)
Browse files Browse the repository at this point in the history
While working on #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.

Related discussion: #491
PR: #532
  • Loading branch information
jbduncan committed Oct 12, 2021
1 parent 394a983 commit 5bac897
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -117,9 +117,10 @@ The least we can do is to thank them and list some of their accomplishments here

* [Cory Thomas](https://github.com/dump247) contributed the `minSuccess` attribute in [retrying tests](https://junit-pioneer.org/docs/retrying-test/) (#408 / #430)
* [Daniel Kraus](https://github.com/beatngu13) fixed bugs in the environment variable and system property extensions (#432 / #433, #448 / #449, and more), revamped their annotation handling (#460 / #485), and improved the build process (#482 / #483) before becoming a maintainer
* [John Lehne](https://github.com/johnlehne) resolved an issue with the latest build status not showing correctly in README.md (#530)
* [John Lehne](https://github.com/johnlehne) resolved an issue with the latest build status not showing correctly in README.md (#530)
* [Slawomir Jaranowski](https://github.com/slawekjaranowski) Migrate to new Shipkit plugins (#410 / #419)
* [Stefano Cordio](https://github.com/scordio) contributed [the Cartesian Enum source](https://junit-pioneer.org/docs/cartesian-product/#cartesianenumsource) (#379 / #409 and #414 / #453)
* [Jonathan Bluett-Duncan](https://github.com/jbduncan) contributed a fix to `buildSrc/build.gradle` which was failing when a `.idea` directory did not contain a `vcs.xml` file (#532)

#### 2020

Expand Down
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 5bac897

Please sign in to comment.