joelittlejohn / embedmongo-maven-plugin

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

Enable the usage of other maven phases #33

Closed andianderson522 closed 10 years ago

andianderson522 commented 10 years ago

Please allow for the running in the test-compile phase so this can be used for unit tests with out having to launch mongod over and over for each test.

joelittlejohn commented 10 years ago

This should be possible already, the default phases that the goals bind to are pre-integration-test and post-integration-test, but you can choose whatever phases you like.

Are you having some trouble binding the start goal to the test-compile phase?

andianderson522 commented 10 years ago

i added test-compile to the start execution to have it start up before my unit tests run. this works in maven 2 in a terminal but not maven 3.10. also it will not run in eclipse as it gives the following error: Phase test-compile not listed as available option in plugin. Only the following phases are supported pre-integration-test, post-integration-test

this is using eclipse kelper on mac lion

joelittlejohn commented 10 years ago

I don't think Maven 3.10 exists, could you check the version again? I just tried this pom with Maven 3.0.5:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.github.joelittlejohn.embedmongo</groupId>
    <artifactId>embedmongo-maven-plugin-test1</artifactId>
    <version>0.1.0-SNAPSHOT</version>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.joelittlejohn.embedmongo</groupId>
                <artifactId>embedmongo-maven-plugin</artifactId>
                <version>0.1.9</version>
                <executions>
                    <execution>
                        <id>start</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

and it worked perfectly well. You say this works in Maven 2 but not Maven 3, what error did you get?

You mention that the plugin will not run in Eclipse. What exactly are you doing in Eclipse to create this error?

andianderson522 commented 10 years ago

its 3.1.0 i typoed sorry in eclipse i am going to the pom and running mvn build... and putting in clean deploy for the goals. also in eclipse when editing the pom source it red underlines the line and when you hover gives the same message above. in maven 3 terminal i get the message: test-compile not listed as available phase in plugin embedmongo-maven-plugin

joelittlejohn commented 10 years ago

The only Maven releases that I can find that sound similar are:

3.1.0-alpha-1 3.1.1

I've tried both of these with the example pom.xml above and it works without any error.

Could you paste the full plugin config you're using here?

andianderson522 commented 10 years ago

Apache Maven 3.1.0 (r1075438; 2011-02-28 12:31:09-0500) Maven home: /usr/share/maven Java version: 1.7.0_21, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre Default locale: en_US, platform encoding: US-ASCII OS name: "mac os x", version: "10.7.4", arch: "x86_64", family: "mac"

<build>
        <plugins>
            <plugin>
                <groupId>com.github.joelittlejohn.embedmongo</groupId>
                <artifactId>embedmongo-maven-plugin</artifactId>
                <version>0.1.9</version>
                <executions>
                    <execution>
                        <id>start</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <port>12345</port>
                            <!-- optional, default 27017 -->
                            <!--
                            <randomPort>true</randomPort>
                            optional, default is false, if true allocates a random port and overrides embedmongo.port -->
                            <!-- <version>2.0.4</version>
                            optional, default 2.2.1 -->
                            <!-- 
                            <databaseDirectory>/tmp/mongotest</databaseDirectory>
                            optional, default is a new dir in java.io.tmpdir -->
                            <logging>none</logging>
                            <!--  optional (file|console|none), default console -->
                            <logFile>${project.build.directory}/myfile.log</logFile>
                            <!-- optional, can be used when logging=file, default is ./embedmongo.log -->
                            <logFileEncoding>utf-8</logFileEncoding>
                            <!-- optional, can be used when logging=file, default is utf-8 -->
                            <!-- <proxyHost>myproxy.company.com</proxyHost>
                            optional, default is none -->
                            <!-- <proxyPort>8080</proxyPort>
                            optional, default 80 -->
                            <!-- <proxyUser>joebloggs</proxyUser>
                            optional, default is none -->
                            <!-- <proxyPassword>pa55w0rd</proxyPassword>
                            optional, default is none -->
                            <bindIp>127.0.0.1</bindIp>
                            <!-- optional, default is to listen on all interfaces -->
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop</id>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
joelittlejohn commented 10 years ago

When I run using this exact configuration using Maven 3.1.0, I have no problem.

Could you provide the full output from a Maven build that shows the error? Pastebin would be good, or if you have parts of the log that you don't want to expose publicly then feel free to email it to me using my github username at gmail.com.

joelittlejohn commented 10 years ago

I can't replicate this problem I'm afraid so I can't apply a fix. If you can provide a log then I'll try to investigate, but everything appears to be working so I'm going to close this. If you can provide some further information then I'll take another look.