Reputation: 1962
Google-java-format-gradle-plugin integrates with Gradle, but how can I run it automatically as part of the normal build?
Upvotes: 1
Views: 1673
Reputation: 588
Sherter gradle plugin is automatically integrated to "gradle build". When you run it, it will run "gradle verifyGoogleJavaFormat". In case of violations, the build will fail.
We are using it on jenkins and it works. You will only need dependency to build.gradle file:
compile group: 'com.github.sherter.google-java-format', name: 'com.github.sherter.google-java-format.gradle.plugin', version: '0.8', ext: 'pom'
And also add plugin:
id 'com.github.sherter.google-java-format' version '0.8'
Then just run "gradle build" and you can see in the console, that verifyGoogleJavaFormat was executed.
Upvotes: 1
Reputation: 1380
DependsOn plugin's task that you need from a task that relates to a normal build, for example, you can use preBuild
task:
tasks.findByName("preBuild").dependsOn(YOUR_TASK_FROM_PLUGIN)
or shorter
preBuild.dependsOn(YOUR_TASK_FROM_PLUGIN)
Also you can choose another task instead of preBuild
.
Upvotes: 0