Skip to content

Commit

Permalink
fix: inconsitenacy across jdk versions
Browse files Browse the repository at this point in the history
Make builders plugin behave consistently when
looking for the vagrantfileDir across jdk versions.
  • Loading branch information
mrinalwadhwa committed Feb 9, 2020
1 parent 968ae64 commit a16cda2
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class BuildersPlugin implements Plugin<Project> {
]
]

def vagrantfileDir = new File(findVagrantfileDir())
def currentDir = project.file('.')
def vagrantfileDir = findVagrantfileDir(currentDir)
def pathRelativeToVagrentfileDir = vagrantfileDir.toPath().relativize(currentDir.toPath()).toFile()

config = merge(config, project.host)
Expand Down Expand Up @@ -68,8 +68,8 @@ class BuildersPlugin implements Plugin<Project> {
}

// starting from the current directory, look for a parent directory that has a Vagrantfile
static String findVagrantfileDir() {
def path = new File('.')
static File findVagrantfileDir(File currentDir) {
def path = currentDir
def hasVagrantfile = false
while (true) {
path.eachFileMatch (FileType.FILES, /Vagrantfile/) { file ->
Expand All @@ -78,7 +78,7 @@ class BuildersPlugin implements Plugin<Project> {
if (hasVagrantfile) break
path = new File('..', path)
}
return path.getCanonicalPath()
return (new File(path.getCanonicalPath()))
}

static Map merge(Map onto, Map... overrides) {
Expand Down

0 comments on commit a16cda2

Please sign in to comment.