Search code examples
mavenmaven-3javaspark-java

How to modify pom.xml so Maven 3.0.4 Does not think I am running SDK 1.3


I know this question gets asked every so often, but the solutions out there seem to be for older versions of Maven.

The version I am running:

hduser@lightning252:~/spark-0.7.0-2/examples/ex2$ mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.6.0_26, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-6-sun-1.6.0.26/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-4-amd64", arch: "amd64", family: "unix"

The pom.xml I am using:

<project>
  <groupId>edu.berkeley</groupId>
  <artifactId>simple-project</artifactId>
  <modelVersion>4.0.0</modelVersion>
  <name>Simple Project</name>
  <packaging>jar</packaging>
  <version>1.0</version>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
       <configuration>
        <source>1.5</source>
        <target>1.5</target>
       </configuration>
    </plugin>
  </plugins>
  <repositories>
    <repository>
      <id>Spray.cc repository</id>
      <url>http://repo.spray.cc</url>
    </repository>
    <repository>
      <id>Akka repository</id>
      <url>http://repo.akka.io/releases</url>
    </repository>
  </repositories>
  <dependencies>
    <dependency> <!-- Spark dependency -->
      <groupId>org.spark-project</groupId>
      <artifactId>spark-core_2.9.2</artifactId>
      <version>0.7.0</version>
    </dependency>
  </dependencies>
</project>

I have actually never used Maven before, I am trying to follow the instructions given by the Spark project to compile a Spark task. The pom.xml was directly lifted from:

http://spark-project.org/docs/latest/quick-start.html

I know the problem is with <plugins> could someone please let me know how to fix it?


Solution

  • After looking around, I found that <plugins> tags need to be surrounded by <build> tags.

    I changed and it works fine now. See below for correct version.

    <project>
      <groupId>edu.berkeley</groupId>
      <artifactId>simple-project</artifactId>
      <modelVersion>4.0.0</modelVersion>
      <name>Simple Project</name>
      <packaging>jar</packaging>
      <version>1.0</version>
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.2</version>
           <configuration>
            <source>1.5</source>
            <target>1.5</target>
           </configuration>
        </plugin>
      </plugins>
    </build>
      <repositories>
        <repository>
          <id>Spray.cc repository</id>
          <url>http://repo.spray.cc</url>
        </repository>
        <repository>
          <id>Akka repository</id>
          <url>http://repo.akka.io/releases</url>
        </repository>
      </repositories>
      <dependencies>
        <dependency> <!-- Spark dependency -->
          <groupId>org.spark-project</groupId>
          <artifactId>spark-core_2.9.2</artifactId>
          <version>0.7.0</version>
        </dependency>
      </dependencies>
    </project>