can only set headerLicense config once (#234)
* can only set headerLicense config once * Update CopyrightHeader.scala
This commit is contained in:
parent
0a8b8a572f
commit
f9eb8aaebf
1 changed files with 5 additions and 15 deletions
|
|
@ -34,20 +34,12 @@ trait CopyrightHeader extends AutoPlugin {
|
|||
headerMappings := headerMappings.value ++ Map(
|
||||
HeaderFileType.scala -> cStyleComment,
|
||||
HeaderFileType.java -> cStyleComment,
|
||||
HeaderFileType.conf -> hashLineComment,
|
||||
HeaderFileType("template") -> cStyleComment)))
|
||||
}
|
||||
|
||||
private def confHeaderMappingSettings: Seq[Def.Setting[_]] =
|
||||
Seq(Compile, Test).flatMap { config =>
|
||||
inConfig(config)(
|
||||
Seq(
|
||||
headerLicense := Some(HeaderLicense.Custom(apacheSpdxHeader)),
|
||||
headerMappings := headerMappings.value ++ Map(
|
||||
HeaderFileType.conf -> hashLineComment)))
|
||||
}
|
||||
|
||||
override def projectSettings: Seq[Def.Setting[_]] =
|
||||
Def.settings(headerMappingSettings, confHeaderMappingSettings, additional)
|
||||
Def.settings(headerMappingSettings, additional)
|
||||
|
||||
def additional: Seq[Def.Setting[_]] =
|
||||
Def.settings(Compile / compile := {
|
||||
|
|
@ -59,9 +51,6 @@ trait CopyrightHeader extends AutoPlugin {
|
|||
(Test / compile).value
|
||||
})
|
||||
|
||||
def headerFor(year: String): String =
|
||||
s"Copyright (C) $year Lightbend Inc. <https://www.lightbend.com>"
|
||||
|
||||
def apacheHeader: String =
|
||||
"""Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|license agreements; and to You under the Apache License, version 2.0:
|
||||
|
|
@ -92,14 +81,15 @@ trait CopyrightHeader extends AutoPlugin {
|
|||
|
||||
val hashLineComment = HeaderCommentStyle.hashLineComment.copy(commentCreator = new CommentCreator() {
|
||||
|
||||
// deliberately hardcode use of apacheSpdxHeader and ignore input text
|
||||
override def apply(text: String, existingText: Option[String]): String = {
|
||||
val formatted = existingText match {
|
||||
case Some(currentText) if isApacheCopyrighted(currentText) =>
|
||||
currentText
|
||||
case Some(currentText) =>
|
||||
HeaderCommentStyle.hashLineComment.commentCreator(text, existingText) + NewLine * 2 + currentText
|
||||
HeaderCommentStyle.hashLineComment.commentCreator(apacheSpdxHeader, existingText) + NewLine * 2 + currentText
|
||||
case None =>
|
||||
HeaderCommentStyle.hashLineComment.commentCreator(text, existingText)
|
||||
HeaderCommentStyle.hashLineComment.commentCreator(apacheSpdxHeader, existingText)
|
||||
}
|
||||
formatted.trim
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue