views:

1370

answers:

3

I've been using maven2 and hudson for a while to do my continuous integration, but I find that Eclipse and Maven do not play well together. Sure there's a plugin, but it's cranky to mash the maven project into something that eclipse likes and the build times and unit test are too long. I'm considering switching back to a pure eclipse project with no ant and no maven involved. With the infinitest plugin and possible the JavaRebel agent, it would give me a very fast build-deploy-test cycle. However I'd still like to have automatic and testing as well, so:

How do I use continuous integration with an Eclipse project?

Is there a command line way to do it?

Is there a build server that already supports it natively?

+3  A: 

Yeah, Eclipse Maven2 plugin is crap for now. But I would suggest for you to hang in there, there is a lot of benefit to using Maven2, so it actually balances out.

What we do, is that we use Eclipse to develop and only use Maven to manage dependencies. Everything else is done by running "mvn" on command line. We keep tests in their own integration test projects (...-itest) and have continuous integration server to do build in 2 phases, first build the actual code, and second pass build and runs the -itest projects. (First pass (pure build) usually is very quick, and the integration tests build (with running of tests) usually takes quite a while.)

Here's command line to make mvn run tests: mvn -o verify -Ditest

Of course you need to define 'itest' profile in your parent pom: Say, like this:

<profiles>
  <profile>
    <id>integration-test</id>
    <activation>
      <property>
        <name>itest</name>
      </property>
    </activation>
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <executions>
            <execution>
              <id>itest</id>
            </execution>
          </executions>
          <configuration>
            <testSourceDirectory>src/main</testSourceDirectory>
            <testClassesDirectory>target/classes</testClassesDirectory>
            <forkMode>once</forkMode>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>
Valters Vingolds
Interesting idea, i had not thought of splitting it into two projects. I'm a big fan of maven usually, but I've noticed that the build/test cycle takes a bit long. This idea could speed things up a bit i guess.
Sebastian
A: 

I've had fair success using Eclipse + Ant with CruiseControl. If you want automation, you're probably going to need more than just pure Eclipse.

CruiseControl can automatically check out a copy of your project from source control, build it, run tests, and then update a web application with the results. It was pretty slick last I used it, but that was a long time ago now.

Ian McLaird
+2  A: 

I managed find a good solution. I simply got infinitest to work when using maven and eclipse

In Eclipse->Project Properties->Java Build Path->Source uncheck the box called: "Allow output folders for source folders"

That will enable your project to have more than one output path and Eclipse will then start reporting the test-classes as being part of the class path. Infinitest now finds it and starts running tests!

All i did was use the official maven eclipse plugin and add this to my POM

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.5</version>
  <!-- <scope>provided</scope> -->
    </dependency>

    <dependency>
        <groupId>org.infinitest</groupId>
        <artifactId>infinitest</artifactId>
        <scope>test</scope>
        <version>4.0</version>
    </dependency>

</dependencies>
Sebastian