Skip to content

Commit dc2381c

Browse files
committed
chore: maven formatter plugin with org.fugerit.java:fugerit-code-rules
1 parent 5d1f83e commit dc2381c

File tree

4 files changed

+54
-20
lines changed

4 files changed

+54
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
* maven formatter plugin with org.fugerit.java:fugerit-code-rules
1213
* dependabot workflow
1314

1415
## Fixed

pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1111
<fj-doc-version>8.16.9</fj-doc-version>
1212
<jacoco-plugin-version>0.8.14</jacoco-plugin-version>
13+
<!-- formatter plugin -->
14+
<mvn-formatter-plugin-version>2.29.0</mvn-formatter-plugin-version>
15+
<fugerit-code-rules-version>0.1.1</fugerit-code-rules-version>
16+
<format.skip>false</format.skip>
1317
</properties>
1418
<dependencyManagement>
1519
<dependencies>
@@ -88,6 +92,31 @@
8892
</execution>
8993
</executions>
9094
</plugin>
95+
<plugin>
96+
<groupId>net.revelc.code.formatter</groupId>
97+
<artifactId>formatter-maven-plugin</artifactId>
98+
<version>${mvn-formatter-plugin-version}</version>
99+
<dependencies>
100+
<dependency>
101+
<groupId>org.fugerit.java</groupId>
102+
<artifactId>fugerit-code-rules</artifactId>
103+
<version>${fugerit-code-rules-version}</version>
104+
</dependency>
105+
</dependencies>
106+
<configuration>
107+
<configFile>org/fugerit/java/coderules/eclipse-format.xml</configFile>
108+
<skip>${format.skip}</skip>
109+
</configuration>
110+
<executions>
111+
<execution>
112+
<id>format-sources</id>
113+
<phase>process-sources</phase>
114+
<goals>
115+
<goal>format</goal>
116+
</goals>
117+
</execution>
118+
</executions>
119+
</plugin>
91120
</plugins>
92121
</build>
93122
</project>

src/main/java/org/fugerit/java/demo/bareminimumgithubrepojavamaven/DocHelper.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@
88
*/
99
public class DocHelper {
1010

11-
/*
12-
* FreemarkerDocProcessConfig is thread-safe and should be initialized once for each config file.
13-
*
14-
* Consider using a @ApplicationScoped or Singleton approach.
15-
*/
16-
private FreemarkerDocProcessConfig docProcessConfig = FreemarkerDocProcessConfigFacade.loadConfigSafe( "cl://bare-minimum-github-repo-java-maven/fm-doc-process-config.xml" );
11+
/*
12+
* FreemarkerDocProcessConfig is thread-safe and should be initialized once for each config file.
13+
*
14+
* Consider using a @ApplicationScoped or Singleton approach.
15+
*/
16+
private FreemarkerDocProcessConfig docProcessConfig = FreemarkerDocProcessConfigFacade
17+
.loadConfigSafe("cl://bare-minimum-github-repo-java-maven/fm-doc-process-config.xml");
1718

18-
/**
19-
* Accessor for FreemarkerDocProcessConfig configuration.
20-
*
21-
* @return the FreemarkerDocProcessConfig instance associated with this helper.
22-
*/
23-
public FreemarkerDocProcessConfig getDocProcessConfig() { return this.docProcessConfig; }
19+
/**
20+
* Accessor for FreemarkerDocProcessConfig configuration.
21+
*
22+
* @return the FreemarkerDocProcessConfig instance associated with this helper.
23+
*/
24+
public FreemarkerDocProcessConfig getDocProcessConfig() {
25+
return this.docProcessConfig;
26+
}
2427

2528
}

src/test/java/test/org/fugerit/java/demo/bareminimumgithubrepojavamaven/DocHelperTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,29 @@
2929
* https://github.com/fugerit-org/fj-doc
3030
*
3131
* NOTE: This is a 'Hello World' style example, adapt it to your scenario, especially :
32-
* - change the doc handler and the output mode (here a ByteArrayOutputStream buffer is used)
32+
* - change the doc handler and the output mode (here a ByteArrayOutputStream buffer is used)
3333
*/
3434
@Slf4j
3535
class DocHelperTest {
3636

3737
@Test
3838
void testDocProcess() throws Exception {
39-
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) {
39+
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
4040
// creates the doc helper
4141
DocHelper docHelper = new DocHelper();
4242
// create custom data for the fremarker template 'document.ftl'
43-
List<People> listPeople = Arrays.asList( new People( "Luthien", "Tinuviel", "Queen" ), new People( "Thorin", "Oakshield", "King" ) );
44-
45-
43+
List<People> listPeople = Arrays.asList(new People("Luthien", "Tinuviel", "Queen"),
44+
new People("Thorin", "Oakshield", "King"));
45+
4646
String chainId = "document";
4747
// handler id
4848
String handlerId = DocConfig.TYPE_MD;
4949
// output generation
50-
docHelper.getDocProcessConfig().fullProcess( chainId, DocProcessContext.newContext( "listPeople", listPeople ), handlerId, baos );
50+
docHelper.getDocProcessConfig().fullProcess(chainId, DocProcessContext.newContext("listPeople", listPeople),
51+
handlerId, baos);
5152
// print the output
52-
log.info( "{} output : \n{}", handlerId, new String( baos.toByteArray(), StandardCharsets.UTF_8 ) );
53-
Assertions.assertNotEquals( 0, baos.size() );
53+
log.info("{} output : \n{}", handlerId, new String(baos.toByteArray(), StandardCharsets.UTF_8));
54+
Assertions.assertNotEquals(0, baos.size());
5455
}
5556
}
5657

0 commit comments

Comments
 (0)