A maven packaging plugin that enables <packaging>sql</packaging> for .sql artifacts.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A maven packaging plugin that enables <packaging>sql</packaging> for .sql artifacts.

Why? Shouldn't .sql files go in SCM?

Yes, a .sql file would normally be stored in SCM. However, in some cases, it's nice to treat them as versioned binaries. For example, you might have a build which programmatically aggregates a number of smaller .sql files (fix-1.sql, fix-2.sql, fix-3.sql) into a single .sql file (productpatch-2.0.0.sql). In this case, the aggregate is never edited, but is a build artifact. As such, it is handy to treat it as a versioned binary so that you can add it as a Maven <dependency>, and, for example, package it into an installer using the maven-assembly-plugin.

Building the Plugin

Clone this repository and install the plugin to your local Maven repository:

$ cd sql-packaging-plugin
$ mvn clean install

Using the Plugin

In the Maven project you wish to package as a .sql file, edit the pom.xml file to enable extensions for the plugin and declare the packaging type to be sql:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">



When the plugin is executed (by default, in the package phase), the plugin looks for a file in /target (or ${project.build.directory}) with a name of the format artifactId-version.sql. Using the example pom above, the plugin would expect a file named myartifact-2.0.0.sql. Whether this file is copied from someplace else, e.g. src/main/resources, or created via the execution of some other plugin is up to you.