jleetutorial / maven-project

Source code for James Lee's Jenkins course
https://www.level-up.one
199 stars 10.08k forks source link

Maven build error #181

Open uncle-norman opened 3 years ago

uncle-norman commented 3 years ago

Hi James,

I'm on your Udemy Jenkins lecture.

I encountered the following error while building the first Jenkins project. Would you please kindly advise the next steps? Thank you!

[INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] error: Source option 6 is no longer supported. Use 7 or later. [ERROR] error: Target option 6 is no longer supported. Use 7 or later. [INFO] 2 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for Maven Project 1.0-SNAPSHOT: [INFO] [INFO] Maven Project ...................................... SUCCESS [ 0.142 s] [INFO] Server ............................................. FAILURE [ 0.402 s] [INFO] Webapp ............................................. SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.630 s [INFO] Finished at: 2021-09-04T09:59:06+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project server: Compilation failure: Compilation failure: [ERROR] error: Source option 6 is no longer supported. Use 7 or later. [ERROR] error: Target option 6 is no longer supported. Use 7 or later. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :server Build step 'Invoke top-level Maven targets' marked build as failure Finished: FAILURE

jpa1911 commented 1 year ago

I had the same problem and still did not get a solution. Did you get any?

Vishal31122000 commented 5 months ago

The issue is related to the compilation failure due to source and target compatibility levels. However, in the webapp.xml provided, there is no Maven Compiler Plugin configuration similar to the server-side pom.xml.

FIXED the compilation issue, we can add the Maven Compiler Plugin configuration to the webapp module's pom.xml. <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/maven-v4_0_0.xsd">

4.0.0 com.example.maven-project maven-project 1.0-SNAPSHOT ../pom.xml webapp war Webapp Webapp. ${project.artifactId} org.apache.maven.plugins maven-compiler-plugin 3.8.1 7 7 org.mortbay.jetty jetty-maven-plugin javax.servlet servlet-api provided javax.servlet.jsp jsp-api provided

Ensure that we replace 7 with the appropriate source and target compatibility levels we want to use. After updating the pom.xml, save the changes and rebuild your project in Jenkins. This should resolve the source and target compatibility level errors for the webapp module.