Packaging Java or Scala Handler Code with Maven

If you are using Maven to build and package your code, you can use the Maven Assembly Plugin to create a JAR file that contains all of the dependencies.

Once you have a JAR file, you can upload the file to a Snowflake stage, then reference it in an IMPORTS statement when you create a function or procedure. For more information on uploading JAR files, refer to Making Dependencies Available to Your Code. For more information on choosing whether to have code inline or on a stage, refer to Keeping Handler Code In-line or on a Stage.

To create an JAR file with your handler code, use the following steps.

  1. In the directory for your project (for example, hello-snowpark/), create a subdirectory named assembly/.

  2. In that directory, create an assembly descriptor file that specifies that you want to include dependencies in your JAR file.

    For an example, see jar-with-dependencies.

  3. If your project requires the Snowpark library, exclude its JAR file from the output archive because the library is already included on Snowflake.

    In the assembly descriptor, add a <dependencySet> element that excludes the Snowpark library from your JAR file.

    For example:

    <assembly xmlns=""

    For information about the elements in an assembly descriptor, see Assembly Descriptor Format.

  4. In your pom.xml file, under the <project> » <build> » <plugins>, add a <plugin> element for the Maven Assembly Plugin.

    In addition, under <configuration> » <descriptors>, add a <descriptor> that points to the assembly descriptor file that you created in the previous steps.

    For example: