diff --git a/build-parent/pom.xml b/build-parent/pom.xml
index af29e5a81..676d9983b 100644
--- a/build-parent/pom.xml
+++ b/build-parent/pom.xml
@@ -70,7 +70,7 @@
3.3.4
4.1.5_for_spark_3
1.12.262
- 1.0.0
+ 1.1.0-SNAPSHOT
0.6.0
7.4.1
diff --git a/foundation/foundation-upgrade/pom.xml b/foundation/foundation-upgrade/pom.xml
index b040ec57d..5df58377e 100644
--- a/foundation/foundation-upgrade/pom.xml
+++ b/foundation/foundation-upgrade/pom.xml
@@ -44,7 +44,7 @@
org.technologybrewery.baton
baton-maven-plugin
- 0.2.0
+ ${version.baton}
org.yaml
@@ -56,11 +56,6 @@
toml
3.6.6
-
- com.vdurmont
- semver4j
- 3.1.0
-
org.projectlombok
lombok
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractHelmNameMigration.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractHelmNameMigration.java
index bc0bd53c4..8ca73e4fa 100644
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractHelmNameMigration.java
+++ b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractHelmNameMigration.java
@@ -10,7 +10,7 @@
* #L%
*/
-import com.boozallen.aissemble.upgrade.util.FileUtils;
+import org.technologybrewery.baton.util.FileUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,7 +20,7 @@
import java.io.IOException;
import java.util.List;
-import static com.boozallen.aissemble.upgrade.util.FileUtils.getRegExCaptureGroups;
+import static org.technologybrewery.baton.util.FileUtils.getRegExCaptureGroups;
/**
* Baton migration used to migrate the Helm Chart names and/or Helm module names in the Chart.yaml and values.yaml files within a project's deploy folder
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractHelmRepositoryMigration.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractHelmRepositoryMigration.java
index 199283df6..602fb5f49 100644
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractHelmRepositoryMigration.java
+++ b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractHelmRepositoryMigration.java
@@ -10,7 +10,7 @@
* #L%
*/
-import com.boozallen.aissemble.upgrade.util.FileUtils;
+import org.technologybrewery.baton.util.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractPoetryMigration.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractPoetryMigration.java
index 3c876d7be..1dd33db09 100644
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractPoetryMigration.java
+++ b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/AbstractPoetryMigration.java
@@ -18,8 +18,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.technologybrewery.baton.BatonException;
+import org.technologybrewery.baton.util.FileUtils;
-import com.boozallen.aissemble.upgrade.util.FileUtils;
import com.boozallen.aissemble.upgrade.util.PythonPackageMigration;
import com.electronwill.nightconfig.core.Config;
import com.electronwill.nightconfig.core.file.FileConfig;
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/HelmChartsV1Migration.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/HelmChartsV1Migration.java
index 91f12f705..97bf6ff60 100644
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/HelmChartsV1Migration.java
+++ b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/HelmChartsV1Migration.java
@@ -10,16 +10,16 @@
* #L%
*/
-import com.boozallen.aissemble.upgrade.util.FileUtils;
-import com.boozallen.aissemble.upgrade.util.MigrationUtils;
+import org.technologybrewery.baton.util.FileUtils;
+import org.technologybrewery.baton.util.CommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
+import java.util.List;
-import static com.boozallen.aissemble.upgrade.util.FileUtils.getRegExCaptureGroups;
+import static org.technologybrewery.baton.util.FileUtils.getRegExCaptureGroups;
public class HelmChartsV1Migration extends AbstractAissembleMigration {
public static final Logger logger = LoggerFactory.getLogger(HelmChartsV1Migration.class);
@@ -38,10 +38,10 @@ protected boolean shouldExecuteOnFile(File file) {
mavenAissembleVersion = getAissembleVersion();
if (mavenAissembleVersion != null) {
- ArrayList chartAissembleVersions = getRegExCaptureGroups(extractVersionRegex, file);
+ List chartAissembleVersions = getRegExCaptureGroups(extractVersionRegex, file);
if (!chartAissembleVersions.isEmpty())
shouldExecute = chartAissembleVersions.stream().anyMatch(chartVersion ->
- MigrationUtils.isLessThanVersion(chartVersion, mavenAissembleVersion)
+ CommonUtils.isLessThanVersion(chartVersion, mavenAissembleVersion)
);
} else {
logger.error("Unable to parse version from current project");
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/HelmChartsV2Migration.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/HelmChartsV2Migration.java
index deabca2cc..f3394790d 100644
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/HelmChartsV2Migration.java
+++ b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/HelmChartsV2Migration.java
@@ -10,8 +10,9 @@
* #L%
*/
-import com.boozallen.aissemble.upgrade.util.FileUtils;
-import com.boozallen.aissemble.upgrade.util.MigrationUtils;
+import org.technologybrewery.baton.util.FileUtils;
+import org.technologybrewery.baton.util.CommonUtils;
+import static org.technologybrewery.baton.util.CommonUtils.isLessThanVersion;
import com.google.common.io.Files;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -24,7 +25,6 @@
import java.util.HashMap;
import java.util.List;
-import static com.boozallen.aissemble.upgrade.util.MigrationUtils.isLessThanVersion;
public class HelmChartsV2Migration extends AbstractAissembleMigration {
public static final Logger logger = LoggerFactory.getLogger(HelmChartsV2Migration.class);
@@ -125,13 +125,13 @@ private static void writeNewFile(File file, ArrayList newFileContents) t
private String upgradeVersionInString(String line) {
String newLine;
- ArrayList captureGroups = FileUtils.getRegExCaptureGroups(
+ List captureGroups = FileUtils.getRegExCaptureGroups(
VERSION_APP_VERSION_REPLACE_REGEX,
line
);
String currentVersion = getAissembleVersion();
String oldVersion = captureGroups.get(1).replaceAll("['|\"]", "").trim();
- String newVersion = MigrationUtils.isLessThanVersion(oldVersion, currentVersion) ? currentVersion : oldVersion;
+ String newVersion = CommonUtils.isLessThanVersion(oldVersion, currentVersion) ? currentVersion : oldVersion;
newLine = captureGroups.get(0) + "\"" + newVersion + "\"";
return StringUtils.appendIfMissing(newLine,"\n");
}
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/TiltfileMigration.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/TiltfileMigration.java
index 42b5090a3..2569adfce 100644
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/TiltfileMigration.java
+++ b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/TiltfileMigration.java
@@ -11,6 +11,8 @@
*/
import com.boozallen.aissemble.upgrade.util.TiltfileUtil;
+import static org.technologybrewery.baton.util.FileUtils.replaceInFile;
+import static org.technologybrewery.baton.util.CommonUtils.isLessThanVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,8 +22,6 @@
import java.io.FileReader;
import java.io.IOException;
-import static com.boozallen.aissemble.upgrade.util.MigrationUtils.isLessThanVersion;
-import static com.boozallen.aissemble.upgrade.util.FileUtils.replaceInFile;
public class TiltfileMigration extends AbstractAissembleMigration {
public static final String VERSION_REGEX = "(aissemble_version = *['\"])(\\d+\\.\\d+\\.\\d+(?:[\\.\\-\\d+a-zA-Z]*))(['\"])";
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/v1_8_0/AiopsReferencePDPPythonMigration.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/v1_8_0/AiopsReferencePDPPythonMigration.java
index c6e8df4ed..aaee8d859 100644
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/v1_8_0/AiopsReferencePDPPythonMigration.java
+++ b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/v1_8_0/AiopsReferencePDPPythonMigration.java
@@ -20,7 +20,7 @@
import java.io.IOException;
import java.util.Map;
-import static com.boozallen.aissemble.upgrade.util.FileUtils.replaceLiteralInFile;
+import static org.technologybrewery.baton.util.FileUtils.replaceLiteralInFile;
/**
Baton migration class to verify whether a migration to the Policy Decision Point (Python) module files is required from
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/v1_8_0/AiopsReferencePythonMigration.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/v1_8_0/AiopsReferencePythonMigration.java
index d063d7df7..469d28a41 100644
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/v1_8_0/AiopsReferencePythonMigration.java
+++ b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/migration/v1_8_0/AiopsReferencePythonMigration.java
@@ -20,7 +20,7 @@
import java.util.Map;
-import static com.boozallen.aissemble.upgrade.util.FileUtils.replaceLiteralInFile;
+import static org.technologybrewery.baton.util.FileUtils.replaceLiteralInFile;
/**
Baton migration class to verify whether a migration to the python file packages are required from the aiops reference removal from the
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/FileUtils.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/FileUtils.java
deleted file mode 100644
index 2e6ac22a0..000000000
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/FileUtils.java
+++ /dev/null
@@ -1,214 +0,0 @@
-package com.boozallen.aissemble.upgrade.util;
-
-/*-
- * #%L
- * aiSSEMBLE::Foundation::Upgrade
- * %%
- * Copyright (C) 2021 Booz Allen
- * %%
- * This software package is licensed under the Booz Allen Public License. All Rights Reserved.
- * #L%
- */
-
-import org.apache.commons.io.IOUtils;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public final class FileUtils {
-
- /**
- *
- * @param file the File
- * @param toReplace a string representing the text to replace
- * @param replacement the replacement text to substitute the toReplace string
- * @return a boolean set to true if at least one replacement was performed in the file
- */
- public static boolean replaceLiteralInFile(File file, String toReplace, String replacement) throws IOException {
- boolean replacedInFile = false;
-
- if (file != null && file.exists()) {
- String content = new String(Files.readAllBytes((file.toPath())));
- content = content.replace(toReplace, replacement);
- Files.write(file.toPath(), content.getBytes());
- replacedInFile = true;
- }
- return replacedInFile;
- }
-
- /**
- *
- * @param file the File
- * @param regex a regex representing the text to replace, as a String
- * @param replacement the replacement text to substitute the regex
- * @return a boolean set to true if at least one replacement was performed in the file
- */
- public static boolean replaceInFile(File file, String regex, String replacement) throws IOException {
- boolean replacedInFile = false;
- if (file != null && file.exists()) {
- Charset charset = StandardCharsets.UTF_8;
- String fileContent = new String(Files.readAllBytes(file.toPath()), charset);
-
- Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
- Matcher matcher = pattern.matcher(fileContent);
- String newFileContent = matcher.replaceAll(replacement);
- IOUtils.write(newFileContent, new FileOutputStream(file), charset);
- replacedInFile = true;
- }
- return replacedInFile;
- }
-
- /**
- * Evaluates a file against a regex pattern and replaces a substring of each regex match
- * with a specified replacement
- * @param file the File
- * @param regex a regex representing the text to replace a substring of
- * @param substring the substring of the regex match that will be replaced
- * @param replacement the replacement of the match substring
- * @return a boolean set to true if at least one modification was performed in the file
- */
- public static boolean modifyRegexMatchInFile(File file, String regex, String substring, String replacement) {
- if (file == null || !file.exists()) {
- return false;
- }
-
- boolean modified = false;
-
- try {
- Path path = file.toPath();
- Charset charset = StandardCharsets.UTF_8;
- List resultLines = new ArrayList<>();
-
- Pattern pattern = Pattern.compile(regex);
- for (String line : Files.readAllLines(path, charset)) {
- if (pattern.matcher(line).find()) {
- line = line.replace(substring, replacement);
- modified = true;
- }
- resultLines.add(line);
- }
- if (modified) {
- Files.write(path, resultLines, charset);
- }
- } catch (IOException e) {
- return false;
- }
- return modified;
- }
-
- /**
- * Function to read in the {@link File} object and return a {@link List} of the contents.
- * @param file {@link File} to read
- * @return {@link List} of the contents
- * @throws IOException
- */
- public static List readAllFileLines(File file) throws IOException {
- return Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
- }
-
- /**
- * Function to write a {@link List} of the contents to the {@link File} object.
- * @param file {@link File} to write
- * @param contents {@link List} of the contents
- * @throws IOException
- */
- public static void writeFile(File file, List contents) throws IOException {
- Files.write(file.toPath(), contents, StandardCharsets.UTF_8);
- }
-
- /**
- * @see FileUtils#getRegExCaptureGroups(String, String)
- * @param regex a regex containing capture groups, as a String
- * @param file the file to search for matching capture groups
- * @return An ArrayList of Strings representing each capture group in the regex that was matched
- */
- public static ArrayList getRegExCaptureGroups(String regex, File file) throws IOException {
- String fileContent = "";
- if (file != null && file.exists()) {
- Charset charset = StandardCharsets.UTF_8;
- fileContent = new String(Files.readAllBytes(file.toPath()), charset);
- }
- return StringUtils.isNotEmpty(fileContent) ? getRegExCaptureGroups(regex, fileContent) : new ArrayList<>();
- }
-
- /**
- *
- * @param regex a regex containing capture groups, as a String
- * @param input the string to search for matching capture groups
- * @return An ArrayList of Strings representing each capture group in the regex that was matched
- */
- public static ArrayList getRegExCaptureGroups(String regex, String input) {
- Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
- Matcher matcher = pattern.matcher(input);
-
- ArrayList captured = new ArrayList<>();
- if (matcher.find()) {
- // Skip the 0 index -- the first match is always all capture groups put together
- for (int i = 1; i <= matcher.groupCount(); ++i) {
- captured.add(matcher.group(i));
- }
- }
-
- return captured;
- }
-
- /**
- * Evaluates a regex pattern against a file to determine if at least one regex match exists
- *
- * @param regex a regex pattern, as a String
- * @param file the file to search for matching substrings
- * @return true if there is at least one regex match, otherwise false
- */
- public static boolean hasRegExMatch(String regex, File file) throws IOException {
- String fileContent;
- if (file != null && file.exists()) {
- Charset charset = StandardCharsets.UTF_8;
- fileContent = Files.readString(file.toPath(), charset);
- return Pattern.compile(regex, Pattern.MULTILINE).matcher(fileContent).find();
- } else {
- return false;
- }
- }
-
- /**
- * Infers the indentation style from the given line.
- *
- * @param line the line to infer the indentation style from
- * @param level the level of indentation of the line
- * @return a single indent in the inferred style
- */
- public static String getIndent(String line, int level) {
- if( level < 1 ) {
- return "";
- }
- int i = 0;
- while (i < line.length() && Character.isWhitespace(line.charAt(i))) {
- i++;
- }
- return line.substring(0, i/level);
- }
-
- /**
- * Indent the values the desired number of tabs with a variable tab size.
- * @param values List of {@link String} values to indent
- * @param numSpaces number of spaces to indent
- */
- public static void indentValues(List values, int numSpaces) {
- String SPACE = " ";
- for (int i = 0; i < values.size(); i++) {
- if (!values.get(i).isBlank()) {
- values.set(i, SPACE.repeat(numSpaces) + values.get(i));
- }
- }
- }
-}
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/MigrationUtils.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/MigrationUtils.java
deleted file mode 100644
index 69701ad26..000000000
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/MigrationUtils.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.boozallen.aissemble.upgrade.util;
-
-/*-
- * #%L
- * aiSSEMBLE::Foundation::Upgrade
- * %%
- * Copyright (C) 2021 Booz Allen
- * %%
- * This software package is licensed under the Booz Allen Public License. All Rights Reserved.
- * #L%
- */
-
-import com.vdurmont.semver4j.Semver;
-
-public class MigrationUtils {
- /**
- * Checks if version1 is less than version2 using the Semver4j library.
- *
- * @param version1
- * @param version2
- * @return isLessThanVersion - if true, version1 is less than version2.
- */
- public static boolean isLessThanVersion(String version1, String version2) {
- Semver sem = new Semver(version1);
- return sem.isLowerThan(version2);
- }
-}
diff --git a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/pom/PomModifications.java b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/pom/PomModifications.java
index 150b92ffe..c32f4f5dc 100644
--- a/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/pom/PomModifications.java
+++ b/foundation/foundation-upgrade/src/main/java/com/boozallen/aissemble/upgrade/util/pom/PomModifications.java
@@ -10,7 +10,7 @@
* #L%
*/
-import com.boozallen.aissemble.upgrade.util.FileUtils;
+import org.technologybrewery.baton.util.FileUtils;
import org.apache.maven.model.InputLocation;
import org.codehaus.plexus.util.StringUtils;