Compilation error maven

I have a maven project forked and cloned from a git repo onto my eclipse. It is build on Java 8. The first thing i do is perform a mvn clean install But I get following failure message: [INFO]

I have a maven project forked and cloned from a git repo onto my eclipse. It is build on Java 8. The first thing i do is perform a

mvn clean install

But I get following failure message:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Maven ---
[INFO] Deleting /Users/vshukla/git/Prism/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Maven ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/vshukla/git/Prism/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 66 source files to /Users/vshukla/git/Prism/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/vshukla/git/Prism/src/main/java/PrenPost/scanUtility.java:[54,52] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /Users/vshukla/git/Prism/src/main/java/main/AppUtility.java:[87,86] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /Users/vshukla/git/Prism/src/main/java/PrenPost/ComparisionUtility.java:[58,52] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[INFO] 3 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.266 s
[INFO] Finished at: 2017-03-01T12:11:27+05:30
[INFO] Final Memory: 13M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure:
[ERROR] /Users/vshukla/git/Prism/src/main/java/PrenPost/scanUtility.java:[54,52] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] /Users/vshukla/git/Prism/src/main/java/main/AppUtility.java:[87,86] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] /Users/vshukla/git/Prism/src/main/java/PrenPost/ComparisionUtility.java:[58,52] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[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

However, below is the build path details of the project which clearly has JRE — 8 set up:
build path

and the compilation set up:

Compliance level

No matter how many times I build the project, i get the same error. Even after cleaning the project and refreshing it from eclipse doesn’t help. Please guide.

UPDATE:

After adding the properties to set maven compiler plugin

<properties>
 <maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target>
</properties>

,

am getting the below error:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Maven ---
[INFO] Deleting /Users/vshukla/git/Prism/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Maven ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/vshukla/git/Prism/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 66 source files to /Users/vshukla/git/Prism/target/classes
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING : 
[INFO] -------------------------------------------------------------
[WARNING] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java: /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java uses or overrides a deprecated API.
[WARNING] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java: Recompile with -Xlint:deprecation for details.
[WARNING] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java: Some input files use unchecked or unsafe operations.
[WARNING] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java: Recompile with -Xlint:unchecked for details.
[INFO] 4 warnings 
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java:[26,22] package com.apple.eawt does not exist
[ERROR] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java:[93,41] cannot find symbol
  symbol: class Application
[ERROR] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java:[93,67] cannot find symbol
  symbol: variable Application
[INFO] 3 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.591 s
[INFO] Finished at: 2017-03-01T13:09:47+05:30
[INFO] Final Memory: 21M/347M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure:
[ERROR] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java:[26,22] package com.apple.eawt does not exist
[ERROR] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java:[93,41] cannot find symbol
[ERROR] symbol: class Application
[ERROR] /Users/vshukla/git/Prism/src/main/java/main/MainUITabbed.java:[93,67] cannot find symbol
[ERROR] symbol: variable Application
[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

And here is the code snippet giving the compilation error from MainUITabbed class:

import com.apple.eawt.Application;
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {


                Application application = Application.getApplication(); // line 93

                ImageIcon imgicon = new ImageIcon(getClass().getResource(
                        "ICON.jpg"));
                Image img = imgicon.getImage();


                application.setDockIconImage(img);

                MainUITabbed frame = new MainUITabbed();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();

            }
        }
    });
}

Содержание

  1. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile on project client-java-api #795
  2. Comments
  3. Does not compile twice with maven-compiler-plugin 3.3 #17
  4. Comments
  5. Maven compiler plugin compilation error
  6. Optional Parameters
  7. Parameter Details

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile on project client-java-api #795

Could you please help me with the following issue I got while executing mvn install:

Java version: 13, maven 3.6.2

The text was updated successfully, but these errors were encountered:

Hrm,
I will try to reproduce this. It might be a Java 13 thing.

In the meantime, does an mvn clean fix the issue?

Yes, mvn clean itself returns BUILD SUCCESS .

after a mvn clean does mvn install work?

Ok, I will try to reproduce this.

There definitely appear to be compilation problems with Java 13. For now, I would recommend using an earlier JDK (it compiles w/ Java 11 for example)

We’ll continue to try to figure out what’s going on here.

@iocanel I’m seeing failures in compiling the generated code w/ Java 13:

The generated code looks like:

I’m not sure why the List isn’t getting the right templates, but something is definitely confused.

Have you tested sundr.io on java 13?

@brendanburns: Just tried sundrio with OpenJDK 13.0.1. Other than some issues related to tests, I didn’t notice any other kind of issue.

