I have the issue that my mvn compile fails on an internal project for some reason. Two other colleagues tried it as well and it does not fail on their machines.
We use Lombok there (I am not a fan but that was not my choice) and for some reason it fails with a StackOverflowError. After some research I found a solution, adding:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<fork>true</fork>
<compilerArgs>
<arg>-J-Xss4M</arg>
</compilerArgs>
</configuration>
</plugin>
This works fine, but I'd like not to change the pom.xml if this only happens on my machine. So is there a way to add the Xss flag to some environment variable?
I tried to add it via MAVEN_OPTS, in Windows as well as in IntelliJ -> Maven Runner Settings, with and without -Jin front, but it fails as before.
Related
This is the following error:
And these are the failed reports:
I'm completely new to maven so I'm not sure what any of this means
To clarify, maven is saying that it failed to execute it's goal (which was verify in this case). If you aren't running any test suites, maven will always record a failure, because it is configured to fail a build when you don't have any tests to run.
There are configurations which will allow maven to build successfully with no tests that can be set in your pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<failIfNoTests>false</failIfNoTests>
</configuration>
</plugin>
With this adjustment, maven will still build when you don't specify any tests. You never specified in your original post what your tests (if you have any) look like, so it's impossible to see if this is what the error is, or something else.
You need to find a way to ignore the test cases. Adding the following maven plugin solves the issue.
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
i did a maven plugin that overwrites "maven-jar-plugin" following this doc:
How do I create a new packaging type for Maven?
you can find my plugin here:
http://mvnrepository.com/artifact/org.lucee/lco-plugin/1.0
the source is here:
https://github.com/lucee/lco-maven-plugin
I only change the extension, nothing else, i get the right extension as expected, problem is the configuration is ignored
<plugin>
<groupId>org.lucee</groupId>
<artifactId>lco-plugin</artifactId>
<version>1.01-SNAPSHOT</version>
<!-- when I use this the configuration works!
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>-->
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
<extensions>true</extensions>
</plugin>
any idea what i do wrong?
You can do further debugging by running your maven build with the -X -e flags activated. This way, you'll see for each running plugin which configuration is loaded.
As the configuration is not loaded, I would suggest it's typically an activation issue that the aforementionned method will allow you to solve.
I must increase java heap space to compile my project. The only way I found is modify mvn.bat and set:
set MAVEN_OPTS=-XX:PermSize=256m -XX:MaxPermSize=256m -Xms1300M -Xmx1300M
than all colleagues must change the file localy.
I want keep all inside my project, not localy. Can I insert in the POM.xml or other file?
Setting MAVEN_OPTS usually provides arguments to the JVM running the build, and these are passed down to the compiler because it runs inline. You have probably already noted that the maven-surefire-plugin used for test usually fork a separate process so passing options to the plugin is bound inside the pom.xml.
What if you fork the compilation process also and add the flags there, such as the below example.
Notice the fork and the compiler args
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
<compilerArgument>-verbose -bootclasspath ${java.home}\lib\rt.jar</compilerArgument>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Using maven-release-plugin, I have tried all possible ways I could (on command line as well), to skip compiling my tests but have not been successful so far. I want to do skip through pom. This is how my pom.xml looks
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<arguments>-Dmaven.test.skip</arguments>
<goals>deploy</goals>
</configuration>
</plugin>
I have tried solutions from this post:
How can I get maven-release-plugin to skip my tests? but couldn't get it to work.
Tried surefire http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#skip
but no luck.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
Please help to fix my pom.xml using maven-release-plugin preferably.
AFAIK this can only be done on the command line by setting
-Darguments="-Dmaven.test.skip=true -DskipTests"
First you need to figure out how to solve this without the maven-release-plugin. Compilation of the test-classes is done by the org.apache.maven.plugins:maven-compiler-plugin:testCompile, while the execution is done by org.apache.maven.plugins:maven-surefire-plugin:test.
So it is possible, but maybe the real question is: why do you want this? Isn't this a workaround for the real cause?
Sometimes, my Talend Open Studio components have resources but not Java sources (they are purely metadata components). I need to disable the generation of JAR files in such a case.
I configured the maven-jar-plugin this way:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<forceCreation>false</forceCreation>
<skipIfEmpty>true</skipIfEmpty>
<useDefaultManifestFile>false</useDefaultManifestFile>
</configuration>
</plugin>
but I still get the ${project.name}.jar file with pom.properties, pom.cml, the manifest and an empty file App.class containing only "class {}"
While I can disable the includes of all maven stuff using this:
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
I still get a JAR with the manifest file inside it
Are there some configuration parameters I misconfigured?
Most efficient way to disable the creation of jars is to configure the maven-jar-plugin like this:
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
It will place the default jar creation in the none phase, it will never be run.
I found the solution by myself, even if it's only a workaround. I delete the JAR using a delete antrun task if /src/main/java directory doesn't exist:
<!-- remove the empty JAR if not needed -->
<if>
<not><available file="${basedir}/src/main/java" type="dir" /></not>
<then>
<delete file="${project.build.directory}/${project.name}-${project.version}.jar"/>
</then>
</if>
this task requires antcontrib to work properly and, ofc, it doesn't work if you plan to do releases with maven (but it's ok for metadata-only components, like Talend Open Studio plugins)
You can instruct maven-jar-plugin to not generate META-INF/maven/*/pom. files, as explained in Maven Archiver Reference.
Also, you can use its skipIfEmpty option.
Following code combines both these (just to have them copy-paste ready):
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<skipIfEmpty>true</skipIfEmpty>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
...
This works fine, but when you do mvn install, it fails due to missing project artifact.
Similar problem will probably be with mvn deploy and with release, but I didn't check these.
However, if you can live with antrun's delete, the property skipIfEmpty will probably work well for you, and is a bit more elegant. At least it does not introduce a new execution and its dependencies etc.