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

Execute spotless by JDK 11 at least #360

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -265,5 +265,5 @@ target/
### Takari Maven Wrapper ###
/mvnw.bat
/mvnw
/.mvn/
.mvn/wrapper

1 change: 1 addition & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-DrecommendedJavaBuildVersion=11
29 changes: 21 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
<maven.compiler.target>${mojo.java.target}</maven.compiler.target>

<minimalJavaBuildVersion>${mojo.java.target}</minimalJavaBuildVersion>
<recommendedJavaBuildVersion>${minimalJavaBuildVersion}</recommendedJavaBuildVersion>

<minimalMavenBuildVersion>3.2.5</minimalMavenBuildVersion>

<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand Down Expand Up @@ -652,6 +654,11 @@
<requireJavaVersion>
<version>${minimalJavaBuildVersion}</version>
</requireJavaVersion>
<requireJavaVersion>
<version>${recommendedJavaBuildVersion}</version>
<level>WARN</level>
<message>Recommended Java version for build should be at least ${recommendedJavaBuildVersion}</message>
</requireJavaVersion>
<requireProperty>
<property>project.scm.connection</property>
<!-- because Maven adds the artifactId to the SCM-Url automatically for modules in a multimodule project,
Expand All @@ -673,12 +680,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<!-- only in parent, other projects must enable it by itself -->
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
Expand Down Expand Up @@ -716,13 +717,25 @@

<profiles>
<profile>
<id>java9+</id>
<id>java11+</id>
<activation>
<jdk>[9,)</jdk>
<jdk>[11,)</jdk>
</activation>

<properties>
<maven.compiler.release>${mojo.java.target}</maven.compiler.release>
</properties>

<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<!-- only in parent, other projects must enable it by itself -->
<inherited>false</inherited>
</plugin>
</plugins>
</build>
</profile>

<profile>
Expand Down
29 changes: 24 additions & 5 deletions src/site/markdown/index.md.vm
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,32 @@ with options:
- other imports
- static import

In order to use `spotless` in your project, you should add to your pom.xml `build/plugins`:
In order to use `spotless` in your project, you should add to your pom.xml

Newer version of spotless requires JDK 11, so it must be add in profile unless your project requires 11 by default.

```xml
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
<profiles>
<profile>
<id>java11+</id>
<activation>
<jdk>[11,)</jdk>
</activation>

<properties>
<recommendedJavaBuildVersion>11</recommendedJavaBuildVersion>
</properties>

<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
```

When `spotless` will be enabled, each build will be check according to correct code format.
Expand Down