Introducing Maven and Gradle Plugins for Snowflake

Some exciting news for our Java and Scala users — Snowflake has just released two new plugins for Maven and Gradle that will allow developers to easily deploy their user-defined functions (UDFs) and stored procedures to Snowflake! Follow the demo video below to get started:

You can use these plugins to deploy directly from your local machine or from a CI pipeline, such as GitHub Actions. Under the hood these plugins will create a stage if it does not already exist, upload your compiled JAR and dependencies, and then run the CREATE ... DDL for each UDF and stored procedure to create them on Snowflake. This allows you to keep your object metadata in the same project as your source code, and track it all in git.

The plugins are open source and available on Snowflake-Labs, so anyone can access them and contribute to their development. Special thanks to Stewart Bryson, a Snowflake Data Superhero, who advised and contributed to the development. If you haven’t been following, Stewart published his own Gradle plugin for Snowflake last year. We’re excited to be working with him, incorporating his work into these plugins over the coming months.

As a Snowflake-Labs project, support is provided on a best effort basis by project contributors.

Install the Plugins

To get started with the plugins, add the following plugin coordinates to your pom.xml or build.gradle. If you don’t have a Snowpark project, you can clone the Java or Scala template.

<plugin>
<groupId>com.snowflake</groupId>
<artifactId>snowflake-maven-plugin</artifactId>
<version>0.1.0</version>
</plugin>

The Gradle plugin has not yet been published to the Gradle plugin portal. See the provided intructions to do a local installation.

Authentication

Next, specify the credentials for your Snowflake account in the plugin. You can do this by referencing a profile.properties:

<plugin>
<groupId>com.snowflake</groupId>
<artifactId>snowflake-maven-plugin</artifactId>
<version>0.1.0</version>
<configuration>
<auth>
<propertiesFile>profile.properties</propertiesFile>
</auth>
</configuration>
</plugin>

… or you can specify the URL, username, password, and other values individually, either from environment variables or as strings:

<plugin>
<groupId>com.snowflake</groupId>
<artifactId>snowflake-maven-plugin</artifactId>
<version>0.1.0-SNAPSHOT</version>
<configuration>
<auth>
<url>${env.ACCOUNT_URL}</url> <!-- Env vars are supported -->
<user>${env.MY_USER}</user>
<password>${env.MY_PASSWORD}</password>
<role>MY_ROLE</role> <!-- Strings are also supported -->
<db>MY_DATABASE</db>
<schema>public</schema>
</auth>
</configuration>
</plugin>

Configuration

Now you can specify the names, handlers, and arguments for your UDFs and stored procedures. The following snippet is the configuration for a single UDF and a single stored procedure. You can specify as many objects as you want!

<plugin>
<groupId>com.snowflake</groupId>
<artifactId>snowflake-maven-plugin</artifactId>
<version>0.1.0</version>
<configuration>
<auth>
<propertiesFile>profile.properties</propertiesFile>
</auth>
<stage>artifacts</stage>
<functions>
<function>
<name>funcNameOnSnowflake</name>
<handler>ClassName.MethodName</handler>
<args>
<arg>
<name>firstArg</name>
<type>integer</type>
</arg>
<arg>
<name>secondArg</name>
<type>string</type>
</arg>
</args>
<returns>string</returns>
</function>
</functions>
<procedures>
<procedure>
<name>procNameOnSnowflake</name>
<handler>ClassName.SomeMethodName</handler>
<args>
<arg>
<name>a</name>
<type>string</type>
</arg>
</args>
<returns>string</returns>
</procedure>
</procedures>
</configuration>
</plugin>

Deploy!

Once you’ve set your configuration all that’s left is to build your project and run the plugin command to deploy it:

# Maven:
mvn clean package snowflake:deploy

# Gradle:
gradle clean assemble snowflakeDeploy

Get involved

As mentioned earlier, these plugins are open-source on Snowflake-Labs. There are a few ways to get involved:

  1. Try the plugins! If you have any questions or hit a bug, please file an issue on the repository.
  2. Check the list of planned improvements and let us know what you think in the comments.
  3. Check the contributing guide if you want to contribute directly to the plugins themselves!

--

--