Skip to content
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

Merged
merged 93 commits into from
Feb 12, 2018
Merged
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
5ff5581
Initial version of Spotless Maven plugin
lutovich Jan 14, 2018
9956473
Switched maven plugin over to Formatter.
nedtwigg Jan 17, 2018
c219ef1
Improved config handling in maven plugin
lutovich Jan 17, 2018
a5a6cc9
Removed dependency on maven-core
lutovich Jan 17, 2018
1d63aa2
Simplified maven plugin build process
lutovich Jan 17, 2018
af677ab
Set maven plugin version from gradle props
lutovich Jan 17, 2018
b059d53
Added "aspiring" docs for the maven plugin.
nedtwigg Jan 19, 2018
c0a2fa6
Merge branch 'master' into maven-plugin
nedtwigg Jan 19, 2018
a431b71
Switch indent from tab to 2-space for better GitHub render.
nedtwigg Jan 19, 2018
3639269
Update feature matrix for current maven ambitions.
nedtwigg Jan 19, 2018
240f87c
Fixed some typos in README.
nedtwigg Jan 19, 2018
8570064
Made maven plugin build use template for pom
lutovich Jan 19, 2018
75f0204
Fixed code formatting and build dir reference
lutovich Jan 19, 2018
40da7f5
Improve maven plugin configuration
lutovich Jan 21, 2018
3696310
Changed maven artifactId to spotless-maven-plugin, but kept project f…
nedtwigg Jan 21, 2018
49c2753
Added an explicit steps container inside each "java" configuration.
nedtwigg Jan 21, 2018
35da59a
Change task names from "spotless-{check|apply}" to just "check|apply".
nedtwigg Jan 21, 2018
fd38755
First cut at an integration test system for the maven plugin.
nedtwigg Jan 21, 2018
3864178
Use ByteStreams.copy to reduce boilerplate.
nedtwigg Jan 22, 2018
d54b183
Made maven plugin ITs runnable
lutovich Jan 22, 2018
ddbf0eb
Better package name for maven plugin
lutovich Jan 22, 2018
4754a8f
Include stdout and stderr in maven plugin test failures
lutovich Jan 22, 2018
88bcd19
Assert on exit code, not stderr
lutovich Jan 22, 2018
c84becf
Refactored DiffMessageFormatter out of gradle and into lib-extra.
nedtwigg Jan 23, 2018
012b118
Added "check" to the maven plugin, but not properly integrated.
nedtwigg Jan 23, 2018
0c01e64
Made maven plugin use all dependencies from local repo
lutovich Jan 23, 2018
c43ed45
Consistent naming of mustache variables
lutovich Jan 23, 2018
66bb67e
Use correct root dir for DiffMessageFormatter
lutovich Jan 24, 2018
31d5357
Fix maven provisioner to resolve transitive dependencies
lutovich Jan 24, 2018
4b032eb
Support RemoveUnusedImports in maven plugin
lutovich Jan 24, 2018
4cf839a
Use correct artifactId for maven plugin in tests
lutovich Jan 24, 2018
622d2df
Extracted check MOJO
lutovich Jan 24, 2018
e759a0b
Removed DiffMessageFormatter::rootDir() because Formatter has it alre…
nedtwigg Jan 27, 2018
0185af6
The local dependencies repo now contains only our local deps, and it …
nedtwigg Jan 27, 2018
0dba10c
Forced buildMavenPlugin to act like the standard jar task, so that pu…
nedtwigg Jan 27, 2018
9bb5bbc
Added a GoogleJavaFormat step.
nedtwigg Jan 27, 2018
3189d7d
Added an ImportOrder step.
nedtwigg Jan 27, 2018
6568440
Reorganized packages.
nedtwigg Jan 27, 2018
21f8d00
Make the parent FormatterFactory available to the FormatterStepFactory.
nedtwigg Jan 27, 2018
8ebdbfc
Refactored non-java stuff out of FormatterFactory.
nedtwigg Jan 27, 2018
24f7096
Added a License step.
nedtwigg Jan 27, 2018
5e9fce6
Refactor formatter and step configuration
lutovich Jan 27, 2018
d95f76d
Allow multiple file extension for formatters
lutovich Jan 27, 2018
4f2952c
Made spotless mojo scan for files starting at basedir
lutovich Jan 28, 2018
1d82ba9
Added scalafmt step
lutovich Jan 28, 2018
4b34991
Fixed license header tests
lutovich Jan 28, 2018
7db3759
Mark check and apply MOJOs as thread safe
lutovich Jan 28, 2018
d8258bd
Removed need for "<steps>" config element
lutovich Jan 30, 2018
a8de57d
Added property to skip 'spotless:check'
lutovich Jan 30, 2018
3ca2bf7
Added javadoc to check and apply MOJOs
lutovich Jan 30, 2018
807291e
Bind 'spotless:check' to verify phase by default
lutovich Jan 30, 2018
48cb4c9
Run maven plugin tests with full stacktrace logging
lutovich Jan 30, 2018
08f90d2
Use mvnw to build maven plugin
lutovich Jan 31, 2018
5ccbd09
Cache the .m2 directory on Travis.
nedtwigg Feb 1, 2018
7df6191
Use mvnw to run tests.
nedtwigg Feb 1, 2018
a676bc4
Moved mvnw out of src/main/resources into the project route.
nedtwigg Feb 1, 2018
d4cddc0
Revert "Moved mvnw out of src/main/resources into the project route."
nedtwigg Feb 1, 2018
b9a4fa4
Added task graph vis, which shows problem in build.
nedtwigg Feb 1, 2018
bafc30c
Fixed the problem in the build.
nedtwigg Feb 1, 2018
9d3ea05
Moved mvnw and the template poms into src/test/resources.
nedtwigg Feb 1, 2018
e438881
Only run the maven tests on CI, for faster debugging. Also format fix.
nedtwigg Feb 1, 2018
f8bf47d
mvnw now works on Windows.
nedtwigg Feb 2, 2018
d2170fe
Disable the apache-snapshots repo.
nedtwigg Feb 2, 2018
da36b36
Another attempt at disabling the apache-snapshots repo.
nedtwigg Feb 2, 2018
07b6d68
Update docs for skipping spotless:check.
nedtwigg Feb 2, 2018
243035e
Try to figure out what travis is using for $HOME/.m2/settings.xml
nedtwigg Feb 2, 2018
ea6ebb5
Attempt #2...
nedtwigg Feb 2, 2018
6d660c6
Instead of snapshot-repo-whackamole, I'm just setting a restrictive s…
nedtwigg Feb 2, 2018
aef8b32
Another shot at a settings.xml - none at all.
nedtwigg Feb 2, 2018
21f163b
Force maven tests to run in "offline" mode.
nedtwigg Feb 2, 2018
e7cea18
Run Maven with debug logging and use "special" version
lutovich Feb 4, 2018
da77c39
Set version back to normal
lutovich Feb 4, 2018
34ff0e9
Local repo as repository, not only pluginRepository
lutovich Feb 4, 2018
7de4e1a
Do not use offline mode for maven plugin tests
lutovich Feb 4, 2018
8e77cf7
Force snapshot updates in maven plugin tests
lutovich Feb 4, 2018
fcebff7
Install maven plugin to local repo during build
lutovich Feb 4, 2018
53d8013
Turn off debug logging and cleanup local repo cmd
lutovich Feb 4, 2018
d52a448
Run all tests on CI
lutovich Feb 4, 2018
079e9a2
Removed repository declaration from POMs
lutovich Feb 4, 2018
3fdc785
Less verbose download logging when building maven plugin
lutovich Feb 4, 2018
95c7fc9
Cache the localMavenRepository on Travis, but delete the com.diffplug…
nedtwigg Feb 5, 2018
bd8a3b9
Merge branch 'master' into maven-plugin
nedtwigg Feb 5, 2018
d215905
Added support for google-java-format's style parameter.
nedtwigg Feb 5, 2018
2345cbd
Added `~/.m2` as a cached directory, because stuff gets downloaded fo…
nedtwigg Feb 5, 2018
0f9ff8e
Added a test for GoogleJavaFormat's style parameter.
nedtwigg Feb 5, 2018
9cee266
Gah! Fumble-fingers, I forgot the build.
nedtwigg Feb 5, 2018
15e65a0
Allow custom file includes and excludes
lutovich Feb 10, 2018
740317c
Added docs about includes & excludes configuration
lutovich Feb 10, 2018
a154f59
Fix serialization warning.
nedtwigg Feb 10, 2018
49987d7
Update README because maven-plugin is integrated with scala.
nedtwigg Feb 10, 2018
81477a6
Add @lutovich as first author of the maven plugin for the mavencentra…
nedtwigg Feb 10, 2018
a934a73
Fixed LicenseHeader when configured globally
lutovich Feb 11, 2018
4162569
Moved license header config handling to FormatterFactory
lutovich Feb 12, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
lutovich committed Jan 23, 2018
commit 0c01e6459b2fc950c6af36050a9d9adbead646e4
53 changes: 50 additions & 3 deletions plugin-maven/build.gradle
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ final BUILD_DIR = project.buildDir.toString()
final MAVEN_PROJECT_DIR = "${BUILD_DIR}/mavenProject"
final LOCAL_MAVEN_REPO_DIR = "${BUILD_DIR}/localMavenRepository"

