Skip to content

kitbellew/mvn_scalafmt

 
 

Repository files navigation

licenseimg Codacy Build Status

releasebadge Maven

Synopsis

A wrapper that allows the use of the Scalafmt formatter in Maven.

Usage

Add the following snippet to your pom.

Note: version.scala.binary refers to major releases of scala ie. 2.11 or 2.12 (scalafmt-dynamic doesn't currently support 2.13).

<plugin>
    <groupId>org.antipathy</groupId>
    <artifactId>mvn-scalafmt_${version.scala.binary}</artifactId>
    <version>1.0.1</version>
    <configuration>
        <configLocation>${project.basedir}/.scalafmt.conf</configLocation> <!-- path to config -->
        <skipTestSources>false</skipTestSources> <!-- (Optional) skip formatting test sources -->
        <skipSources>false</skipSources> <!-- (Optional) skip formatting main sources -->
        <respectVersion>false</respectVersion> <!-- (Optional) fail if no version set in scalafmt.conf -->
        <sourceDirectories> <!-- (Optional) Paths to source-directories. Overrides ${project.build.sourceDirectory} -->
          <param>${project.basedir}/src/main/scala</param>
        </sourceDirectories>
        <testSourceDirectories> <!-- (Optional) Paths to test-source-directories. Overrides ${project.build.testSourceDirectory} -->
          <param>${project.basedir}/src/test/scala</param>
        </testSourceDirectories>
        <validateOnly>false</validateOnly> <!-- check formatting without changing files -->
    </configuration>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>format</goal>
            </goals>
        </execution>
    </executions>
</plugin>

configLocation Can either be a local path (e.g. ${project.basedir}/.scalafmt.conf) or a HTTP url (e.g https://raw.githubusercontent.com/jozic/scalafmt-config/master/.scalafmt.conf)

make sure you have set a version in your scalafmt.conf

version = "1.5.1"

About

Scalafmt plugin for maven

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 91.5%
  • Java 8.5%