Enable build and format validation
Validate the formatting of Java files using GJF 1.7.
Output with formatting issues is provided as automated
commends to the code under review.
Change-Id: I2f31723c394c645b627ddf13b5f56e2fae96eb71
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..a090baf
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,31 @@
+pipeline {
+ agent { label 'bazel-debian' }
+ stages {
+ stage('GJF') {
+ steps {
+ sh 'mvn process-sources'
+ script {
+ def formatOut = sh (script: 'git status --porcelain', returnStdout: true)
+ if (formatOut.trim()) {
+ def files = formatOut.split('\n').collect { it.split(' ').last() }
+ files.each { gerritComment path:it, message: 'Needs reformatting with GJF' }
+ gerritReview labels: [Formatting: -1]
+ } else {
+ gerritReview labels: [Formatting: 1]
+ }
+ }
+ }
+ }
+ stage('build') {
+ steps {
+ gerritReview labels: [Verified: 0], message: "Build started: ${env.BUILD_URL}"
+ sh 'mvn test'
+ }
+ }
+ }
+ post {
+ success { gerritReview labels: [Verified: 1] }
+ unstable { gerritReview labels: [Verified: 0], message: "Build is unstable: ${env.BUILD_URL}" }
+ failure { gerritReview labels: [Verified: -1], message: "Build failed: ${env.BUILD_URL}" }
+ }
+}
diff --git a/pom.xml b/pom.xml
index 9b8a945..98cf971 100644
--- a/pom.xml
+++ b/pom.xml
@@ -124,6 +124,30 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>com.theoryinpractise</groupId>
+ <artifactId>googleformatter-maven-plugin</artifactId>
+ <version>1.7.3</version>
+ <executions>
+ <execution>
+ <id>reformat-sources</id>
+ <configuration>
+ <includeStale>false</includeStale>
+ <style>GOOGLE</style>
+ <formatMain>true</formatMain>
+ <formatTest>true</formatTest>
+ <filterModified>false</filterModified>
+ <skip>false</skip>
+ <fixImports>true</fixImports>
+ <maxLineLength>100</maxLineLength>
+ </configuration>
+ <goals>
+ <goal>format</goal>
+ </goals>
+ <phase>process-sources</phase>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>