Skip to content

Commit

Permalink
Allow Java source formatting mvn formatter:format (swagger-api#4214)
Browse files Browse the repository at this point in the history
Uses Eclipse formatting tools with a configuration matching Google's style guide (plus our customisations).
  • Loading branch information
nickcmaynard authored and wing328 committed Nov 23, 2016
1 parent ba194ba commit 4c05d5f
Show file tree
Hide file tree
Showing 6 changed files with 406 additions and 0 deletions.
341 changes: 341 additions & 0 deletions eclipse-formatter.xml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions modules/swagger-codegen-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<configuration>
<!-- Point at the eclipse-formatter.xml in the swagger-codegen parent project directory -->
<configFile>${project.basedir}${file.separator}${project.parent.relativePath}${file.separator}eclipse-formatter.xml</configFile>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
10 changes: 10 additions & 0 deletions modules/swagger-codegen-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,15 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<configuration>
<!-- Point at the eclipse-formatter.xml in the swagger-codegen parent project directory -->
<configFile>${project.basedir}${file.separator}${project.parent.relativePath}${file.separator}eclipse-formatter.xml</configFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
8 changes: 8 additions & 0 deletions modules/swagger-codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<configuration>
<!-- Point at the eclipse-formatter.xml in the swagger-codegen parent project directory -->
<configFile>${project.basedir}${file.separator}${project.parent.relativePath}${file.separator}eclipse-formatter.xml</configFile>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
8 changes: 8 additions & 0 deletions modules/swagger-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<configuration>
<!-- Point at the eclipse-formatter.xml in the swagger-codegen parent project directory -->
<configFile>${project.basedir}${file.separator}${project.parent.relativePath}${file.separator}eclipse-formatter.xml</configFile>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down
31 changes: 31 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@
<directory>target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<!-- Uncomment this to format before checkstyle -->
<!-- <executions>
<execution>
<id>format</id>
<phase>validate</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions> -->
<configuration>
<compilerSource>1.7</compilerSource>
<compilerCompliance>1.7</compilerCompliance>
<compilerTargetPlatform>1.7</compilerTargetPlatform>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand All @@ -77,6 +97,8 @@
<phase>validate</phase>
<configuration>
<configLocation>google_checkstyle.xml</configLocation>
<!-- Don't include generated sources a la http://stackoverflow.com/a/30406454 -->
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
Expand Down Expand Up @@ -201,6 +223,15 @@
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>0.5.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
Expand Down

0 comments on commit 4c05d5f

Please sign in to comment.