Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve latest configuration version dynamically #1669

Open
jan-vcapgemini opened this issue Apr 3, 2023 · 0 comments
Open

Retrieve latest configuration version dynamically #1669

jan-vcapgemini opened this issue Apr 3, 2023 · 0 comments

Comments

@jan-vcapgemini
Copy link
Collaborator

Currently we are using a fixed version number for the pom configuration version after the upgrade.
This version needs to be retrieved automatically from the latest version of CobiGen.

public static final String CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_VERSION = "2021.12.007";

// read the content of the pom.xml then replace it
Charset charset = StandardCharsets.UTF_8;
String content = new String(Files.readAllBytes(oldPom), charset);
content = content.replaceAll("</modelVersion>\n" + " <groupId>([a-zA-Z]+(\\.[a-zA-Z]+)+)</groupId>",
"</modelVersion>\n" + " <groupId>" + ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID
+ "</groupId>");
content = content.replaceAll("</groupId>\n" + " <artifactId>.*</artifactId>", "</groupId>\n" + " <artifactId>"
+ newTemplateFolder.getFileName().toString().replace('_', '-') + "</artifactId>");
content = content.replaceAll("</artifactId>\n" + " <version>([0-9]+(\\.[0-9]+)+)</version>", "</artifactId>\n"
+ " <version>" + ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_VERSION + "</version>");
content = content.replaceAll("</version>\n" + " <name>.*</name>",
"</version>\n" + " <name>" + newTemplateFolder.getFileName().toString() + "</name>");
Files.write(newPom, content.getBytes(charset));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant