Skip to content

Setting Scala Environment Cheat Sheet

thevpc edited this page Jul 29, 2017 · 3 revisions

Setting Scala Environment

Maven Pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

     <!--REPLACE THESE WITH YOUR ID AND VERSION -->
    <groupId>your-group-id</groupId>
    <artifactId>your-artifact-id</artifactId>
    <version>your-version</version>
    <properties>
        <!--REPLACE THIS WITH THE RIGHTFUL VERSION -->
        <scholar-version>3.1.2</scholar-version>
    </properties>
    <repositories>
        <repository>
            <id>scala-tools.org</id>
            <name>Scala-tools Maven2 Repository</name>
            <url>http://scala-tools.org/repo-releases</url>
        </repository>
        <repository>
            <id>vpc-public-maven</id>
            <url>https://raw.github.com/thevpc/vpc-public-maven/master</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>net.vpc.scholar</groupId>
            <artifactId>hadruwaves-scala</artifactId>
            <version>${scholar-version}</version>
        </dependency>
    </dependencies>
    <pluginRepositories>
        <pluginRepository>
            <id>scala-tools.org</id>
            <name>Scala-tools Maven2 Repository</name>
            <url>http://scala-tools.org/repo-releases</url>
        </pluginRepository>
    </pluginRepositories>
    <build>
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <sourceDir>src/main/java</sourceDir>
                    <jvmArgs>
                        <jvmArg>-Xms64m</jvmArg>
                        <jvmArg>-Xmx1024m</jvmArg>
                    </jvmArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Application Skeleton

Example 1

package mypackage

import net.vpc.scholar.hadruwmaths._
import net.vpc.scholar.hadruwmaths.Maths._
import net.vpc.scholar.hadruwmaths.MathScala._

object MyProgram extends App {
      // YOUR CODE GOES HERE
}

Example 2

package mypackage

import net.vpc.scholar.hadruwmaths._
import net.vpc.scholar.hadruwmaths.Maths._
import net.vpc.scholar.hadruwmaths.MathScala._

object MyProgram {
   def main(args: Array[String]) {
      // YOUR CODE GOES HERE
   }
}