All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.slavaz.maven.plugin.postgresql.embedded.goals.StopGoalMojo Maven / Gradle / Ivy

Go to download

This is a Maven plugin for running an embedded PostgreSQL server, mostly for integration tests.

The newest version!
package com.github.slavaz.maven.plugin.postgresql.embedded.goals;

import com.github.slavaz.maven.plugin.postgresql.embedded.classloader.ClassLoaderHolder;
import com.github.slavaz.maven.plugin.postgresql.embedded.psql.IsolatedPgInstanceManager;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;

@Mojo(name = "stop")
public class StopGoalMojo extends AbstractGoalMojo {
	
    @Override
	protected void doExecute() throws MojoExecutionException, MojoFailureException {
        ClassLoader classLoader = ClassLoaderHolder.getClassLoader();
        if (classLoader != null) {
            try {
                getLog().info("Stopping PostgreSQL...");
                new IsolatedPgInstanceManager(classLoader).stop();
                ClassLoaderHolder.setClassLoader(null);
                getLog().info("PostgreSQL stopped.");
            } catch (Exception e) {
                getLog().error("Failed to stop PostgreSQL", e);
            }
        } else {
            getLog().warn("PostgreSQL was not started");
        }
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy