-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial version of Spotless Maven plugin #188
Commits on Jan 14, 2018
-
Initial version of Spotless Maven plugin
Commit introduces a prototype of the Maven plugin which is able to apply Eclipse formatter step to all java files in the project. It only takes a single parameter - 'eclipseFormatFile' which is a path to the formatter configuration. Maven plugin is build and packaged using Maven which is executed from the Gradle build script via Exec plugin. This seems to be the simplest way to get a JAR with "maven-plugin" packaging. Gradle does not have a native plugin to do this. This change just adds a bare minimum to verify the approach.
Configuration menu - View commit details
-
Copy full SHA for 5ff5581 - Browse repository at this point
Copy the full SHA 5ff5581View commit details
Commits on Jan 17, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 9956473 - Browse repository at this point
Copy the full SHA 9956473View commit details -
Improved config handling in maven plugin
Exposed `encoding` and `lineEndings` in the plugin xml configuration. Renamed `eclipseFormatFile` to `eclipseConfigFile` and moved it inside the `<java>` tag. Maven plugins can handle nested configs using Plexus dependency injection and POJO objects. Thus introduced a dedicated class for all java related configuration called `Java`. Plugin xml configuration can now look like: ``` <plugin> <groupId>com.diffplug.spotless</groupId> <artifactId>spotless-maven-plugin</artifactId> <version>${spotless.version}</version> <configuration> <encoding>UTF-8</encoding> <lineEndings>UNIX</lineEndings> <java> <eclipseConfigFile>${basedir}/eclipse-fmt.xml</eclipseConfigFile> </java> </configuration> </plugin> ``` Extracted an abstract `AbstractSpotlessMojo` to hold all injected dependencies. It can be potentially used in future to implement the `check` goal. Changed name of `SpotlessMojo` from "spotless" to "apply" so that it can be invoked with `mvn spotless:apply`.
Configuration menu - View commit details
-
Copy full SHA for c219ef1 - Browse repository at this point
Copy the full SHA c219ef1View commit details -
Removed dependency on maven-core
Injected `MavenProject` is now replaced by injection of multiple primitive values, like `project.basedir`.
Configuration menu - View commit details
-
Copy full SHA for a5a6cc9 - Browse repository at this point
Copy the full SHA a5a6cc9View commit details -
Simplified maven plugin build process
Removed shading & local repository for `lib` and `lib-extra`. Instead made plugin directly depend on stable version denoted by `project.stableLib`. Made all maven plugin API dependencies provided and their versions injected by the Gradle build script.
Configuration menu - View commit details
-
Copy full SHA for 1d63aa2 - Browse repository at this point
Copy the full SHA 1d63aa2View commit details -
Configuration menu - View commit details
-
Copy full SHA for af677ab - Browse repository at this point
Copy the full SHA af677abView commit details
Commits on Jan 19, 2018
-
Added "aspiring" docs for the maven plugin.
These don't match the current implementation exactly, but I think they're close. I don't know much about maven, lets get the docs right, and then build to the docs.
Configuration menu - View commit details
-
Copy full SHA for b059d53 - Browse repository at this point
Copy the full SHA b059d53View commit details -
Configuration menu - View commit details
-
Copy full SHA for c0a2fa6 - Browse repository at this point
Copy the full SHA c0a2fa6View commit details -
Configuration menu - View commit details
-
Copy full SHA for a431b71 - Browse repository at this point
Copy the full SHA a431b71View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3639269 - Browse repository at this point
Copy the full SHA 3639269View commit details -
Configuration menu - View commit details
-
Copy full SHA for 240f87c - Browse repository at this point
Copy the full SHA 240f87cView commit details -
Made maven plugin build use template for pom
Gradle build script will now use Mustache template to create pom.xml with needed versions. This should be more reliable and future-proof than previously used `String#replace()`.
Configuration menu - View commit details
-
Copy full SHA for 8570064 - Browse repository at this point
Copy the full SHA 8570064View commit details -
Configuration menu - View commit details
-
Copy full SHA for 75f0204 - Browse repository at this point
Copy the full SHA 75f0204View commit details
Commits on Jan 21, 2018
-
Improve maven plugin configuration
Restructured code to better support addition of new formatter steps and formatters. Spotless mojo now accepts java configuration with list of steps. It is also possible to specify global encoding, line endings and override them for java. New `pom.xml` config looks like: ``` <configuration> <encoding>UTF-8</encoding> <lineEndings>UNIX</lineEndings> <java> <encoding>US-ASCII</encoding> <lineEndings>WINDOWS</lineEndings> <steps> <eclipse> <file>${basedir}/build/eclipse-format.xml</file> <version>4.7.1</version> </eclipse> </steps> </java> </configuration> ```
Configuration menu - View commit details
-
Copy full SHA for 40da7f5 - Browse repository at this point
Copy the full SHA 40da7f5View commit details -
Changed maven artifactId to spotless-maven-plugin, but kept project f…
…older location as 'plugin-maven'.
Configuration menu - View commit details
-
Copy full SHA for 3696310 - Browse repository at this point
Copy the full SHA 3696310View commit details -
Configuration menu - View commit details
-
Copy full SHA for 49c2753 - Browse repository at this point
Copy the full SHA 49c2753View commit details -
Configuration menu - View commit details
-
Copy full SHA for 35da59a - Browse repository at this point
Copy the full SHA 35da59aView commit details -
Configuration menu - View commit details
-
Copy full SHA for fd38755 - Browse repository at this point
Copy the full SHA fd38755View commit details
Commits on Jan 22, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 3864178 - Browse repository at this point
Copy the full SHA 3864178View commit details -
Made maven plugin ITs runnable
Gradle build script creates builds spotless maven plugin by shelling out to maven. It then installs the plugin JAR into a local maven repo that's later used for tests. Task "test" depends on all these steps. Maven integration tests generate pom.xml based on a template. This pom references the previously created local maven repo to locate spotless plugin. Tests then invoke maven via Process API and compare formatter with unformatted files.
Configuration menu - View commit details
-
Copy full SHA for d54b183 - Browse repository at this point
Copy the full SHA d54b183View commit details -
Configuration menu - View commit details
-
Copy full SHA for ddbf0eb - Browse repository at this point
Copy the full SHA ddbf0ebView commit details -
Include stdout and stderr in maven plugin test failures
Make test task print assertion failures.
Configuration menu - View commit details
-
Copy full SHA for 4754a8f - Browse repository at this point
Copy the full SHA 4754a8fView commit details -
Assert on exit code, not stderr
In maven plugin integration tests. Previous assertion on string obtained from stderr failed on CI. There build agents print "Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m" to stderr when java is launched.
Configuration menu - View commit details
-
Copy full SHA for 88bcd19 - Browse repository at this point
Copy the full SHA 88bcd19View commit details
Commits on Jan 23, 2018
-
1
Configuration menu - View commit details
-
Copy full SHA for c84becf - Browse repository at this point
Copy the full SHA c84becfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 012b118 - Browse repository at this point
Copy the full SHA 012b118View commit details -
Made maven plugin use all dependencies from local repo
So that it is able to depend on snapshot version of lib and lib-extra. All compile dependencies with transitives are now installed into local maven repo. This repo is used both for building and testing the plugin.
Configuration menu - View commit details
-
Copy full SHA for 0c01e64 - Browse repository at this point
Copy the full SHA 0c01e64View commit details -
Configuration menu - View commit details
-
Copy full SHA for c43ed45 - Browse repository at this point
Copy the full SHA c43ed45View commit details
Commits on Jan 24, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 66bb67e - Browse repository at this point
Copy the full SHA 66bb67eView commit details -
Fix maven provisioner to resolve transitive dependencies
Previously it only resolved given coordinates to a single artifact.
Configuration menu - View commit details
-
Copy full SHA for 31d5357 - Browse repository at this point
Copy the full SHA 31d5357View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4b032eb - Browse repository at this point
Copy the full SHA 4b032ebView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4cf839a - Browse repository at this point
Copy the full SHA 4cf839aView commit details -
To make goal `spotless:check` accessible. Moved all functionality common for "apply" and "check" into `AbstractSpotlessMojo`. Now command `mvn spotless:check` will result in all formatting violations being printed and build being failed.
Configuration menu - View commit details
-
Copy full SHA for 622d2df - Browse repository at this point
Copy the full SHA 622d2dfView commit details
Commits on Jan 27, 2018
-
Configuration menu - View commit details
-
Copy full SHA for e759a0b - Browse repository at this point
Copy the full SHA e759a0bView commit details -
The local dependencies repo now contains only our local deps, and it …
…has up-to-date checking.
Configuration menu - View commit details
-
Copy full SHA for 0185af6 - Browse repository at this point
Copy the full SHA 0185af6View commit details -
Forced buildMavenPlugin to act like the standard jar task, so that pu…
…blishing works automatically.
Configuration menu - View commit details
-
Copy full SHA for 0dba10c - Browse repository at this point
Copy the full SHA 0dba10cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9bb5bbc - Browse repository at this point
Copy the full SHA 9bb5bbcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3189d7d - Browse repository at this point
Copy the full SHA 3189d7dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6568440 - Browse repository at this point
Copy the full SHA 6568440View commit details -
Configuration menu - View commit details
-
Copy full SHA for 21f8d00 - Browse repository at this point
Copy the full SHA 21f8d00View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8ebdbfc - Browse repository at this point
Copy the full SHA 8ebdbfcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 24f7096 - Browse repository at this point
Copy the full SHA 24f7096View commit details -
Refactor formatter and step configuration
Split configuration into two - one for `FormatterFactory` and other for `FormatterStepFactory`.
Configuration menu - View commit details
-
Copy full SHA for 5e9fce6 - Browse repository at this point
Copy the full SHA 5e9fce6View commit details -
Allow multiple file extension for formatters
Previously each `FormatterFactory` had to return only a single extension. This worked fine for Java but does not hold for other languages, like Scala.
Configuration menu - View commit details
-
Copy full SHA for d95f76d - Browse repository at this point
Copy the full SHA d95f76dView commit details
Commits on Jan 28, 2018
-
Made spotless mojo scan for files starting at basedir
Maven by default allows only a single compile root dir. Plugins can add more or override at runtime but by default it's only `src/main/java`. When single plugin goal, like `spotless:check` is executed this single source root is what it can access. Previously spotless mojo scanned only compile source roots. This made it only see java files. It wasn't able to see for example scala files that usually live at `src/main/scala`. This happened because `src/main/scala` source root can be added by other plugins (like scala-maven-plugin http://davidb.github.io/scala-maven-plugin/add-source-mojo.html) and such plugins are not executed when single spotless mojo is invoked. This commit makes spotless mojo start scanning files from project root directory. It will only skip `target` directory right now.
Configuration menu - View commit details
-
Copy full SHA for 4f2952c - Browse repository at this point
Copy the full SHA 4f2952cView commit details -
It allows scalafmt version and configuration file to be configured.
Configuration menu - View commit details
-
Copy full SHA for 1d82ba9 - Browse repository at this point
Copy the full SHA 1d82ba9View commit details -
They were previously not executed because of missing `@Test` annotation. When enabled, they failed because maven was not able to find `LicenseHeader` implementation. Looks like Maven is only able to locate classes for injection when they live in the same package or in subpackages of the current package. For example step `Java` lives in package `com.diffplug.spotless.maven.java` and to be able to inject implementation of `licenseHeader` step it should also live in `com.diffplug.spotless.maven.java` or any of it's subpackages, like `com.diffplug.spotless.maven.java.hello`. This commit makes generic license header an abstract class and adds implementor for Java in the correct package. Such implementations are now also responsible for default delimiter. This feels cleaner than putting delimiter in `FormatterFactory` implementations.
Configuration menu - View commit details
-
Copy full SHA for 4b34991 - Browse repository at this point
Copy the full SHA 4b34991View commit details -
Mark check and apply MOJOs as thread safe
They do not keep any internal state. Every field is injected by Maven.
Configuration menu - View commit details
-
Copy full SHA for 7db3759 - Browse repository at this point
Copy the full SHA 7db3759View commit details
Commits on Jan 30, 2018
-
Removed need for "<steps>" config element
And need to restructure packages. Turns out Maven (underlying Eclipse sisu container) requires injected classes be in the same package as the class that's being configured. That's only in case of direct field injection. With setter/adder is class can be in any package because it's `Class` will be determined based on the type of setter/adder parameter. It is also guaraneteed that setters and adders will be invoked in the order of corresponding xml elements. This removes the need for `<steps>` and makes it possible to place classes in nice packages. One drawback is that explicit adder methods are required. At the same time they provide an ability to explicitly define which steps are supported for the given formatter. This makes error messages a bit prettier when for example "googleJavaFormat" is configured for Scala. Eclipse sisu doc for adder/setter: https://www.eclipse.org/sisu/docs/api/org.eclipse.sisu.plexus/reference/org/eclipse/sisu/plexus/CompositeBeanHelper.html
Configuration menu - View commit details
-
Copy full SHA for d8258bd - Browse repository at this point
Copy the full SHA d8258bdView commit details -
Added property to skip 'spotless:check'
Property is `spotless.check.skip` and takes a boolean value. Can either be specified in POM `<properties>` section or in command like like `-Dspotless.check.skip=true`.
Configuration menu - View commit details
-
Copy full SHA for a8de57d - Browse repository at this point
Copy the full SHA a8de57dView commit details -
Added javadoc to check and apply MOJOs
It will be shown as MOJO description.
Configuration menu - View commit details
-
Copy full SHA for 3ca2bf7 - Browse repository at this point
Copy the full SHA 3ca2bf7View commit details -
Bind 'spotless:check' to verify phase by default
Which makes `<phase>verify</phase>` unneeded in plugin execution configuration. Example to bing 'check' to verify phase: ``` <plugin> <groupId>com.diffplug.spotless</groupId> <artifactId>spotless-maven-plugin</artifactId> <version>${spotless.version}</version> <executions> <execution> <id>check</id> <!-- <phase>verify</phase> --> <!-- no need for this line --> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> ```
Configuration menu - View commit details
-
Copy full SHA for 807291e - Browse repository at this point
Copy the full SHA 807291eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 48cb4c9 - Browse repository at this point
Copy the full SHA 48cb4c9View commit details
Commits on Jan 31, 2018
-
Use mvnw to build maven plugin
Maven wrapper makes it easy to control version of maven and it's installation. Version can be changed in `.mvn/wrapper/maven-wrapper.properties` file.
Configuration menu - View commit details
-
Copy full SHA for 08f90d2 - Browse repository at this point
Copy the full SHA 08f90d2View commit details
Commits on Feb 1, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 5ccbd09 - Browse repository at this point
Copy the full SHA 5ccbd09View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7df6191 - Browse repository at this point
Copy the full SHA 7df6191View commit details -
Moved mvnw out of src/main/resources into the project route.
Everything in src/main/resources will get shipped to users inside the jar. No need to ship mvnw. Also appears that some of the plugin installation tasks might be failing on the buildserver, perhaps because the install tasks didn't depend on copyMvnw.
Configuration menu - View commit details
-
Copy full SHA for a676bc4 - Browse repository at this point
Copy the full SHA a676bc4View commit details -
Revert "Moved mvnw out of src/main/resources into the project route."
This reverts commit a676bc4.
Configuration menu - View commit details
-
Copy full SHA for d4cddc0 - Browse repository at this point
Copy the full SHA d4cddc0View commit details -
Configuration menu - View commit details
-
Copy full SHA for b9a4fa4 - Browse repository at this point
Copy the full SHA b9a4fa4View commit details -
Configuration menu - View commit details
-
Copy full SHA for bafc30c - Browse repository at this point
Copy the full SHA bafc30cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9d3ea05 - Browse repository at this point
Copy the full SHA 9d3ea05View commit details -
Configuration menu - View commit details
-
Copy full SHA for e438881 - Browse repository at this point
Copy the full SHA e438881View commit details
Commits on Feb 2, 2018
-
Configuration menu - View commit details
-
Copy full SHA for f8bf47d - Browse repository at this point
Copy the full SHA f8bf47dView commit details -
Configuration menu - View commit details
-
Copy full SHA for d2170fe - Browse repository at this point
Copy the full SHA d2170feView commit details -
Configuration menu - View commit details
-
Copy full SHA for da36b36 - Browse repository at this point
Copy the full SHA da36b36View commit details -
Configuration menu - View commit details
-
Copy full SHA for 07b6d68 - Browse repository at this point
Copy the full SHA 07b6d68View commit details -
Configuration menu - View commit details
-
Copy full SHA for 243035e - Browse repository at this point
Copy the full SHA 243035eView commit details -
Configuration menu - View commit details
-
Copy full SHA for ea6ebb5 - Browse repository at this point
Copy the full SHA ea6ebb5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6d660c6 - Browse repository at this point
Copy the full SHA 6d660c6View commit details -
Configuration menu - View commit details
-
Copy full SHA for aef8b32 - Browse repository at this point
Copy the full SHA aef8b32View commit details -
Configuration menu - View commit details
-
Copy full SHA for 21f163b - Browse repository at this point
Copy the full SHA 21f163bView commit details
Commits on Feb 4, 2018
-
Configuration menu - View commit details
-
Copy full SHA for e7cea18 - Browse repository at this point
Copy the full SHA e7cea18View commit details -
Configuration menu - View commit details
-
Copy full SHA for da77c39 - Browse repository at this point
Copy the full SHA da77c39View commit details -
Configuration menu - View commit details
-
Copy full SHA for 34ff0e9 - Browse repository at this point
Copy the full SHA 34ff0e9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7de4e1a - Browse repository at this point
Copy the full SHA 7de4e1aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8e77cf7 - Browse repository at this point
Copy the full SHA 8e77cf7View commit details -
Configuration menu - View commit details
-
Copy full SHA for fcebff7 - Browse repository at this point
Copy the full SHA fcebff7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 53d8013 - Browse repository at this point
Copy the full SHA 53d8013View commit details -
Configuration menu - View commit details
-
Copy full SHA for d52a448 - Browse repository at this point
Copy the full SHA d52a448View commit details -
Removed repository declaration from POMs
It is not needed because maven plugin and tests specify custom local repository via `-Dmaven.repo.local` system property.
Configuration menu - View commit details
-
Copy full SHA for 079e9a2 - Browse repository at this point
Copy the full SHA 079e9a2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3fdc785 - Browse repository at this point
Copy the full SHA 3fdc785View commit details
Commits on Feb 5, 2018
-
Cache the localMavenRepository on Travis, but delete the com.diffplug…
….spotless group before caching.
Configuration menu - View commit details
-
Copy full SHA for 95c7fc9 - Browse repository at this point
Copy the full SHA 95c7fc9View commit details -
Configuration menu - View commit details
-
Copy full SHA for bd8a3b9 - Browse repository at this point
Copy the full SHA bd8a3b9View commit details -
Configuration menu - View commit details
-
Copy full SHA for d215905 - Browse repository at this point
Copy the full SHA d215905View commit details -
Added
~/.m2
as a cached directory, because stuff gets downloaded fo……r maven-install-plugin and the wrapper.
Configuration menu - View commit details
-
Copy full SHA for 2345cbd - Browse repository at this point
Copy the full SHA 2345cbdView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0f9ff8e - Browse repository at this point
Copy the full SHA 0f9ff8eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9cee266 - Browse repository at this point
Copy the full SHA 9cee266View commit details
Commits on Feb 10, 2018
-
Allow custom file includes and excludes
This commit makes it possible to configure includes and excludes for paths/files with Ant style pattern in configuration groups (currently Java and Scala). It also changes the default source roots for scanning. Default policy for scanning used to recursively start from the `basedir` and include files with needed extensions, like "*.java" or "*.scala". This worked fine for simple maven projects but resulted in a lot of extra work for multi-module maven projects. Same files had to be scanned more than once during parent and then child module scanning. Now scanning will use most common source roots for supported languages. They are "scr/main/java/**/*.java", "scr/test/java/**/*.java" for Java and "scr/main/scala/**/*.scala", "scr/main/scala/**/*.sc", "scr/test/scala/**/*.scala", "scr/test/scala/**/*.sc" for Scala. So only these common source roots will be scanned by default. Mentioned patters form default includes. Default excludes are empty, except output directory (usually "target"), temporary files and VCS files are always skipped. It is possible to override includes and add excludes. This can be done like this: ``` <java> <includes> <!-- include all java files in "java" folders under "src" --> <include>src/**/java/**/*.java</include> <!-- include all java files in "java" folders under "other" --> <include>other/java/**/*.java</include> </includes> <excludes> <!-- exclude examples from formatting --> <exclude>src/test/java/**/*Example.java</exclude> </excludes> </java> ``` Similar configuration is possible for Scala. Custom includes completely override default includes. Default excludes of output directory, temporary and VCS files can't be overridden.
Configuration menu - View commit details
-
Copy full SHA for 15e65a0 - Browse repository at this point
Copy the full SHA 15e65a0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 740317c - Browse repository at this point
Copy the full SHA 740317cView commit details -
Configuration menu - View commit details
-
Copy full SHA for a154f59 - Browse repository at this point
Copy the full SHA a154f59View commit details -
Configuration menu - View commit details
-
Copy full SHA for 49987d7 - Browse repository at this point
Copy the full SHA 49987d7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 81477a6 - Browse repository at this point
Copy the full SHA 81477a6View commit details
Commits on Feb 11, 2018
-
Fixed LicenseHeader when configured globally
Generic formatting steps, like LicenseHeader can be defined both globally and inside language configs. Example: ``` <configuration> <!-- global license header config --> <licenseHeader>...</licenseHeader> <java> <!-- overridden license header for java --> <licenseHeader>...</licenseHeader> </java> </configuration> ``` Previously global config had no effect. This commit fixes the problem by passing globally configured generic steps down to `FormatterFactory` which creates steps and uses globally configured ones, unless overridden.
Configuration menu - View commit details
-
Copy full SHA for a934a73 - Browse repository at this point
Copy the full SHA a934a73View commit details
Commits on Feb 12, 2018
-
Moved license header config handling to FormatterFactory
License header is a generic step that is applicable to both `Java` and `Scala`. This commit moves adder for it to `FormatterFactory`, which is super class of both `Java` and `Scala`. Code duplication is thus a bit reduced.
Configuration menu - View commit details
-
Copy full SHA for 4162569 - Browse repository at this point
Copy the full SHA 4162569View commit details