Skip to content

Commit

Permalink
Develop (#10)
Browse files Browse the repository at this point in the history
* develop: added gitignore

* develop: added *.iml to gitignore

* develop: added pom

* develop: initial version

* develop: added readme

* develop: added tests

* develop: fixed typo

* featture/version_change: version number should match scalafmt version. (#6)

* develop: fixed versioning & NPE.
  • Loading branch information
SimonJPegg authored Jun 15, 2017
1 parent 259dea9 commit 0bd6780
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

A wrapper that allows the use of the [Scalafmt](https://github.com/olafurpg/scalafmt/) formatter in Maven;

Note: The version of the plugin should match the version of scalafmt you wish to use. Current supported versions are 0.6.0 - 0.6.8. All versions are currently compiled against Scala 2.11.8. If you require anything else, please open an issue.
Note: There are muliple versions of the plugin released and the version of the plugin should match the version of scalafmt you wish to use. Current supported versions are 0.6.0 - 0.6.8. For exmaple, to use the latest version of the plugin with the latest version of scala-fmt you should set the version to 0.3_0.6.8 in your pom.
All versions are currently compiled against Scala 2.11.8. If you require anything else, please open an issue.

## Usage

Expand All @@ -14,7 +15,7 @@ passed through to the CLI as is.
<plugin>
<groupId>org.antipathy</groupId>
<artifactId>mvn-scalafmt</artifactId>
<version>${scalafmt.version}</version>
<version>0.3_${scalafmt.version}</version>
<configuration>
<parameters>--diff</parameters> <!-- Additional command line arguments-->
<configLocation>${project.basedir}/path/to/scalafmt.conf</configLocation>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.antipathy</groupId>
<artifactId>mvn-scalafmt</artifactId>
<packaging>maven-plugin</packaging>
<version>${version.scalafmt}</version>
<version>0.3_${version.scalafmt}</version>
<name>Scalafmt Maven Plugin</name>
<description>Maven plugin for ScalaFmt</description>
<url>https://github.com/SimonJPegg/mvn_scalafmt</url>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/antipathy/scalafmtmvn/FormatMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public void execute() throws MojoExecutionException {
if(StringUtils.isEmpty(configLocation)) {
throw new MojoExecutionException("No configuration file specified");
} else {
getLog().info("Formatting with config: " + configLocation + " and options: " + parameters);
getLog().info("Formatting with config: " + configLocation);
if (parameters != null) {
getLog().info(" and options: " + parameters);
}
try {
Formatter.format(configLocation, parameters);
} catch (Exception e) {
Expand Down
5 changes: 4 additions & 1 deletion src/main/scala/org/antipathy/scalafmtmvn/Formatter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ object Formatter {
* @param configLocation the location of a scalafmt.conf file
*/
def format(configLocation: String, parameters: String): Unit = {
val params = parameters.split(" ") ++ Seq("--config", configLocation)
val params : Seq[String] = parameters match {
case null => Seq("--config", configLocation)
case string: String => parameters.split(" ") ++ Seq("--config", configLocation)
}
Cli.getConfig(params.toArray, CliOptions.default) match {
case Some(x) => Cli.run(x)
case None =>
Expand Down

0 comments on commit 0bd6780

Please sign in to comment.