To be more specific, the generated BuildFluent.java seems to be generated as expected.

To further troubleshoot this, I think that it might make sense to try and use the exact same version and flavour of JDK.

In my tests I am using sdkman and I am installing Java.Net , GrallVM and Amazon variants of JDK.

I’ve only witnesed issues once with OpenJ9 .

What is the exact version you are using?

I’m using oracle jdk with jenv with 2 configurations:

Strange but I got the same errors with the amazon jdk :

The same with sdkman with AdoptOpenJDK , so weird.

Allright, I’ve found my hero:

Still weird why it didn’t work for all the previous versions in my environment.

Ok, let me see how it works with these JDKs for me.

I got exactly the same errors described at the top of this thread with OpenJDK 11.0.5 when using the instructions to build the JAR files (mvn package) with this configuration:

I see references to others successfully building it with this JDK version, but is the recommendation to drop to v10.x?

Note: when using the «mvn install» option, I’m getting this error:

Update: I installed OpenJDK 10 and retried the instructions to create the JAR files . the original errors listed at the start of this thread no longer occur, but I’m still getting the the error about «No getter found for property»:

So this error occurs with both OpenJDK v10 and 11.

I get this on a clean install both in MacOS. First encountered this with Catalina + JDK 13, then wiped my java/, re-cloned and build with JDK 11. Both failed with the above message. A subsequent mvn install failed with a different error (io.sundr.SundrException: No getter found for property: instance on class: io.kubernetes.client.openapi.models.V1ClusterRoleBindingListFluentImpl).

I was also able to reproduce on Linux with a fresh build using openjdk version «12.0.2» 2019-07-16.

On mac-os, mvn clean && mvn -T=1 install fails in a different way:
[ERROR] ../java/kubernetes/src/main/java/io/kubernetes/client/openapi/apis/AdmissionregistrationApi.java:63: error: attribute not supported in HTML5: summary
[ERROR]

FYI, I did some fixes in sundrio to better support flavors of JDK11 and JDK13 also added some circleci configuration so that pull requests are validated against JDK8, JDK11 and JDK13.

I will release later today!

EDIT: version 0.21.0 is on its way to central.

Источник

Does not compile twice with maven-compiler-plugin 3.3 #17

I noticed this in one of my own projects where I was using the latest maven-compiler-plugin 3.3, but you can reproduce it in auto-matter as well.

First time works.

Compiling a second time breaks

Is this an actual java bug or a problem with maven-compiler-plugin or auto-matter?

The text was updated successfully, but these errors were encountered:

This seems to be an issue with javac and/or maven-compiler-plugin

One straightforward fix is to get into the habit of mvn clean . This also works around issues like e.g. maven-compiler-plugin leaving orphan class files around in target/ , etc.

Another suggested workaround is to set maven-compiler-plugin configuration option useIncrementalCompilation to false. I have not verified myself but I think @mattnworb has had success with that.

Invoking javac directly seems to work correctly.

Added a readme comment about this issue:

Ideally we’d contribute to maven-compiler-plugin and try to resolve this issue upstream. Any takers? 😃

Correct that setting useIncrementalCompilation to false as a workaround works (at least with 1.8.0_40), and I’ve only seen this when compiling with JDK8 (i.e. when JAVA_HOME is set to 1.8.x).

Regarding the javac example above — Maven sets the -sourcepath to be both src/main/java and target/generated-sources/annotations :

and the compiler output seems to show that the javac bug is hit when parsing one of the generated files (but I could be reading it wrong, since the error comes after javac says «parsing completed» of the Builder that auto-matter generated):

maven-compiler-plugin 3.1 and earlier work. 3.2 and 3.3 fail.

Compiling with java7 also breaks but with a different error message:

Источник

Maven compiler plugin compilation error

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: compile.
  • The goal is thread-safe and supports parallel builds.
  • Since version: 2.0.
  • Binds by default to the lifecycle phase: compile.

Optional Parameters

Classpath elements to supply as annotation processor path. If specified, the compiler will detect annotation processors only in those classpath elements. If omitted, the default classpath is used to detect annotation processors. The detection itself depends on the configuration of annotationProcessors.

Each classpath element is specified using their Maven coordinates (groupId, artifactId, version, classifier, type). Transitive dependencies are added automatically. Example:

Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies.

Sets the arguments to be passed to the compiler.

Note that -J options are only passed through if fork is set to true.

Sets the unformatted single argument string to be passed to the compiler. To pass multiple arguments such as -Xmaxerrs 1000 (which are actually two arguments) you have to use compilerArguments.

This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.

Note that -J options are only passed through if fork is set to true.

Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+

