Wrapper to launch scalafmt through Maven
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/main/java/com/devsmobile
.gitignore
LICENSE.md
README.md
pom.xml

README.md

Synopsis

This is a wrapper that allows you to use the Scalafmt formatter in Mvn. Current version of the embedded Scalafmt is 0.2.11

Usage

There are two goals by default you can use: verify and format. Verify will launch as default scalafmt with --test -f . through your maven projects. Format will launch as default scalafmt with -i -f . through your maven projects.

To include it into your pom.xml, just specify some lines as below in the phase you want to format/verify your code:

<plugin>
  <groupId>com.devsmobile</groupId>
  <artifactId>mvn-scalafmt</artifactId>
  <version>0.2.11</version>
  <executions>
    <execution>
      <phase>validate</phase>
      <goals>
        <goal>format</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Or

<plugin>
  <groupId>com.devsmobile</groupId>
  <artifactId>mvn-scalafmt</artifactId>
  <version>0.2.11</version>
  <executions>
    <execution>
      <phase>validate</phase>
      <goals>
        <goal>verify</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Additional parameters

If you want to change the default parameters for the format/verify goals, you can provide it in the following properties:

<plugin>
  <groupId>com.devsmobile</groupId>
  <artifactId>mvn-scalafmt</artifactId>
  <version>0.2.11</version>
  <configuration>
    <formatParameters>--maxColumn 110 -i -f .</formatParameters>
    <verifyParameters>--test --maxColumn 110 -f .</verifyParameters>
  </configuration>
  <executions>
    <execution>
      <phase>validate</phase>
      <goals>
        <goal>format</goal>
        <goal>verify</goal>
      </goals>
    </execution>
  </executions>
</plugin>

##Debug If you are finding an strange behaviour with the plugin you can check the exit from scalafmt using -X mvn option which provides Debug log. Also you can remove from your ~/.scalafmt the jar that is copied in order to use the plugin from maven.

##Limitations For now only Linux/Unix is provided. I'm looking to extend it to Windows.