GithubHelp home page GithubHelp logo

howyp / sbt-header Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sbt/sbt-header

0.0 2.0 0.0 116 KB

sbt-header is an sbt plugin for creating file headers, e.g. copyright headers

License: Apache License 2.0

Scala 100.00%

sbt-header's Introduction

sbt-header

Join the chat at https://gitter.im/sbt/sbt-header

sbt-header is an sbt plugin for creating or updating file headers, e.g. copyright headers.

Requirements

  • Java 7 or higher
  • sbt 0.13.8 or higher

Configuration

In order to add the sbt-header plugin to your build, add the following line to project/plugins.sbt:

addSbtPlugin("de.heikoseeberger" % "sbt-header" % "1.4.0")

If your build uses an auto plugin for common settings, make sure to add HeaderPlugin to requires:

import de.heikoseeberger.sbtheader.HeaderPlugin

object Build extends AutoPlugin {
  override def requires = ... && HeaderPlugin
  ...
}

You have to define which source or resource files should be considered by sbt-header and if so, how the headers should look like. sbt-header uses a mapping from file extension to header pattern and text for that purpose, specified with the headers setting. Here's an example:

import de.heikoseeberger.sbtheader.HeaderPattern

headers := Map(
  "scala" -> (
    HeaderPattern.cStyleBlockComment,
    """|/*
       | * Copyright 2015 Heiko Seeberger
       | *
       | * Licensed under the Apache License, Version 2.0 (the "License");
       | * you may not use this file except in compliance with the License.
       | * You may obtain a copy of the License at
       | *
       | *    http://www.apache.org/licenses/LICENSE-2.0
       | *
       | * Unless required by applicable law or agreed to in writing, software
       | * distributed under the License is distributed on an "AS IS" BASIS,
       | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       | * See the License for the specific language governing permissions and
       | * limitations under the License.
       | */
       |
       |""".stripMargin
  )
)

The Apache 2.0 license has been pre-canned in Apache2_0 and can be added as follows:

import de.heikoseeberger.sbtheader.license.Apache2_0

headers := Map(
  "scala" -> Apache2_0("2015", "Heiko Seeberger")
)

Notice that for the header pattern you have to provide a Regex which extracts the header and the body for a given file, i.e. one with two capturing groups. HeaderPattern defines two widely used patterns:

  • cStyleBlockComment, e.g. for Scala and Java
  • hashLineComment, e.g. for Bash, Pyhon and HOCON

By the way, first lines starting with shebang are not touched by sbt-header.

By default sbt-header takes Compile and Test configurations into account. If you need more, just add them:

HeaderPlugin.settingsFor(It, MultiJvm)

Usage

In order to create or update file headers, execute the createHeaders task:

> createHeaders
[info] Headers created for 2 files:
[info]   /Users/heiko/projects/sbt-header/sbt-header-test/test.scala
[info]   /Users/heiko/projects/sbt-header/sbt-header-test/test2.scala

Automation

If you want to automate header creation/update on compile, enable the AutomateHeaderPlugin:

lazy val myProject = project
  .in(file("."))
  .enablePlugins(AutomateHeaderPlugin)

By default automation takes Compile and Test configurations into account. If you need more, just add them:

AutomateHeaderPlugin.automateFor(It, MultiJvm)

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.

License

This code is open source software licensed under the Apache 2.0 License.

sbt-header's People

Contributors

gitter-badger avatar hseeberger avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.