Default value is: $/generated-sources/annotations.

Specify the requirements for this jdk toolchain for using a different javac than the one of the JRE used by Maven. This overrules the toolchain selected by the maven-toolchain-plugin.

note: requires at least Maven 3.3.1

The -source argument for the Java compiler.

NOTE: Since 3.8.0 the default value has changed from 1.5 to 1.6. Since 3.9.0 the default value has changed from 1.6 to 1.7
Default value is: 1.7.
User property is: maven.compiler.source.

The -target argument for the Java compiler.

NOTE: Since 3.8.0 the default value has changed from 1.5 to 1.6. Since 3.9.0 the default value has changed from 1.6 to 1.7
Default value is: 1.7.
User property is: maven.compiler.target.

to enable/disable incremental compilation feature.

This leads to two different modes depending on the underlying compiler. The default javac compiler does the following:

  • true (default) in this mode the compiler plugin determines whether any JAR files the current module depends on have changed in the current build run; or any source file was added, removed or changed since the last compilation. If this is the case, the compiler plugin recompiles all sources.
  • false (not recommended) this only compiles source files which are newer than their corresponding class files, namely which have changed since the last compilation. This does not recompile other classes which use the changed class, potentially leaving them with references to methods that no longer exist, leading to errors at runtime.

Default value is: true.
User property is: maven.compiler.useIncrementalCompilation.

Name Type Since Description
List 3.5
Map 2.0.1 Deprecated. use compilerArgs instead.
String 2.0 The compiler id of the compiler to use. See this guide for more information.
Default value is: javac.
User property is: maven.compiler.compilerId.
String 2.5 Strategy to re use javacc class created:

  • reuseCreated (default): will reuse already created but in case of multi-threaded builds, each thread will have its own instance
  • reuseSame: the same Javacc class will be used for each compilation even for multi-threaded build
  • alwaysNew: a new Javacc class will be created for each compilation

Note this parameter value depends on the os/jdk you are using, but the default value should work on most of env.
Default value is: $ .
User property is: maven.compiler.compilerReuseStrategy.

String 2.0 Version of the compiler to use, ex. «1.3», «1.5», if fork is set to true.
User property is: maven.compiler.compilerVersion.
boolean 3.10 Package info source files that only contain javadoc and no annotation on the package can lead to no class file being generated by the compiler. This causes a file miss on the next compilations and forces an unnecessary recompilation. The default value of true causes an empty class file to be generated. This behavior can be changed by setting this parameter to false.
Default value is: true.
User property is: maven.compiler.createMissingPackageInfoClass.
boolean 2.0 Set to true to include debugging information in the compiled class files.
Default value is: true.
User property is: maven.compiler.debug.
String 3.10.0 when forking and debug activated the commandline used will be dumped in this file
Default value is: javac.
String 2.1 Keyword list to be appended to the -g command-line switch. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debug level is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored.
User property is: maven.compiler.debuglevel.
boolean 3.10.1 Set to true to Enable preview language features of the java compiler
Default value is: false.
User property is: maven.compiler.enablePreview.
String 2.1 The -encoding argument for the Java compiler.
Default value is: $ .
User property is: encoding.
Set 2.0 A list of exclusion filters for the compiler.
String 2.0 Sets the executable of the compiler to use when fork is true.
User property is: maven.compiler.executable.
boolean 2.0.2 Indicates whether the build will continue even if there are compilation errors.
Default value is: true.
User property is: maven.compiler.failOnError.
boolean 3.6 Indicates whether the build will continue even if there are compilation warnings.
Default value is: false.
User property is: maven.compiler.failOnWarning.
List 3.1 File extensions to check timestamp for incremental build. Default contains only class and jar.
boolean 3.0 compiler can now use javax.tools if available in your current jdk, you can disable this feature using -Dmaven.compiler.forceJavacCompilerUse=true or in the plugin configuration
Default value is: false.
User property is: maven.compiler.forceJavacCompilerUse.
boolean 2.0 Allows running the compiler in a separate process. If false it uses the built in compiler, while if true it will use an executable.
Default value is: false.
User property is: maven.compiler.fork.
File 2.2
Set 2.0 A list of inclusion filters for the compiler.
Map 3.6
String 2.0.1 Sets the maximum size, in megabytes, of the memory allocation pool, ex. «128», «128m» if fork is set to true.
User property is: maven.compiler.maxmem.
String 2.0.1 Initial size, in megabytes, of the memory allocation pool, ex. «64», «64m» if fork is set to true.
User property is: maven.compiler.meminitial.
boolean 3.7.1

