All Projects → sherter → Google Java Format Gradle Plugin

sherter / Google Java Format Gradle Plugin

Licence: mit

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects

Projects that are alternatives of or similar to Google Java Format Gradle Plugin

Craftbook
🔧 Machines, ICs, PLCs, and more!
Stars: ✭ 226 (+53.74%)
Mutual labels:  gradle, plugin
Neoformat
✨ A (Neo)vim plugin for formatting code.
Stars: ✭ 977 (+564.63%)
Mutual labels:  plugin, formatter
Argusapm
Powerful, comprehensive (Android) application performance management platform. 360线上移动性能检测平台
Stars: ✭ 2,452 (+1568.03%)
Mutual labels:  gradle, plugin
Spotless
Keep your code spotless
Stars: ✭ 2,285 (+1454.42%)
Mutual labels:  gradle, formatter
Android Gradle Localization Plugin
Gradle plugin for generating localized string resources
Stars: ✭ 100 (-31.97%)
Mutual labels:  gradle, plugin
Hidden Secrets Gradle Plugin
🔒 Deeply hide secrets on Android
Stars: ✭ 79 (-46.26%)
Mutual labels:  gradle, plugin
Jmh Gradle Plugin
Integrates the JMH benchmarking framework with Gradle
Stars: ✭ 441 (+200%)
Mutual labels:  gradle, plugin
Gradle Maven Plugin
Gradle 5.x Maven Publish Plugin to deploy artifacts
Stars: ✭ 124 (-15.65%)
Mutual labels:  gradle, plugin
Kibana Object Format
A Kibana plugin for displaying objects and arrays of objects.
Stars: ✭ 100 (-31.97%)
Mutual labels:  plugin, formatter
Gradle Util Plugins
Fix for windows gradle long classpath issue. Fixes JavaExec tasks that error out with message "CreateProcess error=206, The filename or extension is too long"
Stars: ✭ 87 (-40.82%)
Mutual labels:  gradle, plugin
Japicmp Gradle Plugin
A Gradle plugin for JApicmp
Stars: ✭ 101 (-31.29%)
Mutual labels:  gradle, plugin
Android Development Aircraft Carrier
打造安卓开发航空母舰,Android Studio 使用集锦
Stars: ✭ 138 (-6.12%)
Mutual labels:  gradle, plugin
Sketch Divine Proportions
Divine proportions toolkit for Sketch
Stars: ✭ 143 (-2.72%)
Mutual labels:  plugin
Gltfforue4
Import glTF 2.0 in Unreal Engine
Stars: ✭ 145 (-1.36%)
Mutual labels:  plugin
Vue Plugin Boilerplate
🔩 Boilerplate for Vue.js plugin
Stars: ✭ 143 (-2.72%)
Mutual labels:  plugin
Live Composer Page Builder
Free page builder plugin for WordPress http://livecomposerplugin.com
Stars: ✭ 143 (-2.72%)
Mutual labels:  plugin
Hyper Search
Search-text plugin for Hyper.js
Stars: ✭ 146 (-0.68%)
Mutual labels:  plugin
Flexget qbittorrent mod
flexget qbittorrent删种、辅种 自动签到 插件
Stars: ✭ 144 (-2.04%)
Mutual labels:  plugin
Androidutillib
🔥 旨在打造一款属于Android开发的强大工具库:内置各种开发必备工具类、Dialog封装、组件重写等
Stars: ✭ 143 (-2.72%)
Mutual labels:  gradle
Serverless Sam
Serverless framework plugin to export AWS SAM templates for a service
Stars: ✭ 143 (-2.72%)
Mutual labels:  plugin

= google-java-format-gradle-plugin :release-version: 0.9 :default-google-java-format-version: 1.8 :snapshot-version: 0.9-SNAPSHOT

A https://github.com/gradle/gradle[Gradle] plugin that utilizes https://github.com/google/google-java-format[google-java-format] to format the Java source files in your Gradle project.

image:https://travis-ci.org/sherter/google-java-format-gradle-plugin.svg?branch=master["Build Status", link="https://travis-ci.org/sherter/google-java-format-gradle-plugin"]

== Quick Start

[source,groovy] [subs="attributes"]

plugins { id 'com.github.sherter.google-java-format' version '{release-version}' }

  • Make sure you have defined a repository that contains version {default-google-java-format-version} of google-java-format

