Closed rmannibucau closed 5 months ago
Goal is to enable to quickly use exec:java as an in place mojo replacement without having to bring all maven stack for simple needs.
exec:java
Sample:
import java.util.Properties; import java.util.function.BiConsumer; import java.util.function.Function; public final class ComputeLatest implements Runnable { private final Function<String, String> versionResolver; private final Properties properties; private final BiConsumer<String, String> updater; public ComputeLatest(final Function<String, String> highestVersionResolver, final Properties systemProperties, final BiConsumer<String, String> systemPropertiesUpdater) { this.versionResolver = highestVersionResolver; this.properties = systemProperties; this.updater = systemPropertiesUpdater; } public void run() { final var project = properties.getProperty("env.DEPLOY_PROJECT"); final String ga = switch (project) { case "foo" -> "com.demo.app1:deploy"; case "bar" -> "com.demo.app2:deploy"; default -> ""; }; if (ga.isBlank()) { // ignore return; } var lastVersion = versionResolver.apply(ga); if (!lastVersion.endsWith("-SNAPSHOT")) { // likely local since m2 repo shouldn't get published snapshots final var lastDot = lastVersion.lastIndexOf('.') + 1; lastVersion = lastVersion.substring(0, lastDot) + (Integer.parseInt(lastVersion.substring(lastDot)) + 1) + "-snapshot"; } updater.accept(ga.replace('.', '_').replace(':', '_') + ".latest", lastVersion); } }
then use com_demo_app1_deploy.latest in any placeholder friendly downstream plugin.
com_demo_app1_deploy.latest
adressed comments @slawekjaranowski if you want to have another look, thanks a lot to have spotted some issues, totally missed them yesterday.
Goal is to enable to quickly use
exec:java
as an in place mojo replacement without having to bring all maven stack for simple needs.Sample:
then use
com_demo_app1_deploy.latest
in any placeholder friendly downstream plugin.