When set to true, the classes will be placed in META-INF/versions/$ The release value must be set, otherwise the plugin will fail.

Note: A jar is only a multirelease jar if META-INF/MANIFEST.MF contains Multi-Release: true. You need to set this by configuring the maven-jar-plugin. This implies that you cannot test a multirelease jar using the outputDirectory.

boolean 2.0 Deprecated. This property is a no-op in javac.
Default value is: false.
User property is: maven.compiler.optimize.
String 2.0 Sets the name of the output file when compiling a set of sources to a single file. expression=»$»
boolean 3.6.2 Set to true to generate metadata for reflection on method parameters.
Default value is: false.
User property is: maven.compiler.parameters.

Sets whether annotation processing is performed or not. Only applies to JDK 1.6+ If not set, both compilation and annotation processing are performed at the same time.

Allowed values are:

  • none — no annotation processing is performed.
  • only — only annotation processing is done, no compilation.
String 3.6 The -release argument for the Java compiler, supported since Java9
User property is: maven.compiler.release.
boolean 2.0 Sets whether to show source locations where deprecated APIs are used.
Default value is: false.
User property is: maven.compiler.showDeprecation.
boolean 2.0 Set to true to show compilation warnings.
Default value is: false.
User property is: maven.compiler.showWarnings.
boolean 2.0 Set this to ‘true’ to bypass compilation of main sources. Its use is NOT RECOMMENDED, but quite convenient on occasion.
User property is: maven.main.skip.
boolean 2.5 (no description)
Default value is: false.
User property is: maven.compiler.skipMultiThreadWarning.
String 2.0
int 2.0 Sets the granularity in milliseconds of the last modification date for testing whether a source needs recompilation.
Default value is: .
User property is: lastModGranularityMs.
String 2.0
boolean 3.1
boolean 2.0 Set to true to show messages about what the compiler is doing.
Default value is: false.
User property is: maven.compiler.verbose.

Parameter Details

Classpath elements to supply as annotation processor path. If specified, the compiler will detect annotation processors only in those classpath elements. If omitted, the default classpath is used to detect annotation processors. The detection itself depends on the configuration of annotationProcessors.

Each classpath element is specified using their Maven coordinates (groupId, artifactId, version, classifier, type). Transitive dependencies are added automatically. Example:

  • Type: java.util.List
  • Since: 3.5
  • Required: No

Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies.

  • Type: java.lang.String[]
  • Since: 2.2
  • Required: No

Sets the arguments to be passed to the compiler.

Note that -J options are only passed through if fork is set to true.

  • Type: java.util.List
  • Since: 3.1
  • Required: No

Sets the unformatted single argument string to be passed to the compiler. To pass multiple arguments such as -Xmaxerrs 1000 (which are actually two arguments) you have to use compilerArguments.

This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.

Note that -J options are only passed through if fork is set to true.

  • Type: java.lang.String
  • Since: 2.0
  • Required: No

Sets the arguments to be passed to the compiler (prepending a dash).

This is because the list of valid arguments passed to a Java compiler varies based on the compiler version.

Note that -J options are only passed through if fork is set to true.

To pass -Xmaxerrs 1000 -Xlint -Xlint:-path -Averbose=true you should include the following:

  • Type: java.util.Map
  • Since: 2.0.1
  • Required: No
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.compilerId
  • Default: javac
  • Type: java.lang.String
  • Since: 2.5
  • Required: No
  • User Property: maven.compiler.compilerReuseStrategy
  • Default: $
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.compilerVersion
  • Type: boolean
  • Since: 3.10
  • Required: No
  • User Property: maven.compiler.createMissingPackageInfoClass
  • Default: true
  • Type: boolean
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.debug
  • Default: true
  • Type: java.lang.String
  • Since: 3.10.0
  • Required: No
  • Default: javac
  • Type: java.lang.String
  • Since: 2.1
  • Required: No
  • User Property: maven.compiler.debuglevel
  • Type: boolean
  • Since: 3.10.1
  • Required: No
  • User Property: maven.compiler.enablePreview
  • Default: false
  • Type: java.lang.String
  • Since: 2.1
  • Required: No
  • User Property: encoding
  • Default: $
  • Type: java.util.Set
  • Since: 2.0
  • Required: No
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.executable
  • Type: boolean
  • Since: 2.0.2
  • Required: No
  • User Property: maven.compiler.failOnError
  • Default: true
  • Type: boolean
  • Since: 3.6
  • Required: No
  • User Property: maven.compiler.failOnWarning
  • Default: false
  • Type: java.util.List
  • Since: 3.1
  • Required: No
  • Type: boolean
  • Since: 3.0
  • Required: No
  • User Property: maven.compiler.forceJavacCompilerUse
  • Default: false
  • Type: boolean
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.fork
  • Default: false

Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+

  • Type: java.io.File
  • Since: 2.2
  • Required: No
  • Default: $/generated-sources/annotations
  • Type: java.util.Set
  • Since: 2.0
  • Required: No

