lewisjkl / header   0.1.0

Apache License 2.0 GitHub

Header automation and linting with a mill plugin :tada:

Scala versions: 3.x

Header

Utilities for checking and updating headers in files.

A big thanks to sbt-header which this project is based on.

Mill - Basic Usage

> .mill __.headerCheck
> mill __.headerCreate

In build.sc file:

//| mvnDeps: ["com.lewisjkl::header-mill-plugin::0.1.0"] 
import header._

Apache 2

object core extends HeaderModule {
  override def license: HeaderLicense = HeaderLicense.Apache2("2023", "lewisjkl")
}

MIT

object core extends HeaderModule {
  override def license: HeaderLicense = HeaderLicense.MIT("2023", "lewisjkl")
}

Custom

object core extends HeaderModule {
  override def license: HeaderLicense = HeaderLicense.Custom(
  """|The contents of this file is free and unencumbered software released into the
     |public domain. For more information, please refer to <http://unlicense.org/>""".stripMargin
  )
}

Mill Customization

import header._

object core extends HeaderModule {
  override def license: HeaderLicense = HeaderLicense.Apache2("2023", "lewisjkl")

  // defaults to List("scala")
  override def includeFileExtensions: List[String] = List("scala", "java")

  // if you want more control, you can use the following instead of `includeFileExtensions`
  // This shows the default implementation, but you can make it whatever you would like.
  override def skipFilePredicate: os.Path => Boolean = path => {
    os.isFile(path) && !includeFileExtensions.exists(ext =>
      path.segments.toList.last.endsWith(s".$ext")
    )
  }

  // defaults to this.moduleDir, change this to change where the header checking/creation starts
  // looking for files
  override def headerRootPath: os.Path = this.moduleDir
}