joelittlejohn / embedmongo-maven-plugin

Maven plugin wrapper for the flapdoodle.de embedded MongoDB API
Apache License 2.0
88 stars 51 forks source link

#32. Add ability to specify init script for mongoDB. #40

Closed pvardanega closed 9 years ago

pvardanega commented 9 years ago

Insert data during start goal. It needs the folder where the data files to execute are and the database name where that data will be stored in mongo.

Works like this:

<plugin>
    <groupId>com.github.joelittlejohn.embedmongo</groupId>
    <artifactId>embedmongo-maven-plugin</artifactId>
    <configuration>
        <databaseName>shoppinglist</databaseName>
        <dataFolder>src/main/resources/data</dataFolder>
    </configuration>
    <executions>
        <execution>
            <id>start-embed-mongo</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
    </executions>
</plugin>
joelittlejohn commented 9 years ago

Thanks a lot for submitting this, it looks like a very useful feature! I must admit though, my preference would be to add this to the start goal. I think this will be simpler for users of this plugin - less verbose, no need to repeat the port (which may not be particularly intuitive when the port is randomly assigned), no need to worry about ordering of start and init-data.

I guess the benefit of this new goal is that it can be run without starting a mongodb instance. Is that how you need to be able to run this in your build?

pvardanega commented 9 years ago

Yes, you are totally right. I'll improve this pull request :+1:

joelittlejohn commented 9 years ago

Great thanks. You can extract what you've done here into some class that is called from the start mojo, then add databaseName and initDirectory as new config options.

joelittlejohn commented 9 years ago

I'm going to close this pull request for now, we'll definitely work your commits in to the core but we'll probably pull manually into a new branch and rationalise this and #41 before merging. Thanks!!

joelittlejohn commented 9 years ago

(If you could leave your fork & branch around that would be helpful :))