1

I am trying to run some vulnerability scans(Veracode) on a spring boot application. However, the scan provider suggests running the scans with binaries compiled in debug mode using the following in pom.xml file.

<build>
  <plugins>
    <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration>
        <debug>true</debug>
        <debuglevel>lines,vars,source</debuglevel>
      </configuration>
    </plugin>
  </plugins>
</build>

However, we use the same pom.xml for production deployment where we don't want debug level jars.

Is there a way to create debug jars by passing some argument to the mvn command?

Saif
  • 2,530
  • 3
  • 27
  • 45
  • 1
    https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#debug – khmarbaise Nov 26 '21 at 14:59
  • Did either of the answers answer your question? If so, could you please acknowledge our help by giving one of us a check? Thank you! – Oliver Dec 23 '21 at 15:58

2 Answers2

1

I think it is possible to set the arguments in the command line with -D like this:

mvn compile -Dmaven.compiler.debug=true -Dmaven.compiler.debuglevel=lines,vars,source
csalmhof
  • 1,820
  • 2
  • 15
  • 24
1

You can use profiles.

<profiles>
  <profile>
    <id>debug</id>
    <build>
      <plugins>
        <plugin> 
          <artifactId>maven-compiler-plugin</artifactId> 
          <configuration>
            <debug>true</debug>
            <debuglevel>lines,vars,source</debuglevel>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profile>

Profiles are activated in the mvn command, e.g., mvn ... -Pdebug.

Oliver
  • 1,465
  • 4
  • 17