Giter Site home page Giter Site logo

postgresql-maven-plugin's Introduction

postgresql-maven-plugin Build Status

A Maven plugin for controlling PostgreSQL. There are goals for starting, stopping, initializing a DB, etc. The main purpose is running integration tests.

The project is in a very early stage. It requires JDK 7 to run. Currently there are 6 goals with very few options.

Usage example:

<plugin>
    <groupId>com.github.adrianboimvaser</groupId>
    <artifactId>postgresql-maven-plugin</artifactId>
    <version>0.2-SNAPSHOT</version>
    <configuration>
        <pgsqlHome>${project.build.directory}/pgsql</pgsqlHome>
        <dataDir>${project.build.directory}/data</dataDir>
        <skip>${skipITs}</skip>
        <databaseName>postgres</databaseName>
        <username>postgres</username>
    </configuration>
    <executions>
        <execution>
            <id>version-check</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>version</goal>
            </goals>
            <configuration>
                <mandatoryVersionRange>[9.2,)</mandatoryVersionRange>
            </configuration>
        </execution>
        <execution>
            <id>init-db</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>initdb</goal>
            </goals>
            <configuration>
                <username>postgres</username>
                <passwordFile>${basedir}/password.txt</passwordFile>
                <encoding>UTF8</encoding>
                <locale>en_US</locale>
            </configuration>
        </execution>
        <execution>
            <id>start-postgresql</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
        <execution>
            <id>create-db</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>createdb</goal>
            </goals>
            <configuration>
                <username>postgres</username>
                <databaseName>products</databaseName>
            </configuration>
        </execution>
        <execution>
            <id>drop-db</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>dropdb</goal>
            </goals>
            <configuration>
                <username>postgres</username>
                <databaseName>products</databaseName>
            </configuration>
        </execution>
        <execution>
            <id>stop-postgresql</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Goals

  1. version -- display (and enforce) version information
  2. initdb -- initialize a database root (cluster)
  3. start -- start the server
  4. createdb -- connect to the server and create a database
  5. dropdb -- connect to the server and drop a database
  6. stop -- stop the server

postgresql-maven-plugin's People

Contributors

adrianboimvaser avatar jeroenpeeters avatar nathansgreen avatar wabson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

postgresql-maven-plugin's Issues

Not able to start Embedded PostgreSQL database

@adrianboimvaser
I am trying to start the DB but no luck.
Please Help!

The same error happens in the integration test within this project:

[INFO] --- maven-invoker-plugin:1.7:integration-test (integration-test) @ postgresql-maven-plugin ---
[INFO] Building: start-stop/pom.xml
[INFO] ..FAILED (99.5 s)

Basically the start-stop IT does not start the DB properly and the exception is thrown:

[INFO] Starting PostgreSQL
[ERROR]
java.lang.InterruptedException: timeout reached (60s)

I do not see much in the build.log only the stacktrace:

java.lang.InterruptedException: timeout reached (60s)
at com.github.adrianboimvaser.postgresql.plugin.StartMojo.started(StartMojo.java:83)
at com.github.adrianboimvaser.postgresql.plugin.StartMojo.doExecute(StartMojo.java:53)
at com.github.adrianboimvaser.postgresql.plugin.PgctlMojo.execute(PgctlMojo.java:26)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

Drop Database

More of a question than an bug, but does the init db, drop any existing databases? Is there a drop db equivalent. I see there is a create database goal.

Starting PostgreSQL hangs on a busy port

When starting PG on a busy port, starting process hangs definitely.

 <plugin>
                <groupId>com.github.adrianboimvaser</groupId>
                <artifactId>postgresql-maven-plugin</artifactId>
                <version>0.11</version>
                <configuration>
                    <pgsqlHome>${project.build.directory}/pgsql</pgsqlHome>
                    <dataDir>${project.build.directory}/data</dataDir>
                    <port>${postgresql.port}</port>
                    <skip>false</skip>
                    <databaseName>${database.name}</databaseName>
                    <username>${postgresql.user}</username>
                    <password>${postgresql.password}</password>
                    <encoding>UTF8</encoding>
                </configuration>
                <executions>
                    <execution>
                        <id>initdb-postgresql</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>initdb</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>start-postgresql</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <parameters>
                                <log_statement>all</log_statement>
                                <log_destination>csvlog</log_destination>
                                <logging_collector>on</logging_collector>
                                <log_directory>pg_log</log_directory>
                            </parameters>
                        </configuration>
                    </execution>
                    <execution>
                        <id>create-conciliator-db</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>createdb</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>createdb-rules-store-db</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>createdb</goal>
                        </goals>
                        <configuration>
                            <username>${postgresql.user}</username>
                            <databaseName>rules</databaseName>
                        </configuration>
                    </execution>
               </executions>
</plugin>

[INFO]
[INFO] --- postgresql-maven-plugin:0.11:start (start-postgresql) @ rules-engine-testing ---
[INFO] Starting PostgreSQL
^C

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.