So I have this snippet in my pom
<configuration>
<target if="csc" >
<echo>Unzipping md csc help</echo>
</target>
<target unless="csc">
<echo>Unzipping md help</echo>
</target>
</configuration>
When I run with mvn normally it correctly executes the unless="csc" target. The problem is that when I run it with -Dcsc=true it does not run any of the targets.
What am I doing wrong? :)
Thanks
It seems the antrun plugin supports only a single target element in the configuration. You can achieve the same effect with maven profiles that get activated when the property is set or absent:
<profiles>
<profile>
<id>property-set</id>
<activation>
<property>
<name>csc</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>antrun-property-set</id>
<goals>
<goal>run</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<target>
<echo>property is set</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>property-not-set</id>
<activation>
<property>
<name>!csc</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>antrun-property-not-set</id>
<goals>
<goal>run</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<target>
<echo>property is not set</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
The unpacking can be done via the maven-dependency plugin.
Related
Below is my POM file. I am unable to generate TestNG runner file while all the configs are correct. Please help me to do the correct configuration.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>4.2.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<outputDirectory>runner</outputDirectory>
<glue>
<package>com.compareglobalgroup.stepdefs</package>
<package>com.compareglobalgroup.cucumber.hooks</package>
</glue>
<featuresDirectory>src/test/resources/feature</featuresDirectory>
<cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
<format>json</format>
<plugins>
<plugin>
<name>json</name>
</plugin>
</plugins>
<tags>
<tag>#BBDK</tag>
</tags>
<useTestNG>true</useTestNG>
<!-- <namingScheme>simple</namingScheme> <namingPattern>Parallel{c}TestRunner</namingPattern> -->
<parallelScheme>FEATURE</parallelScheme>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<forkCount>10</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/Parallel*IT.class</include>
</includes>
<!-- You can specify a specific testng.xml file here <suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng-sample.xml</suiteXmlFile> </suiteXmlFiles> -->
<!-- Or dynamically with something like '-DsuiteXmlFile=src/test/resources/testng-sample.xml' -->
<!-- <suiteXmlFiles> <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> </suiteXmlFiles> -->
<!-- Build with '-DskipTests=true' to bypass test execution # build
time Default: false -->
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<systemPropertyVariables>
<browser>${browser}</browser>
<execution>${execution}</execution>
<environment>${environment}</environment>
<!-- <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> -->
<country>${country}</country>
<vertical>${vertical}</vertical>
<homeUrl>${homeUrl}</homeUrl>
<isHeadless>${isHeadless}</isHeadless>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
You need to have your <plugin> entry available under
<build>
<plugins>
<plugin>
<!-- add your plugin entry here -->
</plugin>
</plugins>
</build>
But you have added it under <pluginManagement> which is usually used to control plugin behavior for projects that inherit from the current one. See here for more information.
CI Jenkins is running on CentOS headless machine under non-root user.
Xvfb packege is installed, when I try the hint from How can I specify a display?, i.e. manually set in the console
export DISPLAY=127.0.0.1:0
Xvfb :0
firefox &
and it works - the Xvfb output displays some firefox requests, Firefox output to the console.
When I run the same thing from maven, nothing happens. Please review my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>somegrouppegas</groupId>
<artifactId>pegas</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>pegas</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<thucydides.version>0.9.273</thucydides.version>
<thucydides.jbehave.version>0.9.273</thucydides.jbehave.version>
<webdriver.driver>firefox</webdriver.driver>
<actualVersion>0.9.7.1-BETA</actualVersion>
</properties>
<dependencies>
<dependency>
<groupId>net.thucydides</groupId>
<artifactId>thucydides-core</artifactId>
<version>${thucydides.version}</version>
</dependency>
<dependency>
<groupId>net.thucydides</groupId>
<artifactId>thucydides-junit</artifactId>
<version>${thucydides.version}</version>
</dependency>
<dependency>
<groupId>net.thucydides</groupId>
<artifactId>thucydides-jbehave-plugin</artifactId>
<version>${thucydides.jbehave.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.apache.ftpserver</groupId>
<artifactId>ftpserver-core</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>com.javadocmd</groupId>
<artifactId>simplelatlng</artifactId>
<version>RELEASE</version>
</dependency>
<!--<dependency>
<groupId>com.github.arachnidium</groupId>
<artifactId>arachnidium-app-model</artifactId>
<version>${actualVersion}</version>
</dependency> -->
</dependencies>
<build>
<plugins>
<!--
XMInd plugin is not needed right now; it will be added after it will be improved
<plugin>
<groupId>mavenplugintest</groupId>
<artifactId>mavenplugintest</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<xmindpath>parse.xmind</xmindpath>
</configuration>
<executions>
<execution>
<id>generateStoriesFromXMind</id>
<phase>validate</phase>
<goals>
<goal>generateStoriesFromXMind</goal>
</goals>
</execution>
<execution>
<id>generateXMindFromTestResults</id>
<phase>post-integration-test</phase>
<goals>
<goal>generateXMindFromTestResults</goal>
</goals>
</execution>
</executions>
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<forkCount>0</forkCount>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<configuration>
<forkCount>0</forkCount>
<includes>
<include>**/*Test.java</include>
<include>**/Test*.java</include>
<include>**/When*.java</include>
<include>**/*TestSuite.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<!--<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments> -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
</plugin>
<plugin>
<groupId>net.thucydides.maven.plugins</groupId>
<artifactId>maven-thucydides-plugin</artifactId>
<version>${thucydides.version}</version>
<executions>
<execution>
<id>thucydides-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>maven2</id>
<activation>
<file>
<missing>${basedir}</missing>
</file>
</activation>
<reporting>
<plugins>
<plugin>
<groupId>net.thucydides.maven.plugins</groupId>
<artifactId>maven-thucydides-plugin</artifactId>
<version>${thucydides.version}</version>
</plugin>
</plugins>
</reporting>
</profile>
<profile>
<id>jenkins</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>xvfb</id>
<phase>pre-integration-test</phase>
<goals>
<goal>xvfb</goal>
</goals>
<configuration>
<display>:0</display>
</configuration>
</execution>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
<logOutput>true</logOutput>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>maven3</id>
<activation>
<file>
<exists>${basedir}</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.2</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>net.thucydides.maven.plugins</groupId>
<artifactId>maven-thucydides-plugin</artifactId>
<version>${thucydides.version}</version>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
The firefox and Xvfb utilities are chowned for the jenkins linux user and chmoded 777, so the permissions are not the root of the problem.
export DISPLAY=127.0.0.1:0
Is set to pre-build actions. Xvfb should be started by the maven selenium plugin and it is started according to the mavn output and own Xvfb log.
I'd like to know how Thucydides/Selenium defines how to find the Firefox binaries to run? May be they should be explicitly configured in jenkins profile somehow?
Actually, I couldn't resolve the problem in the way I liked, because despite of any combinations of DISPLAY variables, attributing files and binaries to the jenkins user and back to root, it was impossible to run Xvfb from the maven plugin config. However, the Xvfb Jenkins plugin worked fine! And if was more perfect for me, since I no longer need different mvn profiles to run on the local machine and on the CI (Xvfb run for the plugin was stored as jenkins profile),
I want to distribute the war of my web application generated with Maven with the source code inside it. How to do that with Maven?
It is possible configure the maven-war-plugin to include the source directory as it was a web resource:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${build.sourceDirectory}</directory>
<targetPath>sources</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
The java sources will be included in a sources directory in the war. Of course you should adapt the resource directory to your own maven layout.
If you want the source files in the same directory as the class files you would use:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${build.sourceDirectory}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
Usually I think you would go this way: (this won't include the source files, but provides them as separate files)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
At your war project's pom.xml:
<build>
...
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<attachClasses>true</attachClasses>
<classesClassifier>classes</classesClassifier>
</configuration>
</plugin>
...
</plugins>
</pluginManagement>
</build>
In the projects you want do use it:
<dependency>
<groupId>my-war-group</groupId>
<artifactId>my-war-artifact-id</artifactId>
<version>my-war-version</version>
<classifier>classes</classifier> <!-- THIS IS THE IMPORTANT LINE! -->
</dependency>
I have a scenario wherein my project needs to be compiled in different JDKs and the resulting artifact name should be different based on the JDK used. For example if the project name is MyProject and I call mvn install then it needs to be compiled in JDK 1.4 as well as JDK 1.5, and finally I get two jars of the same project (MyProjectJDK14-1.0 and MyProjectJDK15-1.0). Is is possible to achieve this?
The Maven way to do this is not to change the finalName of the artifact but to use a classifier. For example:
<project>
...
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classifier>${envClassifier}</classifier>
</configuration>
</plugin>
</plugins>
</build>
...
<profiles>
<profile>
<id>jdk16</id>
<activation>
<jdk>1.6</jdk>
</activation>
<properties>
<envClassifier>jdk16</envClassifier>
</properties>
</profile>
<profile>
<id>jdk15</id>
<activation>
<jdk>1.5</jdk>
</activation>
<properties>
<envClassifier>jdk15</envClassifier>
</properties>
</profile>
</profiles>
</project>
The JAR artifact will be named ${finalName}-${envClassifier}.jar and included as a dependency using the following syntax:
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>my-project</artifactId>
<version>1.0</version>
<classifier>jdk16</classifier>
</dependency>
You'll have to call the Maven build twice to produce both jars (a decent CI engine can do that).
What you can do is to define two profiles, one per JDK used. Each profile will be activated regarding which JDK is used:
<profiles>
<profile>
<id>profile-for-jdk1.4</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>1.4</jdk>
</activation>
<build>
<finalName>myBuild-jdk1.4</finalName>
</build>
</profile>
<profile>
<id>profile-for-jdk1.5</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>1.5</jdk>
</activation>
<build>
<finalName>myBuild-jdk1.5</finalName>
</build>
</profile>
</profiles>
Then, in each profile, you define a specific <finalName>, which will be used to name the generated JAR file.
Thus, if you build your application using JDK 1.4, the generated JAR will be named myBuild-jdk1.4.jar.
If your final package is built using an assembly, you can simply change the <build> block inside profiles to configure the assembly plugin (for example to <finalName>).
Regarding your comment: Indeed, this procedure will need two separate builds on Maven, as you have to recompile the whole project when changing the JDK version. One of the Maven2 convention is that one project = one artifact. What you want is to have one project with two artifacts.
Eventually, one solution is to use Hudson to build your application, and especially the matrix feature of this tool, which allows you to run multiple builds with various parameters, in your case the JDK.
Use Maven Profiles. Add this section inside the project tag of your pom.xml:
<profiles>
<profile>
<activation>
<jdk>1.4</jdk>
</activation>
<build>
<finalName>${project.artifactId}-${project.version}-JDK1.4</finalName>
</build>
</profile>
<profile>
<activation>
<jdk>1.5</jdk>
</activation>
<build>
<finalName>${project.artifactId}-${project.version}-JDK1.5</finalName>
</build>
</profile>
</profiles>
See this to know more about profiles.
A similar problem is the different variants of the JDBC api used in different versions of the JDK.
I decided that these needed different arifactIds rather than classifiers.
You can achieve this by setting a property in settings and then referencing this in the artifactId tag:
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>throwing-jdbc-${jdbc.version}</artifactId>
<name>Throwing JDBC</name>
<profiles>
<profile>
<id>jdbc3</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>[1.3,1.4,1.5]</jdk>
</activation>
<properties>
<jdbc.version>3.0</jdbc.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<sources>
<source>src/jdbc3-variants/java</source>
</sources>
</configuration>
<executions>
<execution>
<goals>
<goal>add-source</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdbc4</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>1.6</jdk>
</activation>
<properties>
<jdbc.version>4.0</jdbc.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<configuration>
<sources>
<source>src/jdbc4/java</source>
<source>src/jdbc4-variants/java</source>
</sources>
</configuration>
<executions>
<execution>
<goals>
<goal>add-source</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdbc41</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<jdbc.version>4.1</jdbc.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<configuration>
<sources>
<source>src/jdbc4/java</source>
<source>src/jdbc4.1/java</source>
<source>src/jdbc4.1-variants/java</source>
</sources>
</configuration>
<executions>
<execution>
<goals>
<goal>add-source</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
There is actually a way to produce more than one WAR with one build (I guess this works for JARs as well): you can use the assembly plugin with multiple executions for different descriptors.
I have a project of persistence with spring and hibernate built with maven, I'm running the testing using Junit and a test database HSQLDB, when I do a test first initialize the database HSQLDB in server mode, is there some way to make hudson initializes the database, or with maven ?
I'd use DbUnit and the DbUnit Maven Plugin for that. You can use it to Clear database and insert a dataset before test phase and/or to setup data for each test cases (see the Getting Started for JUnit 3, see this blog post for example for JUnit 4).
Another option would be to use the SQL Maven Plugin. The examples section has a configuration that shows how to drop/create a database and schema, then populate it before the test phase, and drop the database after the test phase).
The later approach gives you less control on data setup between tests which is why I prefer DbUnit.
I add the folowing to pom.
<build>
<extensions>
<extension>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</extension>
<extension>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>annotationconfiguration</implementation>
<outputDirectory>/src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<jdk5>true</jdk5>
<export>false</export>
<drop>true</drop>
<outputfilename>schema.sql</outputfilename>
</componentProperties>
</configuration>
<executions>
<execution>
<id>generate-ddl</id>
<phase>process-classes</phase>
<goals>
<!--Genera Esquema-->
<goal>hbm2ddl</goal>
<!--Genera Clases -->
<!-- <goal>hbm2java</goal> -->
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>create-schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<srcFiles>
<srcFile>target/hibernate3/sql/schema.sql</srcFile>
</srcFiles>
</configuration>
</execution>
<execution>
<id>drop-db-after-test</id>
<phase>test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<sqlCommand>DROP SCHEMA public CASCADE</sqlCommand>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>
</dependencies>
<configuration>
<driver>org.hsqldb.jdbcDriver</driver>
<username>sa</username>
<password></password>
<url>jdbc:hsqldb:file:etc/out/test.db;shutdown=true</url>
<autocommit>true</autocommit>
<skip>${maven.test.skip}</skip>
</configuration>
</plugin>
</plugins>
</build>
and the folowing to my datasource:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" lazy-init="true"
destroy-method="close">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:file:etc/out/test.db;shutdown=true" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
We do that with Maven under Hudson, with a profile that triggers the maven-antrun-plugin in the process-test-resources phase. In our case the maven-antrun-plugin runs a Java class that generates the schema, but of course there are other options. It looks like this:
<profile>
<id>dev</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-database-schema-new</id>
<phase>process-test-resources</phase>
<configuration>
<tasks>
...
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>