Specify the requirements for this jdk toolchain for using a different javac than the one of the JRE used by Maven. This overrules the toolchain selected by the maven-toolchain-plugin.

  • Type: java.util.Map
  • Since: 3.6
  • Required: No
  • Type: java.lang.String
  • Since: 2.0.1
  • Required: No
  • User Property: maven.compiler.maxmem
  • Type: java.lang.String
  • Since: 2.0.1
  • Required: No
  • User Property: maven.compiler.meminitial

When set to true, the classes will be placed in META-INF/versions/$ The release value must be set, otherwise the plugin will fail.

Note: A jar is only a multirelease jar if META-INF/MANIFEST.MF contains Multi-Release: true. You need to set this by configuring the maven-jar-plugin. This implies that you cannot test a multirelease jar using the outputDirectory.

  • Type: boolean
  • Since: 3.7.1
  • Required: No
  • Type: boolean
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.optimize
  • Default: false
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • Type: boolean
  • Since: 3.6.2
  • Required: No
  • User Property: maven.compiler.parameters
  • Default: false

Sets whether annotation processing is performed or not. Only applies to JDK 1.6+ If not set, both compilation and annotation processing are performed at the same time.

Allowed values are:

  • none — no annotation processing is performed.
  • only — only annotation processing is done, no compilation.
  • Type: java.lang.String
  • Since: 2.2
  • Required: No
  • Type: java.lang.String
  • Since: 3.6
  • Required: No
  • User Property: maven.compiler.release
  • Type: boolean
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.showDeprecation
  • Default: false
  • Type: boolean
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.showWarnings
  • Default: false
  • Type: boolean
  • Since: 2.0
  • Required: No
  • User Property: maven.main.skip
  • Type: boolean
  • Since: 2.5
  • Required: No
  • User Property: maven.compiler.skipMultiThreadWarning
  • Default: false

The -source argument for the Java compiler.

NOTE: Since 3.8.0 the default value has changed from 1.5 to 1.6. Since 3.9.0 the default value has changed from 1.6 to 1.7

  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.source
  • Default: 1.7
  • Type: int
  • Since: 2.0
  • Required: No
  • User Property: lastModGranularityMs
  • Default:

The -target argument for the Java compiler.

NOTE: Since 3.8.0 the default value has changed from 1.5 to 1.6. Since 3.9.0 the default value has changed from 1.6 to 1.7

  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • User Property: maven.compiler.target
  • Default: 1.7

to enable/disable incremental compilation feature.

This leads to two different modes depending on the underlying compiler. The default javac compiler does the following:

  • true (default) in this mode the compiler plugin determines whether any JAR files the current module depends on have changed in the current build run; or any source file was added, removed or changed since the last compilation. If this is the case, the compiler plugin recompiles all sources.
  • false (not recommended) this only compiles source files which are newer than their corresponding class files, namely which have changed since the last compilation. This does not recompile other classes which use the changed class, potentially leaving them with references to methods that no longer exist, leading to errors at runtime.

Источник

Today We are Going To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure in Java. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

Contents

  • 1 How to Fix Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure Error?
    • 1.1 Solution 1 : Add the properties
    • 1.2 Solution 2 : Add the code into pom.xml
    • 1.3 Solution 3 : Use sudo apt-get remove
  • 2 Conclusion
    • 2.1 Also Read These Solutions
  1. How to Fix Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure Error?

    To Fix Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure Error just Add the properties. Here you have to configure maven-compiler-plugin itself. So just add the following properties to solve this issue. This will help you. try it! <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties>

  2. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure

    To Fix Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure Error just Add the code into pom.xml. To solve this error you have to just add the code into pom.xml just like below. Try it. <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>

Solution 1 : Add the properties

Here you have to configure maven-compiler-plugin itself. So just add the following properties to solve this issue. This will help you. try it!

<properties>
 <maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Solution 2 : Add the code into pom.xml

To solve this error you have to just add the code into pom.xml just like below. Try it.

<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>

Solution 3 : Use sudo apt-get remove

If you don’t need JDK 9 then just use the below commands to solve this issue.

sudo apt-get remove --purge openjdk-9-jdk openjdk-9-jre 
sudo apt-get remove --purge openjdk-9-jdk-headless openjdk-9-jre-headless

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read These Solutions

  • ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found
  • package org.springframework.boot does not exist
  • The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt
  • android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify
  • npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to run mvn clean install but I am facing following error Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

