Skip to content
Advertisement

Why compile command failed in Maven?

I’m new on Maven and I am trying to run through command prompt. Command mvn build successfully clean command. but it failed to build compile and test command. this is my cmd screen

enter image description here

    <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>
    
      <groupId>bigProjectName</groupId>
      <artifactId>SubProjectName</artifactId>
      <packaging>jar</packaging>
      <version>0.0.1-SNAPSHOT</version>
      <name>SubProjectName</name>
      <url>http://maven.apache.org</url>
      
      <profiles>
      <profile>
      <id>Regression</id>
      
      </profile>
      </profiles>
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
    
    <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <version>3.0.0-M5</version>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
      
      <dependencies>
      
      <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>4.0.0-alpha-6</version>
      </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
      <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.3.0</version>
        <scope>test</scope>
      </dependency>
    <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
      <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>7.3.0</version>
      </dependency>
    
      </dependencies>
    </project>

Please suggest me what should I do?

Advertisement

Answer

Add two properties to specify the version of Java you want to target. Currently, it’s defaulting to 5 (which is no longer supported). For example,

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement