Skip to content

Commit

Permalink
Enable formatting of tests by default (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
jskov authored Oct 6, 2024
1 parent 72a6fe9 commit f070720
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ By default uses [this configuration](./src/main/resources/config/spotless/eclips

* `dk.mada.style.formatter.enabled = true`
Boolean flag allowing the formatter to be disabled
* `dk.mada.style.formatter.include = src/main/java/**/*.java`
Ant-style include pattern for files to format
* `dk.mada.style.formatter.include = src/main/java/**/*.java, src/test/java/**/*.java`
Comma-separated Ant-style include patterns for files to format
* `dk.mada.style.formatter.exclude = `
Ant-style exclude pattern for files to not format
Comma-separated Ant-style exclude patterns for files to not format
* `dk.mada.style.formatter.eclipse-config-path = null`
Optional path to an alternative eclipse formatter configuration file
This can be a URL; the content will be downloaded and cached (so if you want to update the content, you must change the URL)
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/dk/mada/style/config/PluginConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public record ErrorProneConfiguration(boolean enabled, boolean ignoreTestSource,
* Formatter configuration.
*
* @param enabled flag to activate formatter
* @param include Ant-style pattern for sources to format
* @param exclude Ant-style pattern for sources to ignore
* @param includes Ant-style patterns for sources to format
* @param excludes Ant-style patterns for sources to ignore
* @param eclipseConfigPath an optional path to an eclipse configuration file
* @param eclipse429P2mirror an optional URL to a eclipse update P2 repository
*/
public record FormatterConfiguration(boolean enabled, String include, String exclude, @Nullable String eclipseConfigPath,
public record FormatterConfiguration(boolean enabled, List<String> includes, List<String> excludes, @Nullable String eclipseConfigPath,
@Nullable String eclipse429P2mirror) {
}

Expand Down Expand Up @@ -126,8 +126,8 @@ public PluginConfiguration(Project project) {

formatterConf = new FormatterConfiguration(
getBoolProperty("formatter.enabled", true),
getProperty("formatter.include", "src/main/java/**/*.java"),
getProperty("formatter.exclude", ""),
getListProperty("formatter.include", List.of("src/main/java/**/*.java", "src/test/java/**/*.java")),
getListProperty("formatter.exclude", List.of()),
getNullableProperty("formatter.eclipse-config-path", null),
getNullableProperty("formatter.eclipse-429-p2-url", null));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dk.mada.style.configurators;

import java.nio.file.Path;
import java.util.List;
import java.util.Map;

import org.gradle.api.logging.Logger;
Expand Down Expand Up @@ -54,8 +55,8 @@ public void configure(SpotlessExtension se) {
}

private void configureJava(JavaExtension je) {
String include = formatterConfig.include();
String exclude = formatterConfig.exclude();
List<String> include = formatterConfig.includes();
List<String> exclude = formatterConfig.excludes();
Path configFile = getActiveConfigfile();
logger.debug("Spotless java config: {}", configFile);
logger.debug("Spotless java include:{} exclude:{}", include, exclude);
Expand Down

0 comments on commit f070720

Please sign in to comment.