Contents

  1. How This Error Occurs ?
  2. How To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure Error ?
  3. Solution 1: add the following properties
  4. Solution 2: add this code in effective POM
  5. Solution 3: Using org.projectlombok:lombok
  6. Summary

How This Error Occurs ?

I am trying to run mvn clean install but I am facing following error.

[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!

diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)

diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure:

  1. How To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure Error ?

    To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure Error Here problem is Maven doesn’t have a source that will allow to compile the diamond operators So that we need to configure maven-compiler-plugin itself So Just add the following properties. Now, Your problem might be solved. Second solution is If You are using org.projectlombok:lombok then You need to update org.projectlombok:lombok version to 1.16.22 or 1.18.12, Just like this. And my error solved.

  2. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure

    To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven: Compilation failure: Compilation failure Error Here problem is Maven doesn’t have a source that will allow to compile the diamond operators So that we need to configure maven-compiler-plugin itself So Just add the following properties. Now, Your problem might be solved. Second solution is If You are using org.projectlombok:lombok then You need to update org.projectlombok:lombok version to 1.16.22 or 1.18.12, Just like this. And my error solved.

Solution 1: add the following properties

Here problem is Maven doesn’t have a source that will allow to compile the diamond operators So that we need to configure maven-compiler-plugin itself So Just add the following properties.

<properties>
 <maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Now, Your problem might be solved.

Solution 2: add this code in effective POM

Just need to add this code in effective POM.xml file.

<dependencies>
...
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Solution 3: Using org.projectlombok:lombok

If You are using org.projectlombok:lombok then You need to update org.projectlombok:lombok version to 1.16.22 or 1.18.12, Just like this.

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.22</version>
        </dependency>

And my error solved.

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

  • java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Today, I faced a compilation failure in Bitbucket pipelines for a simple Java project. The project compiles successfully in the local machine.

The stack trace of the failure was not useful at all:

