From 514f3db7b11c991a7c7d8f4f0da9c08b7944d57c Mon Sep 17 00:00:00 2001 From: Jens Dietrich Date: Thu, 25 Jun 2020 10:00:52 +1200 Subject: [PATCH] version 1.0.7 --- pom.xml | 4 +-- yamf-acceptancetests/pom.xml | 2 +- yamf-bytecodechecks/pom.xml | 2 +- yamf-core/pom.xml | 2 +- .../java/nz/ac/wgtn/yamf/commons/Files.java | 28 +++++++++++++++++++ yamf-examples/pom.xml | 2 +- yamf-msoffice-reporting/pom.xml | 2 +- yamf-mvn/pom.xml | 2 +- 8 files changed, 36 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 60d883d..50977a6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,10 +4,10 @@ nz.ac.wgtn.yamf yamf-parent pom - 1.0.6 + 1.0.7 yamf-parent - 1.0.6 + 1.0.7 1.8 1.8 diff --git a/yamf-acceptancetests/pom.xml b/yamf-acceptancetests/pom.xml index e4c75f1..e4da085 100644 --- a/yamf-acceptancetests/pom.xml +++ b/yamf-acceptancetests/pom.xml @@ -4,7 +4,7 @@ nz.ac.wgtn.yamf yamf-parent - 1.0.6 + 1.0.7 nz.ac.wgtn.yamf yamf-acceptancetests diff --git a/yamf-bytecodechecks/pom.xml b/yamf-bytecodechecks/pom.xml index 22f1d70..13e5504 100644 --- a/yamf-bytecodechecks/pom.xml +++ b/yamf-bytecodechecks/pom.xml @@ -4,7 +4,7 @@ nz.ac.wgtn.yamf yamf-parent - 1.0.6 + 1.0.7 nz.ac.wgtn.yamf yamf-bytecodechecks diff --git a/yamf-core/pom.xml b/yamf-core/pom.xml index 1ebf136..79240cf 100644 --- a/yamf-core/pom.xml +++ b/yamf-core/pom.xml @@ -4,7 +4,7 @@ nz.ac.wgtn.yamf yamf-parent - 1.0.6 + 1.0.7 nz.ac.wgtn.yamf yamf-core diff --git a/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/Files.java b/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/Files.java index 628a07f..08bd98c 100644 --- a/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/Files.java +++ b/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/Files.java @@ -19,6 +19,34 @@ public static String relativize(File file, File baseFolder) { return pathBase.relativize(pathAbsolute).toString(); } + /** + * Find an ancestor satidfying a certain condition. + * @param file + * @param condition + * @param includeSelf -- whether file is also being considered + * @return + */ + public static File findAncestorSuchThat(File file, Predicate condition, boolean includeSelf) { + Preconditions.checkNotNull(file); + Preconditions.checkArgument(file.exists()); + if (includeSelf && condition.test(file)) { + return file; + } + return doFindAncestorSuchThat(file.getParentFile(),condition); + } + + private static File doFindAncestorSuchThat(File file, Predicate condition) { + if (condition.test(file)) { + return file; + } + File parent = file.getParentFile(); + if (parent==null) { + return null; + } + else { + return doFindAncestorSuchThat(parent,condition); + } + } /** * Breath-first traverse children to find a child file or folder satisfying a condition. diff --git a/yamf-examples/pom.xml b/yamf-examples/pom.xml index 58b5bd3..d167e1f 100644 --- a/yamf-examples/pom.xml +++ b/yamf-examples/pom.xml @@ -4,7 +4,7 @@ nz.ac.wgtn.yamf yamf-parent - 1.0.6 + 1.0.7 nz.ac.wgtn.yamf yamf-examples diff --git a/yamf-msoffice-reporting/pom.xml b/yamf-msoffice-reporting/pom.xml index 3d9576c..a8486df 100644 --- a/yamf-msoffice-reporting/pom.xml +++ b/yamf-msoffice-reporting/pom.xml @@ -4,7 +4,7 @@ nz.ac.wgtn.yamf yamf-parent - 1.0.6 + 1.0.7 nz.ac.wgtn.yamf yamf-msoffice-reporting diff --git a/yamf-mvn/pom.xml b/yamf-mvn/pom.xml index 37ea8d2..b20bf7d 100644 --- a/yamf-mvn/pom.xml +++ b/yamf-mvn/pom.xml @@ -4,7 +4,7 @@ nz.ac.wgtn.yamf yamf-parent - 1.0.6 + 1.0.7 nz.ac.wgtn.yamf yamf-mvn