# Download and Install the Glue Spark Runtime from Maven
## Prerequisite
Users may set up AWS local credential to access some AWS services such as AWS Secret Manager and S3 for some tests.
User may setup AWS CLI and set their local credentials with command [`aws configure`](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) which can generate the AWS credential file *~/.aws/credentials*, will be used by glue local job run.
## Step 1: Install Apache Maven
Follow the section Developing Locally with Scala of this [Glue doc](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-libraries.html) to install Apache Maven from the following location: https://aws-glue-etl-artifacts.s3.amazonaws.com/glue-common/apache-maven-3.6.0-bin.tar.gz. The 'mvn' tool is in the ./bin
folder of this package.
## Step 2: Install Glue libraries
1. Download the Apache Spark distribution from one of the following locations:
1. For AWS Glue version 0.9: https://aws-glue-etl-artifacts.s3.amazonaws.com/glue-0.9/spark-2.2.1-bin-hadoop2.7.tgz
2. For AWS Glue version 1.0 and 2.0: https://aws-glue-etl-artifacts.s3.amazonaws.com/glue-1.0/spark-2.4.3-bin-hadoop2.8.tgz
3. For AWS Glue version 3.0: https://aws-glue-etl-artifacts.s3.amazonaws.com/glue-3.0/spark-3.1.1-amzn-0-bin-3.2.1-amzn-3.tgz
2. Unzip Glue libraries at some location such /home/$USER/
3. Export the SPARK_HOME environment variable, setting it to the root location extracted from the Spark archive. For example:
1. For AWS Glue version 0.9: export SPARK_HOME=/home/$USER/spark-2.2.1-bin-hadoop2.7
2. For AWS Glue version 1.0 and 2.0: export SPARK_HOME=/home/$USER/spark-2.4.3-bin-spark-2.4.3-bin-hadoop2.8
3. For AWS Glue version 3.0: export SPARK_HOME=/home/$USER/spark-3.1.1-amzn-0-bin-3.2.1-amzn-3
Note: please refer to this [Glue doc](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-libraries.html) for up-to-date information.
## Step 3: Configure Your Maven Project
1. If your connector is already packaged as a jar, you may install the connector jar in local maven repository,
```
mvn install:install-file \
-Dfile="path_to_connector.jar" \
-DgroupId="your_groupId" \
-DartifactId="your_artifactId" \
-Dversion="your_version" \
-Dpackaging="jar"
```
and add the installed connector dependency to the project pom.xml.
```xml
your_gorupIdyour_artifactIdyour_version
```
For example, add the following dependencies to the POM file for the open-source Snowflake Spark connector:
```xml
net.snowflakespark-snowflake_2.112.7.0-spark_2.4providednet.snowflakesnowflake-jdbc3.12.3providednet.snowflakespark-snowflake_2.122.9.1-spark_3.1providednet.snowflakesnowflake-jdbc3.13.6provided
```
2. To validate your connector against Glue features locally, add the [ScalaTest](https://www.scalatest.org/user_guide) dependency to the project pom.xml. Please
follow this [Using the ScalaTest Maven plugin](https://www.scalatest.org/user_guide/using_the_scalatest_maven_plugin) to disable SureFire and enable ScalaTest in the pom.xml.
```xml
org.scalatestscalatest_2.113.0.5test
```
Copy the integration tests to the local project directory.
3. Build the project.
Note: Remember to replace the Glue version string with 3.0.0 for AWS Glue 3.0, and with 2.0.0 for AWS Glue 2.0 or 1.0.0 for AWS Glue version 1.0 and 2.0.
The following is a sample POM file for the Maven project with Snowflake open-source spark
```xml
4.0.0com.amazonawsAWSGlueApp1.0-SNAPSHOT${project.artifactId}AWS Glue ETL application2.11.1org.scala-langscala-library${scala.version}com.amazonawsAWSGlueETL1.0.0net.snowflakespark-snowflake_2.112.7.0-spark_2.4providednet.snowflakesnowflake-jdbc3.12.3providedorg.scalatestscalatest_2.113.0.5testaws-glue-etl-artifactshttps://aws-glue-etl-artifacts.s3.amazonaws.com/release/src/main/scalanet.alchim31.mavenscala-maven-plugin3.4.0compiletestCompileorg.codehaus.mojoexec-maven-plugin1.6.0javaspark.masterlocal[*]spark.app.namelocalrunorg.xerial.snappy.lib.namelibsnappyjava.jniliborg.apache.maven.pluginsmaven-enforcer-plugin3.0.0-M2enforce-mavenenforce3.5.3org.apache.maven.pluginsmaven-compiler-plugin88org.apache.maven.pluginsmaven-surefire-plugin2.7trueorg.scalatestscalatest-maven-plugin1.0${project.build.directory}/surefire-reports.WDF TestSuite.txttesttest
```