How to disable a flag in maven compiler plugin? - maven

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project AusPost: Compilation failure
[ERROR] javac: invalid flag: -s
[ERROR] Usage: javac
I am not providing any tag to the maven compiler plugin in my pom.xml. Still it is throwing error saying invalid flag -s.
How to get rid of this?
POM.XML ->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>

Usually, -s comes for settings.xml of maven, but you have to provide more info in order to understand your question.

Related

How can I override properties for test-aggregate-no-fork?

I configured different version for main and test.
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
<maven.compiler.release>${maven.compiler.target}</maven.compiler.release>
<maven.compiler.testSource>17</maven.compiler.testSource>
<maven.compiler.testTarget>${maven.compiler.testSource}</maven.compiler.testTarget>
<maven.compiler.testRelease>${maven.compiler.testTarget}</maven.compiler.testRelease>
When I do the site, the plugin complains.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:4.0.0-M3:site (default-site) on project ...: Error generating maven-javadoc-plugin:3.4.1:test-aggregate-no-fork report:
[ERROR] Exit code: 1 - Loading source files for package ...
[ERROR] Loading source files for package ...
[ERROR] Loading source files for package ...
[ERROR] /.../src/test/java/.../Some.java:16: warning: as of release 10, 'var' is a restricted type name and cannot be used for type declarations or as the element type of an array
[ERROR] final var found = repositoryInstance().findAllBy...(' ', Pageable.unpaged());
[ERROR] ^
I tried with following execution and got no luck.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<configuration>
</configuration>
<executions>
<execution>
<id>default-test-aggregate-no-fork</id>
<configuration>
<source>${maven.compiler.testSource}</source>
</configuration>
</execution>
</executions>
</plugin>

Maven compiler plugin - send parameters to javac (classpath or cp)

Is it possible to send arguments to javac through maven compiler plugin?
I want to set three classpaths as a argument to javac but maven returns
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project wplex-frameworks: Compilation failure
[ERROR] javac: invalid flag: classpath=*:.
[ERROR] Usage: javac <options> <source files>
Code:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<executable>/usr/lib/jvm/java-8-openjdk-amd64/bin/javac</executable>
<compilerArgs>
<arg>classpath=*:.</arg>
<arg>-verbose</arg>
<arg>-Xlint:all,-options,-path</arg>
</compilerArgs>
<excludes>
<exclude>x/y/z/**</exclude>
</excludes>
</configuration>
</plugin>
I have tried so far classpath=:. , -classpath=:. , -classpath *:.
The other arguments are fine.

why I get error Maven source deployment is not supported for Java 8 GAE project after migration from appcfg mvn to gcloud

i run this cmd
gcloud app deploy
and get this error
[ERROR] No plugin found for prefix 'gcloud' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/gallavie/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [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/NoPluginFoundForPrefixException
this is my plugin in pom.xml file
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>2.5.1</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<archiveClasses>true</archiveClasses>
<webResources>
<!-- in order to interpolate version from pom into appengine-web.xml -->
<resource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
</plugin>
</plugins>
</build>
The reason why you are getting that error is because you are missing the gcloud dependency in your pom.xml, try adding the following to it:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.2.0</version>
</plugin>
Also for more information for deploy using maven to appengine, you can check this documentation
had a similar issue after migration, pom was fine, the following command helped.
mvn clean package install -P dev appengine:deploy -Dapp.deploy.version=app_version
The documentation here and here were helpful.
The following has worked for me:
mvn package appengine:deploy

Use JDK11 for specific Maven submodule compilation fails

I have a Maven project with 3 submodules: 2 of them should be compiled with java8 and one of them with java11. My main JAVA_HOME environment variable when running maven is set to the JDK 8 installed in my machine. I want to specify to use the jdk 11 only for the specific submodule that needs it but I can't make it work.
In the POM father I have the following
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
In the specific subproject that needs jdk 11 I tried to setup things following this documentation http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html so I have
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
<verbose>true</verbose>
<fork>true</fork>
<executable>${JAVA_11_HOME}/bin/javac</executable>
</configuration>
</plugin>
and the JAVA_11_HOME variable is set in my settings.xml (according to the doc)
When I run the compilation (either of the whole project or of the single java11 submodule) I get
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile
(default-compile) on project features-serving: Compilation failure -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project
features-serving: Compilation failure
If I run with debug and stacktrace enabled I don't get any useful information. Basically I cannot figure out what it is going wrong. Only thing I am sure is that maven is picking up correctly the JDK 11 path from my settings.xml file.

Jenkins error: Plugin requires Maven version 2.2.1

I have a solution in IntelliJ that builds fine on my local.
Extract from the POM:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<dependencies>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
I have installed Jenkins on my local and created a simple Maven project and pointed it to my POM file from within Jenkins.
When I build the solution from Jenkins I get the following error:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error resolving version for 'org.apache.maven.plugins:maven-surefire-plugin': Plugin requires Maven version 2.2.1
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
On Jenkins I have installed:
Maven Integration plugin
2.15.1
Any ideas / advice would be appreciated.
My own silly mistake. Had to specify the Maven and Java JDK under:
Manage Jenkins --> Global Tool Configuration
After this everything worked.

Resources