final SPOTLESS_LIB_VERSION = "1.0.0-SNAPSHOT" // should be project.stableLib once maven plugin stabilizes

buildscript {
repositories { mavenCentral() }
dependencies { classpath "com.github.spullara.mustache.java:compiler:${VER_MUSTACHE}" }
@@ -46,13 +48,58 @@ task copySourceFiles(type: Copy) {
into "${MAVEN_PROJECT_DIR}/src/main/java"
}

task createPomXml {
// this task is temporary, it should be removed once maven plugin stabilizes
// and can depend on released version of lib and lib-extra
task installAllCompileDependenciesInLocalMavenRepo

project.configurations.compile.resolvedConfiguration.resolvedArtifacts.each {
def groupId = it.moduleVersion.id.group
def artifactId = it.moduleVersion.id.name
def version = it.moduleVersion.id.version
def file = it.file

if (artifactId == "lib" || artifactId == "lib-extra") {
artifactId = "spotless-" + artifactId
version = SPOTLESS_LIB_VERSION
}

def installDependency = task "install_${artifactId}"(type: Exec) {
commandLine "mvn", "org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file",
"-Dfile=${file}",
"-DgroupId=${groupId}",
"-DartifactId=${artifactId}",
"-Dversion=${version}",
"-Dpackaging=jar",
"-DlocalRepositoryPath=${LOCAL_MAVEN_REPO_DIR}"
}

installAllCompileDependenciesInLocalMavenRepo.dependsOn installDependency
}

task createPomXml(dependsOn: installAllCompileDependenciesInLocalMavenRepo) {
doLast {
def additionalDependencies = project.configurations.compile.resolvedConfiguration.resolvedArtifacts.findAll {
def artifactId = it.moduleVersion.id.name
return artifactId != "lib" && artifactId != "lib-extra"
}.collect {
def groupId = it.moduleVersion.id.group
def artifactId = it.moduleVersion.id.name
def version = it.moduleVersion.id.version

return "<dependency>\n" +
" <groupId>${groupId}</groupId>\n" +
" <artifactId>${artifactId}</artifactId>\n" +
" <version>${version}</version>\n" +
" </dependency>\n"
}.join("\n")

def versions = [
SpotlessMavenPluginVersion: project.versionMaven,
MavenApiVersion : VER_MAVEN_API,
EclipseAetherVersion : VER_ECLIPSE_AETHER,
SpotlessLibVersion : project.stableLib
SpotlessLibVersion : SPOTLESS_LIB_VERSION,
additionalDependencies : additionalDependencies,
localMavenRepositoryDir : LOCAL_MAVEN_REPO_DIR
]

def pomXmlTemplate = Paths.get(PROJECT_DIR, "src", "main", "resources", "pom.xml.mustache")
@@ -88,7 +135,7 @@ task createLocalMavenRepositoryForTests(type: Exec, dependsOn: buildMavenPlugin)
"-DgroupId=com.diffplug.spotless",
"-DartifactId=spotless",
"-Dversion=${project.versionMaven}",
"-Dpackaging=paven-plugin",
"-Dpackaging=maven-plugin",
"-DlocalRepositoryPath=${LOCAL_MAVEN_REPO_DIR}"
}

20 changes: 20 additions & 0 deletions plugin-maven/src/main/resources/pom.xml.mustache
Original file line number Diff line number Diff line change
@@ -20,6 +20,23 @@
<spotless.lib.version>{{SpotlessLibVersion}}</spotless.lib.version>
</properties>

<repositories>
<repository>
<id>local-repo</id>
<url>file://{{localMavenRepositoryDir}}</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</snapshots>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -56,6 +73,9 @@
<artifactId>spotless-lib-extra</artifactId>
<version>${spotless.lib.version}</version>
</dependency>

{{{additionalDependencies}}}

</dependencies>

<build>