From 15070f578ec8f70e493b384fa8e4bd867ba49c8f Mon Sep 17 00:00:00 2001 From: fbahle Date: Wed, 9 Oct 2024 17:30:20 +0200 Subject: [PATCH] Changed Mojo to not thread safe --- pom.xml | 2 +- src/changes/changes.xml | 6 ++++++ .../maven/plugin/zonky/StartEmbeddedPostgresMojo.java | 2 +- .../maven/plugin/zonky/StopEmbeddedPostgresMojo.java | 2 +- .../maven/plugin/zonky/utils/MavenProjectUtil.java | 8 ++++++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e682624..58fc024 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ de.funfried.maven.plugins zonky-maven-plugin - 0.5 + 0.6 maven-plugin diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 32a40f7..dc67c1f 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -9,6 +9,12 @@ + + + Changed Mojo to not thread safe + + + Added flag to switch between single instance for all multimodule project or an instance for each sub module (which configures the plugin) diff --git a/src/main/java/de/funfried/maven/plugin/zonky/StartEmbeddedPostgresMojo.java b/src/main/java/de/funfried/maven/plugin/zonky/StartEmbeddedPostgresMojo.java index 75cc3d5..9e57fa5 100644 --- a/src/main/java/de/funfried/maven/plugin/zonky/StartEmbeddedPostgresMojo.java +++ b/src/main/java/de/funfried/maven/plugin/zonky/StartEmbeddedPostgresMojo.java @@ -28,7 +28,7 @@ /** * Goal which starts an embedded postgres database. */ -@Mojo(name = "start", defaultPhase = LifecyclePhase.INITIALIZE, requiresProject = true, threadSafe = true) +@Mojo(name = "start", defaultPhase = LifecyclePhase.INITIALIZE, requiresProject = true, threadSafe = false) public class StartEmbeddedPostgresMojo extends AbstractMojo { /** * The port on which the database will be accessible. A value less than or equal to 0 means auto detect a free port. The port is available through the property ${zonky.port}. diff --git a/src/main/java/de/funfried/maven/plugin/zonky/StopEmbeddedPostgresMojo.java b/src/main/java/de/funfried/maven/plugin/zonky/StopEmbeddedPostgresMojo.java index b7a92c5..b62be4f 100644 --- a/src/main/java/de/funfried/maven/plugin/zonky/StopEmbeddedPostgresMojo.java +++ b/src/main/java/de/funfried/maven/plugin/zonky/StopEmbeddedPostgresMojo.java @@ -19,7 +19,7 @@ /** * Goal which stops the embedded postgres database. */ -@Mojo(name = "stop", defaultPhase = LifecyclePhase.NONE) +@Mojo(name = "stop", defaultPhase = LifecyclePhase.PRE_CLEAN, threadSafe = false) public class StopEmbeddedPostgresMojo extends AbstractMojo { /** * The maven project. diff --git a/src/main/java/de/funfried/maven/plugin/zonky/utils/MavenProjectUtil.java b/src/main/java/de/funfried/maven/plugin/zonky/utils/MavenProjectUtil.java index d7e5190..292b59f 100644 --- a/src/main/java/de/funfried/maven/plugin/zonky/utils/MavenProjectUtil.java +++ b/src/main/java/de/funfried/maven/plugin/zonky/utils/MavenProjectUtil.java @@ -12,10 +12,14 @@ * @author fbahle */ public class MavenProjectUtil { + public static final String PROP_ENABLED = "zonky.required"; + public static final String PROP_HOST = "zonky.host"; public static final String PROP_PORT = "zonky.port"; + public static final String PROP_CREATE_DATABASE = "zonky.createDatabase"; + public static final String PROP_DATABASE = "zonky.database"; public static final String PROP_USERNAME = "zonky.username"; @@ -52,6 +56,10 @@ public static E getProjectProperty(MavenProject project, List } private static E getProjectProperty(MavenProject project, String key) { + if (project == null) { + return null; + } + return (E) project.getProperties().get(key); }