From 2b8bafd71d3ed4fe64fd1523d475ab298f07d3df Mon Sep 17 00:00:00 2001 From: lutovich Date: Thu, 30 Aug 2018 00:36:58 +0200 Subject: [PATCH] Include Maven version requirement in the generated POM Before this commit, it was only included in the POM used to build the plugin. It is different from the POM that's being published to Maven Central. Later is generated using `generatePomFileForPluginMavenPublication` gradle task. This resulted in Maven version requirement not being enforced and builds failing with confusing error messages. Also added `prerequisites` section to the POM used to test the plugin. --- gradle/java-publish.gradle | 8 +++++++- plugin-maven/CHANGES.md | 1 + plugin-maven/src/test/resources/pom-build.xml.mustache | 1 + plugin-maven/src/test/resources/pom-test.xml.mustache | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gradle/java-publish.gradle b/gradle/java-publish.gradle index 6502b6e7fc..29beac4452 100644 --- a/gradle/java-publish.gradle +++ b/gradle/java-publish.gradle @@ -64,6 +64,8 @@ def cred = { } } +final MAVEN_PLUGIN_ARTIFACT_NAME = 'spotless-maven-plugin' + model { publishing { publications { @@ -97,8 +99,12 @@ model { distribution 'repo' } } + if (project.ext.artifactId == MAVEN_PLUGIN_ARTIFACT_NAME) { + // Maven plugin required Maven 3.1.0+ to run + prerequisites { maven '3.1.0' } + } developers { - if (project.ext.artifactId == 'spotless-plugin-maven') { + if (project.ext.artifactId == MAVEN_PLUGIN_ARTIFACT_NAME) { developer { id 'lutovich' name 'Konstantin Lutovich' diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 55dd98bd0e..f2887909d1 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -5,6 +5,7 @@ * Skip `package-info.java` and `module-info.java` files from license header formatting. ([#273](https://github.com/diffplug/spotless/pull/273)) * Updated JSR305 annotation from 3.0.0 to 3.0.2 ([#274](https://github.com/diffplug/spotless/pull/274)) * Migrated from FindBugs annotations 3.0.0 to SpotBugs annotations 3.1.6 ([#274](https://github.com/diffplug/spotless/pull/274)) +* Fix Maven version prerequisite in the generated POM ([#289](https://github.com/diffplug/spotless/pull/289)) ### Version 1.14.0 - July 24th 2018 ([javadoc](https://diffplug.github.io/spotless/javadoc/spotless-maven-plugin/1.14.0/), [jcenter](https://bintray.com/diffplug/opensource/spotless-maven-plugin/1.14.0)) diff --git a/plugin-maven/src/test/resources/pom-build.xml.mustache b/plugin-maven/src/test/resources/pom-build.xml.mustache index 07d473fa94..3495ee8e68 100644 --- a/plugin-maven/src/test/resources/pom-build.xml.mustache +++ b/plugin-maven/src/test/resources/pom-build.xml.mustache @@ -9,6 +9,7 @@ Spotless Maven Plugin + 3.1.0 diff --git a/plugin-maven/src/test/resources/pom-test.xml.mustache b/plugin-maven/src/test/resources/pom-test.xml.mustache index 26350411d5..b03c0b8205 100644 --- a/plugin-maven/src/test/resources/pom-test.xml.mustache +++ b/plugin-maven/src/test/resources/pom-test.xml.mustache @@ -8,6 +8,11 @@ Spotless Maven Plugin Tests + + + 3.1.0 + + UTF-8 1.8