I'm trying to add the debug symboles by using mave-compiler-plugin (so that I'll be able to access the method parameters names).
Following the available configurations that can be found here,
Here is my maven-compiler-plugin configuration
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<debug>true</debug>
<debugLevel>lines,vars,source</debugLevel>
</configuration>
</plugin>
Untill now, I have no success.
Can someone please let me know how to add the debug symboles by using maven?
You may need to add <fork>true</fork> according to the maven-compiler-plugin documentation for compilerArgument.
Sets the unformatted single argument string to be passed to the compiler if fork is set to true.
Not sure if it's required but you may want to add <groupId>org.apache.maven.plugins</groupId> and <version>#.#.#<\version>.
Also, as #JonK mentioned in the comments, you need source instead of sources for debugLevel.
Related
I have an idea to include an immutable (performs compile-time code generation of POJO) library into a legacy project. The main issue: the legacy project is used widely in other applications, so I do not want to have any new dependency at all. I found that question where it said it is possible to use tag annotationProcessorPaths for that purpose. I try to rework my config that way:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
<showWarnings>true</showWarnings>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<version>2.9.2</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</pluginManagement>
it does not work. I get an error: Could not find artifact org.immutables:value:jar:unknown in case I add the library in dependency section - it works. As figure out later, looks like annotationProcessorPaths tag is just order of using annotation processors, but does not actually provide dependencies for them. Is it correct understanding? Is there any work around to use that annotation process without including it in dependency section at all?
I'd like to see the stacktrace of unit tests in the console. Does surefire support this?
A related problem that I found is that surefire in recent versions apparently sets trimStackTrace to true by default (rendering most stack trace in failed tests useless), which is quite inconvenient.
Setting -DtrimStackTrace=false or defining
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
solved this.
You can use the following command to see the stack trace on console instead of report files in the target/surefire-reports folder:
mvn -Dsurefire.useFile=false test
To extend the answer given before, you also can configure this behavior in your pom.xml:
..
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<useFile>false</useFile>
</configuration>
</plugin>
..
I'm working on a Maven project which uses both the Surefire and Failsafe plugins in the same module. The configurations for both plugins are pretty much identical, except for one element (classpathDependencyExcludes), as you can see.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<skipTests>${skipTests}</skipTests>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<argLine>-javaagent:"${project.build.directory}/openejb-javaagent-${tomee.version}.jar"</argLine>
<workingDirectory>${project.build.directory}</workingDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<skipTests>${skipTests}</skipTests>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<argLine>-javaagent:"${project.build.directory}/openejb-javaagent-${tomee.version}.jar"</argLine>
<workingDirectory>${project.build.directory}</workingDirectory>
<classpathDependencyExcludes>
<classpathDependencyExclude>javax:javaee-api</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
I was wondering if there was a way to share the common section of the configuration between the two plugins by writing it down once instead of multiple times. If not, in the hypothesis that both configurations were identical, would it be possible?
First of all, you don't need to set all the properties explicitly. skipTests has already the value of ${skipTests}, no need to repeat that. forkCount has already the default value 1.
Some of the other properties can be set in the <properties> section, like reuseForks and argLine.
Then there is very little left to worry about.
In eclipse I receive this error: "Endorsed directory ... is missing. You may need to perform a Maven command line build to create it."
It seems to be related to this plugin in my pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${project.build.directory}/endorsed</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
The project builds successfully on the command line. I did a clean build in Eclipse but still have this error.
What is wrong with my setup?
I think the problem is with
<endorseddirs>${project.build.directory}/endorsed</endorseddirs>
Refer to Link - Pass Compiler Arguments
In case of my project I need to create new classes after each compilation. For compilation I'm using maven compiler plugin 3.1. I tried to use compilerReuseStrategy = alwaysNew option but it didn't make any affect, it always compile only changed classes. Here is plugin declaration in pom.xml:
<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>
<compilerReuseStrategy>alwaysNew</compilerReuseStrategy>
</configuration>
</plugin>
An I doing something wrong or that's a bug and this option really doesn't work?
If you are talking about the incremental feature fo the maven-compiler-plugin you can change this behaviour by the following configuration:
<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>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
The compileReuseStrategy in contradiction is intended to define the behaviour in relationship with multi-threaded running of the compiler.
What about using mvn clean install?