• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

aalmiray/stats-gradle-plugin: A Gradle plugin for counting lines of code in the ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

aalmiray/stats-gradle-plugin

开源软件地址(OpenSource Url):

https://github.com/aalmiray/stats-gradle-plugin

开源编程语言(OpenSource Language):

Groovy 95.4%

开源软件介绍(OpenSource Introduction):

Stats Gradle Plugin

Build Status Coverage Status Apache License 2 download donations Patreon orange

Stats Gradle Plugin

A Gradle plugin for counting lines of code in the same fashion as the Grails stats command.

Requirements

  • Gradle 2.x and JDK7.

Usage

The plugin is available from Bintray’s JCenter. The latest release is 0.2.2. You can use it as follows

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.kordamp.gradle:stats-gradle-plugin:0.2.2'
    }
}

apply plugin: 'org.kordamp.gradle.stats'

The plugin adds a new task named stats. This task is responsible for computing lines of code. The default configuration is good enough to work with standard Java or Groovy projects without additional setup. Invoking this task in a plain Java project yields something like the following output

$ gradle stats
:stats

    +----------------------+-------+-------+
    | Name                 | Files |   LOC |
    +----------------------+-------+-------+
    | Java Sources         |     1 |     5 |
    +----------------------+-------+-------+
    | Totals               |     1 |     5 |
    +----------------------+-------+-------+

It’s possible to generate an aggregate report when multiple projects are configured. Simply add the following to the root project

task aggregateStatsReport(type: org.kordamp.gradle.stats.AggregateStatsReportTask) {}

You may define a value for the projects property (a collection of project names) if you want desire to limit the number of projects to be queried for stats. The default setting is to query all subprojects. Note that the stats task must have been called before the aggregate task, such as

$ gradle stats aggregateStatsReport

Configuration

The following properties can be configured for the stats task

formats

List of output formats. Valid values are xml, html and txt.

reportDir

Directory where output reports should be placed. default value is project.file("${project.buildDir}/reports/stats")

counters

a Map of additional org.kordamp.gradle.stats.Counter implementations, keyed by extension.

paths

Maps of additional source paths that contain sources to be counted.

The following configuration may be used in a Griffon project for example

stats {
    formats = ['xml', 'html', 'txt']
    paths = [
        model:      [name: 'Models',      path: 'griffon-app/models'],
        view:       [name: 'Views',       path: 'griffon-app/views'],
        controller: [name: 'Controllers', path: 'griffon-app/controllers'],
        service:    [name: 'Services',    path: 'griffon-app/services'],
        config:     [name: 'Config',      path: 'griffon-app/conf'],
        lifecycle:  [name: 'Lifecycle',   path: 'griffon-app/lifecycle']
    ]
}

Which may make the stats task output something similar to

    +----------------------+-------+-------+
    | Name                 | Files |   LOC |
    +----------------------+-------+-------+
    | Groovy Sources       |     4 |    28 |
    | Java Sources         |     1 |     2 |
    | Groovy Test Sources  |     1 |    16 |
    | Models               |     1 |     8 |
    | Views                |     1 |    24 |
    | Controllers          |     1 |    10 |
    | Config               |     1 |    12 |
    | Lifecycle            |     1 |    16 |
    +----------------------+-------+-------+
    | Totals               |    11 |   116 |
    +----------------------+-------+-------+

You may restrict a path to match an specific file type, such as java or any other supported file extension, for example

stats {
    formats = ['xml', 'html', 'txt']
    paths = [
        foo: [name: 'Foos', path: 'src/foo', extension: 'foo']
    ]
}

Supported Extensions

  • java

  • groovy

  • scala

  • kt (Kotlin)

  • js

  • css

  • scss (SASS)

  • xml

  • html

  • fxml (JavaFX FXML)

  • properties

  • sql

  • yaml

Supported Paths

All project SourceSets will be queried when calculating stats, however the following paths have special treatment for reporting their names:

  • src/test

  • src/integration-test

  • src/functional-test




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap