# Additional Configuration

# Setup Proxy

Requirements

Proxy settings require at least version 2.0.1 of the jSparrow Maven plugin.

# Set Forwarding in Proxy

Configure your proxy to allow to reach the endpoint for our licensing service at:

License API endpoint

https://go.netlicensing.io/core/v2/rest

# Define Proxy for Maven

The proxy for maven can be defined in your Maven's settings.xml like this:

<settings>
  ...
  <proxies>
   <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>https</protocol>
      <host>proxy.example.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
    </proxy>
  </proxies>
  ...
</settings>

For further information, have a look at Configuring a Proxy (opens new window)

# Eclipse Formatter File

Via the -Dformatter=<formatter-file-path> parameter, jSparrow can be configured to use a custom formatter configuration for the Reformat Code rule. The <formatter-file-path> has to point to a valid Eclipse formatter file.

# How-to

The easiest way to get a valid Eclipse formatter file is to create it within Eclipse's Code Formatter Preferences (opens new window) and export it from there via Export All.

Eclipse's Code Formatter Preferences offer countless ways to customize formatting, plus a preview window that showcases all changes.

Eclipse Formatter Preferences

Note

Export All will export all self-made formatter profiles and therefore ignore the profiles with the [built-in] suffix.

Note

In case of multiple self-made formatter profiles, jSparrow will take the first one. Either make sure, the formatter XML file only contains one profile, or that the desired profile comes first.

# Formatting Settings Similar to IntelliJ IDEA

Eclipse's Code Formatter Preferences offer a vast amount of customizations and make it possible to configure formatting options similar to other IDEs, such as IntelliJ IDEA. There are subtle differences in the approach how Eclipse and IntelliJ handle formatting though, which makes it impossible to use the exact same formatting in Eclipse, that is default in IntelliJ.

# Differences include:

  • Chained method calls cannot be excluded from line wrapping
  • A lot of parameter alignment options work differently (e.g., try-with-resource cannot have the option "Do not wrap" and "Indent on column" at the same time)
  • A lot of comment related formatting works differently (e.g., one-line block comments are not put into separate lines reliably, options to remove blank lines are different, etc.)
  • It is not possible to use different line wrapping options depending on the element of an annotation (e.g., "Wrap where necessary" on class annotations but not on local variable annotations)

That being said, here (opens new window) are formatting settings that are similar to IntelliJ.

# Specifying the Lombok Agent

If the project uses Lombok (opens new window), then maven has to be configured to include the Lombok Java Agent upon the JVM spin up. This is achieved through the MAVEN_OPTS (opens new window) environment variable. Depending on your operating system, the environment variables are set as follows:

# Linux

Use the following commands to set MAVEN_OPTS and run the jSparrow Maven Plugin in Linux:

export MAVEN_OPTS=-javaagent:/path/to/lombok.jar
mvn jsparrow:refactor

# Windows

Use the following commands to set MAVEN_OPTS and run the jSparrow Maven Plugin in Windows Command Prompt:

set MAVEN_OPTS="-javaagent:C:\path\to\lombok.jar"
mvn jsparrow:refactor

Similarly, on Windows Powershell you can use the following:

$Env:MAVEN_OPTS = "-javaagent:C:\path\to\lombok.jar"
mvn jsparrow:refactor

In both cases, relative paths can also be used.