[source,groovy]

repositories { jcenter() // or mavenCentral() }

  • Execute the task googleJavaFormat to format all *.java files in the project

[source,shell]

$ ./gradlew goJF

  • Execute the task verifyGoogleJavaFormat to verify that all *.java files are formatted properly

[source,shell]

$ ./gradlew verGJF

== Extended Usage

  • The plugin adds the extension googleJavaFormat to your project. Adjust the variable toolVersion to use a specific version of google-java-format. You can even define SNAPSHOT versions, but make sure that you have added a repository to the project that contains this version (e.g. mavenLocal()). For plugin version {release-version} this value defaults to {default-google-java-format-version}. On every new release the default value will be updated to the latest version of google-java-format.

[source,groovy] [subs="attributes"]

googleJavaFormat { toolVersion = '1.1-SNAPSHOT' }

  • Choose betweeen 'GOOGLE' (default) and 'AOSP' style by setting the style option:

[source,groovy]

googleJavaFormat { options style: 'AOSP' }

  • The extension object allows you to configure the default inputs for all tasks related to this plugin. It provides the same methods as a https://docs.gradle.org/2.0/javadoc/org/gradle/api/tasks/SourceTask.html[SourceTask] to set these inputs. Initially, a https://docs.gradle.org/current/javadoc/org/gradle/api/file/FileTree.html[FileTree] that contains all *.java files in the project directory (and recursivly all subdirectories, excluding files in a (sub)project's buildDir) is added with one source method call. However, this initial value for the default inputs can be overwritten (using setSource), extended (using additional source calls) and/or further filtered (using include and/or exclude patterns, see https://docs.gradle.org/2.0/javadoc/org/gradle/api/tasks/util/PatternFilterable.html[Ant-style exclude patterns]). The chapter about https://docs.gradle.org/current/userguide/working_with_files.html[Working With Files] in the Gradle user guide might be worth reading.

[source,groovy] [subs="attributes"]

googleJavaFormat { source = sourceSets*.allJava source 'src/special_dir' include '/*.java' exclude '/Template.java' exclude 'src/test/template_' }

  • All tasks are of type https://docs.gradle.org/2.0/javadoc/org/gradle/api/tasks/SourceTask.html[SourceTask] and can be configured accordingly. In addition to the default tasks googleJavaFormat and verifyGoogleJavaFormat you can define custom tasks if you like. The task type VerifyGoogleJavaFormat also implements the interface https://docs.gradle.org/2.0/javadoc/org/gradle/api/tasks/VerificationTask.html[VerificationTask].

[source,groovy]

import com.github.sherter.googlejavaformatgradleplugin.GoogleJavaFormat import com.github.sherter.googlejavaformatgradleplugin.VerifyGoogleJavaFormat

task format(type: GoogleJavaFormat) { source 'src/main' source 'src/test' include '/*.java' exclude '/*Template.java' }

task verifyFormatting(type: VerifyGoogleJavaFormat) { source 'src/main' include '**/*.java' ignoreFailures true }

If you set sources in a task (by calling setSource and/or source), the default inputs from the extension object are not added to the final set of sources to process. However, if you don't modify the sources in the task and only add include and/or exclude patterns, the default inputs are first added and then further filtered according the the patterns.

  • An additional include filter can be applied on the command line at execution time by setting the <taskName>.include system property. All input files that remain after applying the filters in build.gradle also have to match at least one of the patterns in the comma separated list in order to be eventually processed by the task. Note that this only allows you to further reduce the number of processed files. You can not use this to add another include method call to a task. (See https://github.com/sherter/google-java-format-gradle-plugin/blob/master/contrib/pre-commit[contrib/pre-commit] for a useful application of this feature).

[source,shell]

$ ./gradlew verGJF -DverifyGoogleJavaFormat.include="*Foo.java,bar/Baz.java"

== Snapshots On every push to the master branch https://travis-ci.org/[Travis] runs the tests and, if all tests pass, publishes the built artifact to https://oss.sonatype.org/content/repositories/snapshots/[Sonatype's snapshots repository]. Use the following build script snippet for the current snapshot version:

[source,groovy] [subs="attributes"]

buildscript { repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.github.sherter.googlejavaformatgradleplugin:google-java-format-gradle-plugin:{snapshot-version}' } }

apply plugin: 'com.github.sherter.google-java-format'

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].