I have been trying to build a code using maven. But I am stuck with an error.
The code is available on this github repo. google-play-crawler
My system configurations as shown by maven is followning:
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 19:21:28+0530)
Maven home: /Users/tushar/Downloads/apache-maven-3.0.5
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
Following is the Maven trace for the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project googleplaycrawler: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project googleplaycrawler: 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.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:862)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Here is the 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.akdeniz</groupId>
<artifactId>googleplaycrawler</artifactId>
<version>0.3</version>
<packaging>jar</packaging>
<name>Google Play Crawler</name>
<url>https://github.com/Akdeniz/google-play-crawler</url>
<description>Play with Google Play API :)</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.argparse4j</groupId>
<artifactId>argparse4j</artifactId>
<version>0.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>protoc-plugin</id>
<url>http://sergei-ivanov.github.com/maven-protoc-plugin/repo/releases/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<fork>true</fork
<executable>${JAVA_1_7_HOME}/bin/javac</executable>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>attached</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.akdeniz.googleplaycrawler.cli.googleplay</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.protobuf.tools</groupId>
<artifactId>maven-protoc-plugin</artifactId>
<version>0.3.1</version>
<configuration>
<protocExecutable>protoc</protocExecutable>
<protoSourceRoot>${project.basedir}/src/main/protobuf/</protoSourceRoot>
<languageSpecifications>
<LanguageSpecification>
<language>JAVA</language>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
</LanguageSpecification>
</languageSpecifications>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This post talks about adding maven compiler plugin dependency to projects with pom.xml,
Maven is an open-source apache tool to automate the build process for Java-based projects.
maven-compiler-plugin is a basic plugin that every developer uses to compile the source code of the maven project.
By default, this plugin is not configured.compile
goal will be called as part of the maven lifecycle process without defining it in pom.xml.
If you want to do some configurations. add this plugin in pom.xml.
JDK provides a javac tool to compile the source code. This plugin internally calls JDK javac tool_ to compile the code.
What is the Maven compiler plugin?
Maven compiler plugin is a maven plugin used to compile the java source code and generates class. It is also called the maven compiler.
It contains two goals
- compile: compile source files of a maven application
- testCompile: Compile test files of a maven app
You can also specify the version of java used to compile the project
What is the Maven compiler version?
The current Maven compiler version is 3.10.1. you can specify the version using the version property of a dependency in pom.xml. Without version tag, It takes latest version
How do I download a Maven compiler plugin?
The maven compiler plugin can be downloaded either manually or automatically.
Manually, you can download either source or binary file and copy it to the repository folder.
Another way is automatic.
Once confgiured plugin in pom.xml
It downloads the maven compiler for the first time to the local repository.
Next time onwards, it does not download from the remote repository instead of local cache repository
What is the use of Maven compiler source and target?
maven compiler compiles source files and generates class files of a maven project. source and target are configuration options that tell generated class files are backward compatible with java versions.
What is the latest version of the Maven compiler plugin?
maven compiler plugin’s latest version is 3.10.1.
Add the dependency in pom.xml with the below values
- groupId:org.apache.maven.plugins
- artifactId:maven-compiler-plugin
- version: 3.10.1
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>1.13</source>
<target>1.13</target>
</configuration>
</dependency>
How to change compiler options in pom.xml
In pom.xml
, under the plugin
tag, There is a configuration
tag, It can be used to configure different configuration options.
<project>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<!-- put your configurations here -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
How to get the maven compiler Plugin help
The below maven commands provide helpful information about the compiler plugin
mvn compiler:help -Ddetail=true
maven compiler compile goal example
There are two goals available with maven-compiler-plugin
compile
goal
It executes the compiler:compile option to compile java files as part of the compilation phase during the build process.
It takes java files in the src
folder of the maven project, generates the target/classes folder with .class files
test-compile
goal :
It executes the compiler:testCompile option to compile test java files as part of the test compilation phase during the testing process.
It takes java files in thetest
folder of the maven project, generates target/test/classes folder with .class files
maven compiler Plugin Configuration Options
There are a lot of configurations, we can change/override default values. We can add different options to the tag.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>// add Configuration options here</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Plugin configuration usage examples
we will see different configurations and examples
How to configure different java paths and compiler versions for the plugin?
Change executable
and compilerVersion
tags in the configuration
options as per your java settings.
Please see the below example for more information.
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${JAVA_HOME}/bin/javac</executable>
<compilerVersion>1.8</compilerVersion>
</configuration>
Configure the java compiler version in the plugin
JDK javac
tool has source
and target
options to set JDK versions during compilation.
This plugin also provides configuration for source and target options.
Using these options, We can change the default compiler version with a new version in pom.xml
.
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
Passing arguments to the maven compiler
Sometimes, We need to pass memory-related and garbage configurations to the compilation phase. This plugin provides a CompilerArgs
tag to do it.
<compilerArgs>
<arg>-verbose</arg>
<arg>-Xlint:all,-options,-path</arg>
</compilerArgs>
Enable encoding for source files in the compiler
We used to get a warning during the compilation process if the encoding is not set.
We can do it at either the compiler level or the project level.Compiler encoding configuration
:
<configuration>
<encoding>UTF-8</encoding>
</configuration>
maven project encoding
:
This is the root-level configuration that affects all the modules of the project
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
disable this compiler plugin in maven application
By default, the Compiler
plugin runs without configuring it in pom.xml.
please make configuration
changes in pom.xml to disable it.
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
How to change Custom Directory for source/target folder for compilation
By default, src/main/java
is java files location. Input files can be overridden using the below option
<configuration>
<include>src/javafolder</include>
</configuration>
Compiled source files i.e class files will be written to the target/test/classes
folder by default.
To override the target folder with target/myclasses
, We can use the below configuration.
<build>
<outputDirectory>${project.build.directory}/myclasses</outputDirectory>
</build>
Print dependency information of the maven compiler plugin
We can do it in two ways.
Using tree command:
mvn dependency:tree -Dverbose
Using verbose option in the configuration:
By default, verbose
is false
, change it to true
to get detailed information about this plugin.
<configuration>
<verbose>true</verbose>
</configuration>
maven compiler plugin Errors
Let’s walk through some of the errors encountered during maven compiler plugin usage.
Continue compilation when error/warning occurs
failOnError
and failOnWarning
options allow the compiler to continue compilation.
Errors will be shown once the compilation build process is completed.
javac Task: source release 8 requires target release 1.8
It is a common error running maven projects during the application build process.
It is mismatching java version incompatibility.
If maven-compiler-plugin
is not defined, Please add a plugin in pom.xml
with the following information.
Plugin property change via the below code:
<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>
This contains source and target are valid java versions.
Or you can change via project properties tag
- maven.compiler.source
- maven.compiler.source
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Change encode to UTF-8 in compiler plugin
Inside the plugin configuration, the encoding
attribute is set to true.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
Conclusion
You learned how to add the maven compiler plugin to java applications
How to change the java version in compiler options, change the encoding, disable plugins, compile and test-compile goals usage examples
Содержание
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile on project client-java-api #795
- Comments
- Does not compile twice with maven-compiler-plugin 3.3 #17
- Comments
- Maven compiler plugin compilation error
- Optional Parameters
- 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:
Note this parameter value depends on the os/jdk you are using, but the default value should work on most of env. |
|
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:
|
|||
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.
Источник
Introduction
This article is showing how to solve an error message. The error message appear in the title of this article. Actually, it is an error appear when building and compiling a Java-based application using the Netbeans IDE. It is a project using Spring Boot Framework where the error exist below :
How to Solve Error Message Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11 -> [Help 1]
Furthermore, the full complete error appears in the following actual error :
cd C:UsersPersonalDocumentsNetBeansProjectsInitializrSpringbootProject; "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_111" M2_HOME=C:\apache-maven-3.6.3 cmd /c """C:\apache-maven-3.6.3\bin\mvn.cmd" -Dmaven.ext.class.path="C:\Program Files\NetBeans 8.2\java\maven-nblib\netbeans-eventspy.jar" clean install"" Scanning for projects... --------------------------< com.example:demo >-------------------------- Building demo 0.0.1-SNAPSHOT --------------------------------[ jar ]--------------------------------- --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo --- Deleting C:UsersPersonalDocumentsNetBeansProjectsInitializrSpringbootProjecttarget --- maven-resources-plugin:3.2.0:resources (default-resources) @ demo --- Using 'UTF-8' encoding to copy filtered resources. Using 'UTF-8' encoding to copy filtered properties files. Copying 1 resource Copying 0 resource --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo --- Changes detected - recompiling the module! Compiling 3 source files to C:UsersPersonalDocumentsNetBeansProjectsInitializrSpringbootProjecttargetclasses ------------------------------------------------------------------------ BUILD FAILURE ------------------------------------------------------------------------ Total time: 2.710 s Finished at: 2021-06-28T07:03:24+07:00 ------------------------------------------------------------------------ Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11 -> [Help 1] To see the full stack trace of the errors, re-run Maven with the -e switch. Re-run Maven using the -X switch to enable full debug logging. For more information about the errors and possible solutions, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
For more information, the following is the content of the pom.xml file :
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.2</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>11</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
The above pom.xml file describe the project build and compile process. But the main problem exist while using the above pom.xml file to build and compile the project.
Solution
Actually, the solution is very simple to solve the problem. The main problem is that the compilation stuck because of the maven-compiler-plugin cannot compile and it is considered as an error compile. The reason for the incapability is because of invalid target release: 11. So, just remove by commenting the following element from the pom.xml file of the Java application project. :
Fatal error compiling: invalid target release: 11 -> [Help 1]
<!-- <properties> <java.version>11</java.version> </properties> -->
After saving the changes to the pom.xml file, just run the build and compile process again once more. If there are no more errors available, the build and compile process will be a success.
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.
- 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>
- 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 When I am trying to run my project with java 11 I am facing following error Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11 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
- How This Error Occurs ?
- How To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11 Error ?
- Solution 1: add this line in pom.xml
- Solution 2: set JAVA_HOME
- Solution 3: add java version in pom.xml
- Solution 4: Check JRE version
- Summary
How This Error Occurs ?
When I am trying to run my project with java 11 I am facing following error.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11 -> [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/MojoExecutionException
- How To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11 Error ?
To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11 Error before calling maven, try using set JAVA_HOME=C:pathtojdk11 on the first line and your error must be solved. Second solution is Just check the JRE in use for Maven. First of all Run Configurations. Then, Select your Maven Build configuration. Now, Click the JRE tab and choose the JRE version in accordance with your POM.
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11
To Solve Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error compiling: invalid target release: 11 Error before calling maven, try using set JAVA_HOME=C:pathtojdk11 on the first line and your error must be solved. Second solution is Just check the JRE in use for Maven. First of all Run Configurations. Then, Select your Maven Build configuration. Now, Click the JRE tab and choose the JRE version in accordance with your POM.
Solution 1: add this line in pom.xml
You need to add your own context in pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Solution 2: set JAVA_HOME
before calling maven, try using set JAVA_HOME=C:pathtojdk11 on the first line and your error must be solved.
Solution 3: add java version in pom.xml
add java version in pom.xml. add this follow code in your pom file.
<properties>
<java.version>1.8</java.version>
</properties>
Solution 4: Check JRE version
Just check the JRE in use for Maven.
First of all Run Configurations.
Then, Select your Maven Build configuration.
Now, Click the JRE tab and choose the JRE version in accordance with your POM.
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: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7