Skip to content
Open
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
21 changes: 21 additions & 0 deletions plugin-gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Spotless supports all of Gradle's built-in performance features (incremental bui
- [Dependency resolution modes](#dependency-resolution-modes)
- [How do I preview what `spotlessApply` will do?](#how-do-i-preview-what-spotlessapply-will-do)
- [Can I apply Spotless to specific files?](#can-i-apply-spotless-to-specific-files)
- [Sharing Spotless Configuration](#sharing-configuration)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous point, the verbs appear in their base form — preview, apply, share — rather than in their continuous forms (previewing, applying, sharing).
We could continue using this style for consistency, ensuring a cohesive look and feel.

Suggested change
- [Sharing Spotless Configuration](#sharing-configuration)
- [Share Spotless Configuration](#sharing-configuration)

- [Example configurations (from real-world projects)](#example-configurations-from-real-world-projects)

***Contributions are welcome, see [the contributing guide](../CONTRIBUTING.md) for development info.***
Expand Down Expand Up @@ -1908,6 +1909,26 @@ cmd> gradle spotlessApply -PspotlessFiles=my/file/pattern.java,more/generic/.*-p

The patterns are matched using `String#matches(String)` against the absolute file path.

## Sharing Configuration

Rather than copying the formatter files across many projects, it is possible to define a common configuration that is deployed as a standard artifact so that it can be then be reused by each project; for example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Rather than copying the formatter files across many projects, it is possible to define a common configuration that is deployed as a standard artifact so that it can be then be reused by each project; for example:
Rather than copying the formatter files across many projects, it is possible to define a common configuration that is deployed as a standard artifact, so that it can be then be reused by each project; for example:

In german it could be like this to give dedication and separation. But its en so idk. Ned should fine tune this. Its not so important.

Rest is perfecly fine.


```kotlin
val spotlessConfig by configurations.creating
dependencies {
spotlessConfig("org.mycompany:code-configuration:1.0.0")
}
spotless {
java {
removeUnusedImports()
importOrder(resources.text.fromArchiveEntry(spotlessConfig, "java-import-order.txt").asString())
eclipse().configXml(resources.text.fromArchiveEntry(spotlessConfig, "java-formatter.xml").asString())
}
}
```

In this example, the files `java-import-order.txt` and `java-formatter.xml` should be at the root of the deployed `org.mycompany:code-configuration:1.0.0` jar.

## Example configurations (from real-world projects)

* [A few thousand github projects](https://github.com/search?l=gradle&q=spotless&type=Code)
Expand Down
33 changes: 33 additions & 0 deletions plugin-maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ user@machine repo % mvn spotless:check
- [Disabling warnings and error messages](#disabling-warnings-and-error-messages)
- [How do I preview what `mvn spotless:apply` will do?](#how-do-i-preview-what-mvn-spotlessapply-will-do)
- [Can I apply Spotless to specific files?](#can-i-apply-spotless-to-specific-files)
- [Sharing Spotless Configuration](#sharing-configuration)
- [Example configurations (from real-world projects)](#example-configurations-from-real-world-projects)

***Contributions are welcome, see [the contributing guide](../CONTRIBUTING.md) for development info.***
Expand Down Expand Up @@ -2052,6 +2053,38 @@ Note that for Incremental build support the goals have to be bound to a phase pr

<a name="examples"></a>

## Sharing Configuration

Rather than copying the formatter files across many projects, it is possible to define a common configuration that is deployed as a standard artifact so that it can be then be reused by each project; for example:

```
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless-maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.mycompany</groupId>
<artifactId>code-configuration</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<configuration>
<java>
<removeUnusedImports/>
<importOrder>
<file>java-import-order.txt</file>
</importOrder>
<eclipse>
<file>java-formatter.xml</file>
</eclipse>
<lineEndings>UNIX</lineEndings>
</java>
</configuration>
```

In this example, the files `java-import-order.txt` and `java-formatter.xml` should be at the root of the deployed `org.mycompany:code-configuration:1.0.0` jar.

## Example configurations (from real-world projects)

- [Apache Avro](https://github.com/apache/avro/blob/8026c8ffe4ef67ab419dba73910636bf2c1a691c/lang/java/pom.xml#L307-L334)
Expand Down