------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.655 s
[INFO] Finished at: 2020-10-14T22:24:42Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-cli) on project automation: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-cli) on project automation: Compilation failure
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1224)
    at org.apache.maven.plugin.compiler.TestCompilerMojo.execute (TestCompilerMojo.java:180)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[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

The stack trace doesn’t report any file names or lines numbers. This means the compilation error is not with the source code itself.

Reading the help doc gave me some clue about the problem. After spending some time in investigation, I found that this issue occurred because I was using a custom executable for maven-compiler-plugin that includes a environment variable:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>11</source>
          <target>11</target>
          <executable>${env.JAVA_11_HOME}/bin/javac</executable>
          <fork>true</fork>
        </configuration>
</plugin>

Since this environment variable was present in my local system but was not set in Bitbucket pipelines, I was getting the above exception. Setting the environment variable like below in my bitbucket-pipelines.yml file resolved the issue:

image: maven:3.6.3-openjdk-11
pipelines:
  default:
    - step:
        script:
          - JAVA_11_HOME=/usr/local/openjdk-11 mvn -e -X clean compile compiler:testCompile

If you are using Jenkins/Ubuntu, the path to Java may be different. Use sudo update-alternatives --config java to find out the path. Eg. on my Ubuntu, Java 11 is installed into /usr/lib/jvm/java-11-openjdk-amd64

Details
Written by  
Last Updated on 01 April 2022   |   Print  Email

When building a Java project using Maven (for example, run mvn package in command line) you may encounter this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project ProjectName: 
Fatal error compiling: error: invalid target release: 17 -> [Help 1]

The error is invalid target release: 17 — that means the project’s Java version is 17 but Maven is running under lower JDK version. To see the version of JDK that runs Maven, type mvn -v and you will see something like this:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: g:apache-maven-3.6.3bin..
Java version: 15, vendor: Oracle Corporation, runtime: g:OpenJDK15jdk-15

That means Maven is using Java version 15, whereas the project uses Java version 17, hence that invalid target release error.

So to fix this kind of error, you can either:

— Change Java version of the project to the one that less than or equal to the version of JDK that runs Maven.

— Change the JDK that runs Maven, to be greater than or equal the project’s Java version

 

1. Fix invalid target release error by changing project’s Java version

Open the pom.xml file, and update Java version to a version that is less than or equal to the JDK version that runs Maven. For example:

<properties>
	<java.version>11</java.version>
</properties>

This is for a Spring Boot project. For a general Maven project, you may need to update as follows:

<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>

Or maybe you need to update in the Maven compiler plugin’s configuration like this:

<configuration>
    <release>13</release>
</configuration>

Then run mvn package again, the invalid target release error will be gone.

2. Fix invalid target release error by changing Maven’s Java version

Apply this solution if the project’s Java version cannot be lower. That means you need to have another JDK newer than the one that runs Maven. You can check by typing:

java -version

Or:

mvn -v

You need to install a newer JDK and then update JAVA_HOME or PATH environment variables. Follow my guides here (for example, install JDK 17):

  • Download and install Oracle JDK 17
  • How to set JAVA_HOME environment variable

Note that you need to open a new command prompt window after updating the environment variables.

 

If you encounter the Maven error invalid target release in your IDE such as Eclipse or Spring Tool Suite, follow these steps:

— Open the Run Configurations dialog (Go to menu Run > Run Configurations)

— Select the Run configuration that you use to run Maven build

— Click JRE tab. Then choose the Runtime JRE that has version greater than or equal to your project’s Java version.

edit run configuration maven

Refer to this article to learn more: How to manage JRE installations in Eclipse.

To see how to fix the Maven build error invalid target release in action, watch the following video:

Video:

 

Other Maven Articles:

  • Maven — how to exclude tests from build
  • How to change Java version for Maven project

About the Author:

Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.

Add comment

Проблема

При запуске компиляции с помощью mvn валится ошибка «Compilation failure», которой не предшествует какой бы то ни было ругани javac-а, как это обычно бывает при некомпилируемом коде. При использовании ключа -e валится stacktrace, не сильно информативнее:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
0:compile (default-compile) on project project-core: Compilation failure -> [Help
1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on p
roject project-core: Compilation failure
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
        …
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compila
tion failure
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(Abstrac
tCompilerMojo.java:749)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.ja
va:118)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
        … 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

Причина

Пролить свет на причину ошибки помог анализ вывода запуска mvn с ключем -X, включающим вывод кучи отладочной информации. В частности, в выводе обнаружилась следующая строчка:

[DEBUG]   (f) executable = C:/Program Files (x86)/Java/jdk1.6.0_25/bin/javac.exe

Она привлекла внимание по той причине, что JAVA_HOME смотрит вовсе не туда, и вообще указанный путь не существует. Залез в settings.xml, и действительно, увидел там вот это:

<properties>
   <java.1.6.home>C:/Program Files (x86)/Java/jdk1.6.0_25</java.1.6.home>
   <java.1.6.compiler>${java.1.6.home}/bin/javac.exe</java.1.6.compiler>
</properties>

Исправление данного пути на корректный поправило компиляцию (впрочем, можно было бы и удалить этот блок вообще и понадеяться на переменные окружения).

Apache Maven is a Software Project Management tool. Based on the concept of a Project Object Model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information.

On Crunchify, we do have more than ~20 different maven tutorials including Setting up Maven Classpath on Windows and MacOS, maven-war-plugin, maven-shade-plugin, maven-assembly-plugin, etc.

In this tutorial we will go over highly and widely used some tips and tricks which will fix most of the Maven and POM dependency related issues for your in Eclipse IDE.

Below tips will work if you have any of below questions:

  • In Java how to fix Maven, Maven Configuration and Maven Dependency issue?
  • How do I update my Maven project to work in Eclipse?
  • maven dependency problem in eclipse
  • maven dependency problem eclipse missing artifact
  • How to fix error “Updating Maven Project”?
  • Maven Common Problems And Solutions

Let’s get started:

Task-1: Perform “Project Clean” in Eclipse IDE

Step-1

  • Create new maven based project or open existing maven project.
  • In my case, I’m opening my existing Simplest Spring MVC Hello World Project in Eclipse.

Step-2

  • Click on Project Menu item in Eclipse
  • Choose Clean... option from list

Eclipse Project Clean Option

Step-3

  • Select a project which you want to clean or Select All
  • In my case it’s just CrunchifySpringMVCTutorial

Select a Project which you want to clean in Eclipse IDE

Task-2: Perform Maven Update Project in Eclipse IDE

Step-4

  • Right click on Project
  • Click on Maven
  • Click on Update Project...

Perform Maven Update Project in Eclipse IDE

Task-3: Perform Maven clean install in Eclipse IDE

Step-5

  • Right click on project
  • Click on Run As
  • Click on Maven build...

mvn clean install in Eclipse IDE

Step-6

  • Provide Goal: mvn clean install
  • Select checkbox for Skip Tests
  • Click Apply and Run

Maven - mvn clean install Configuration Steps in Eclipse IDE

You should see BUILD SUCCESS message after successful run.

Build Success Message after mvn clean install

By performing above steps most of the common Maven build issues should be resolved in Eclipse. Let me know if you face any more issues and will try to debug.

Last Option:

Nothing worked and you are still getting weird Maven issue? Try deleting .m2/repository folder via File Explorer.

-> After that perform above steps and all maven libraries will be downloaded again fresh.


Join the Discussion

If you liked this article, then please share it on social media. Still have any questions about an article, leave us a comment.

Share:

I’m an Engineer by profession, Blogger by passion & Founder of Crunchify, LLC, the largest free blogging & technical resource site for beginners. Love SEO, SaaS, #webperf, WordPress, Java. With over 16 millions+ pageviews/month, Crunchify has changed the life of over thousands of individual around the globe teaching Java & Web Tech for FREE.

Reader Interactions


Problem: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

Solution: Follow the solution 2 or 3 as per this link ->


Problem: Maven build Compilation error ‘Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven’ 

OR: After adding Extentreport file, Maven build is not working.

Solution: Follow either one or both solutions. 

1.Need to configuration maven-compiler-plugin in Pom.Xml file as below, save and run again. To know more, click here ->

<project>
<properties>

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</Project>

2.Follow the below instruction if the issue is still happening:

-Open pom.xml file.
-Go to “Dependencies” tab.
-Select “testng” package and click on “Properties…”
-On opened screen change “Scope” option to “compile” and click “OK” to save it.
-Try to build your project again with “compile test” goals


Problem: The JAVA_HOME environment variable is not defined correctly

This environment variable is needed to run this program

NB: JAVA_HOME should point to a JDK not a JRE

Solution: Follow this Link->


Problem: NoGoalSpecifiedException

Solution: Define a default goal in your POM as shown below

<project>

  ...

  <build>

    <defaultGoal>install</defaultGoal>

    ...

  </build>

  ...

</project>

Or follow steps 1-4 as per given link: https://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException


Problem: Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven.

Solution

1. Add following properties

<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>

2. Add default goal under build tag:

<build>
<defaultGoal>install</defaultGoal>

</build>

3. Make sure you have the necessary dependencies.

4. Clean Project: Project> clean

5. Update Project: Right click on Project>Maven> update Project

6. Build and run the project

Related Link: Click here..


Problem: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project EndtoEndProj: Compilation failure: Compilation failure

[ERROR] /C:/user/Study/ProjectName/src/main/java/resources/ExtentReporterNG.java:[9,18] package org.testng does not exist

Solution: If the  scope of testng depency in pom .xml file is defined as test as below:

<dependency>

<groupId>org.testng</groupId>

<artifactId>testng</artifactId>

<version>7.1.0</version>

<scope>test</scope>

</dependency>
1. change the version to : <version>7.0.0</version> and try.

2. With this scope , If we run mvn compile , throwing errors.
So update the scope as:  <scope>compile</scope>   and try.


Problem: [ERROR] : Unable to initialize main class SeleniumTest
Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver

Solution: NoClassDefFoundError in Java occurs when Java Virtual Machine is not able to find a particular class at runtime which was available at compile time. For example, if we have resolved a method call from a class or accessing any static member of a Class and that Class is not available during run-time then JVM will throw NoClassDefFoundError.

What went wrong :
From all the above mentioned points it’s clear that the related Class or Methods were resolved from one source Compile Time which was not available during Run Time.

This situation occurs if there are presence of multiple sources to resolve the Classes and Methods through JDK / Maven / Gradle.

Here are a few steps to solve NoClassDefFoundError :

  • While using a Build Tool e.g. Maven or Gradleremove all the External JARs from the Java Build PathMaven or Gradle will download and resolve all the required dependencies.
  • If using Selenium JARs within a Java Project add only required External JARs within the Java Build Path and remove the unused one.
  • While using Maven, either use <artifactId>selenium-java</artifactId> or <artifactId>selenium-server</artifactId>. Avoid using both at the same time.
  • Remove the unwanted other <dependency> from pom.xml
  • Clean you Project Workspac within your IDE periodically only to build your project with required dependencies.
  • Use CCleane tool to wipe away the OS chores periodically.
  • While you execute a Maven Project always do maven cleanmaven install and then maven test.

Source: https://stackoverflow.com/questions/47823506/exception-in-thread-main-java-lang-noclassdeffounderror-org-openqa-selenium-w

Понравилась статья? Поделить с друзьями:
  • Compilation error expected unqualified id before token
  • Compilation error expected primary expression before token
  • Compilation error expected constructor destructor or type conversion before token
  • Compilation error expected at end of input
  • Compilation error exit status 1 esp8266