You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Vinita Joshi <vj...@etouch.net> on 2006/12/12 23:36:03 UTC
SQL scripts in webapp
I want to use sql scripts in my webapp which I am building using maven 2.
However, the scripts are executed when I run mvn package command. I want
these scripts to be executed when I deploy the app on geronimo.
Any help is appreciated.
Regards,
Vinita
I have added the following in my pom.xml
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>ojdbc14</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.1.0.4.0</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<username>sf</username>
<password>sf</password>
<!-- You can comment out username/password configurations and
have maven to look them up in your settings.xml using
${settingsKey}
-->
<settingsKeys>sensibleKey</settingsKeys>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@localhost:1521:orcl</url>
</configuration>
<executions>
<execution>
<id>create-data</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<fileset>
<basedir>src</basedir>
<includes>
<!-- These 2 files may not get executed in sequence, use
srcFiles instead, if needed -->
<include>test/sql/test-data.sql</include>
<!--<include>test/sql/test-data2.sql</include>-->
</includes>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
RE: SQL scripts in webapp
Posted by Ryan Slobojan <rs...@babycenter.com>.
Hi,
On our side, we created the best of both worlds:
* We used Ant's <exec> to call the command-line SQL client (in the poster's case, SQLPlus) and to rebuild the database as desired
* We then used those ant scripts as the basis for a Maven plugin
End result, a fully integrated and reusable ant-based database build process which is integrated into Maven's build lifecycle.
Thanks,
Ryan Slobojan
-----Original Message-----
From: Phillip Rhodes [mailto:spamsucks@rhoderunner.com]
Sent: Tue 12/12/2006 7:11 PM
To: Maven Users List
Subject: Re: SQL scripts in webapp
I dealt with this one too. I had to take a step back.
Maven is great for building/compiling code, but it is not an platform
for execution.
My problem went away when I decided to use maven to package/build my
projects and left sql/data migration programs/etc/ to ant scripts.
Just my 2 cents.
Vinita Joshi wrote:
>I want to use sql scripts in my webapp which I am building using maven 2.
>However, the scripts are executed when I run mvn package command. I want
>these scripts to be executed when I deploy the app on geronimo.
>
>
>
>Any help is appreciated.
>
>
>
>Regards,
>
>
>
>Vinita
>
>
>
>
>
>I have added the following in my pom.xml
>
>
>
><plugins>
>
> <plugin>
>
>
>
> <groupId>org.codehaus.mojo</groupId>
>
> <artifactId>sql-maven-plugin</artifactId>
>
>
>
> <dependencies>
>
> <!-- specify the dependent jdbc driver here -->
>
> <dependency>
>
> <groupId>ojdbc14</groupId>
>
> <artifactId>ojdbc14</artifactId>
>
> <version>10.1.0.4.0</version>
>
> </dependency>
>
> </dependencies>
>
>
>
> <!-- common configuration shared by all executions -->
>
> <configuration>
>
> <username>sf</username>
>
> <password>sf</password>
>
> <!-- You can comment out username/password configurations and
>
> have maven to look them up in your settings.xml using
>${settingsKey}
>
> -->
>
> <settingsKeys>sensibleKey</settingsKeys>
>
> <driver>oracle.jdbc.driver.OracleDriver</driver>
>
> <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>
> </configuration>
>
>
>
> <executions>
>
>
>
>
>
> <execution>
>
> <id>create-data</id>
>
> <phase>process-test-resources</phase>
>
> <goals>
>
> <goal>execute</goal>
>
> </goals>
>
> <configuration>
>
> <fileset>
>
> <basedir>src</basedir>
>
> <includes>
>
> <!-- These 2 files may not get executed in sequence, use
>srcFiles instead, if needed -->
>
> <include>test/sql/test-data.sql</include>
>
> <!--<include>test/sql/test-data2.sql</include>-->
>
> </includes>
>
> </fileset>
>
> </configuration>
>
> </execution>
>
>
>
>
>
> </executions>
>
> </plugin>
>
> </plugins>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: SQL scripts in webapp
Posted by Phillip Rhodes <sp...@rhoderunner.com>.
I dealt with this one too. I had to take a step back.
Maven is great for building/compiling code, but it is not an platform
for execution.
My problem went away when I decided to use maven to package/build my
projects and left sql/data migration programs/etc/ to ant scripts.
Just my 2 cents.
Vinita Joshi wrote:
>I want to use sql scripts in my webapp which I am building using maven 2.
>However, the scripts are executed when I run mvn package command. I want
>these scripts to be executed when I deploy the app on geronimo.
>
>
>
>Any help is appreciated.
>
>
>
>Regards,
>
>
>
>Vinita
>
>
>
>
>
>I have added the following in my pom.xml
>
>
>
><plugins>
>
> <plugin>
>
>
>
> <groupId>org.codehaus.mojo</groupId>
>
> <artifactId>sql-maven-plugin</artifactId>
>
>
>
> <dependencies>
>
> <!-- specify the dependent jdbc driver here -->
>
> <dependency>
>
> <groupId>ojdbc14</groupId>
>
> <artifactId>ojdbc14</artifactId>
>
> <version>10.1.0.4.0</version>
>
> </dependency>
>
> </dependencies>
>
>
>
> <!-- common configuration shared by all executions -->
>
> <configuration>
>
> <username>sf</username>
>
> <password>sf</password>
>
> <!-- You can comment out username/password configurations and
>
> have maven to look them up in your settings.xml using
>${settingsKey}
>
> -->
>
> <settingsKeys>sensibleKey</settingsKeys>
>
> <driver>oracle.jdbc.driver.OracleDriver</driver>
>
> <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>
> </configuration>
>
>
>
> <executions>
>
>
>
>
>
> <execution>
>
> <id>create-data</id>
>
> <phase>process-test-resources</phase>
>
> <goals>
>
> <goal>execute</goal>
>
> </goals>
>
> <configuration>
>
> <fileset>
>
> <basedir>src</basedir>
>
> <includes>
>
> <!-- These 2 files may not get executed in sequence, use
>srcFiles instead, if needed -->
>
> <include>test/sql/test-data.sql</include>
>
> <!--<include>test/sql/test-data2.sql</include>-->
>
> </includes>
>
> </fileset>
>
> </configuration>
>
> </execution>
>
>
>
>
>
> </executions>
>
> </plugin>
>
> </plugins>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: SQL scripts in webapp
Posted by Rahul Thakur <ra...@gmail.com>.
How are you deploying the app to a geronimo instance (Cargo Maven plugin?)
You can use a <profile> and nest your plugin's configuration therein and
invoke the profile using '-P <profileName>' when you want to invoke the
deploy goal (I am assuming you are using Cargo for deployment).
HTH,
Rahul
Vinita Joshi wrote:
> I want to use sql scripts in my webapp which I am building using maven 2.
> However, the scripts are executed when I run mvn package command. I want
> these scripts to be executed when I deploy the app on geronimo.
>
>
>
> Any help is appreciated.
>
>
>
> Regards,
>
>
>
> Vinita
>
>
>
>
>
> I have added the following in my pom.xml
>
>
>
> <plugins>
>
> <plugin>
>
>
>
> <groupId>org.codehaus.mojo</groupId>
>
> <artifactId>sql-maven-plugin</artifactId>
>
>
>
> <dependencies>
>
> <!-- specify the dependent jdbc driver here -->
>
> <dependency>
>
> <groupId>ojdbc14</groupId>
>
> <artifactId>ojdbc14</artifactId>
>
> <version>10.1.0.4.0</version>
>
> </dependency>
>
> </dependencies>
>
>
>
> <!-- common configuration shared by all executions -->
>
> <configuration>
>
> <username>sf</username>
>
> <password>sf</password>
>
> <!-- You can comment out username/password configurations and
>
> have maven to look them up in your settings.xml using
> ${settingsKey}
>
> -->
>
> <settingsKeys>sensibleKey</settingsKeys>
>
> <driver>oracle.jdbc.driver.OracleDriver</driver>
>
> <url>jdbc:oracle:thin:@localhost:1521:orcl</url>
>
> </configuration>
>
>
>
> <executions>
>
>
>
>
>
> <execution>
>
> <id>create-data</id>
>
> <phase>process-test-resources</phase>
>
> <goals>
>
> <goal>execute</goal>
>
> </goals>
>
> <configuration>
>
> <fileset>
>
> <basedir>src</basedir>
>
> <includes>
>
> <!-- These 2 files may not get executed in sequence, use
> srcFiles instead, if needed -->
>
> <include>test/sql/test-data.sql</include>
>
> <!--<include>test/sql/test-data2.sql</include>-->
>
> </includes>
>
> </fileset>
>
> </configuration>
>
> </execution>
>
>
>
>
>
> </executions>
>
> </plugin>
>
> </plugins>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org