Peter Penzov
Peter Penzov

Reputation: 1656

Configure Maven to use javac -O

There is a option javac -O to compile the optimized java code according to the Javac manual. Can I use maven to use this flag?

Upvotes: 0

Views: 754

Answers (2)

khmarbaise
khmarbaise

Reputation: 97447

Hi you need to configure the maven-compiler-plugin like this:

<project>
  ...
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.1</version>
          <configuration>
            <optimize>true</optimize>
            ...
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  ...
</project>

Upvotes: 5

Lucas
Lucas

Reputation: 14959

From the documentation, you could do something like this:

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <compilerArgument>-O</compilerArgument>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>

Upvotes: -2

Related Questions