Skip to content

Commit e2dcc7c

Browse files
committed
new param 'addVerifyPlugin' (default 'true') of 'add' plugin
1 parent c765a89 commit e2dcc7c

File tree

7 files changed

+75
-15
lines changed

7 files changed

+75
-15
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- [fj-doc-maven-plugin] new param 'addVerifyPlugin' (default 'true') of 'add' plugin
13+
1014
## [8.7.0] - 2024-08-25
1115

1216
### Added

fj-doc-maven-plugin/README.md

+16-11
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ mvn org.fugerit.java:fj-doc-maven-plugin:add \
4141

4242
*Parameters*
4343

44-
| parameter | required | default | description |
45-
|----------------|----------|-----------------|---------------------------------------------------------------------------------------------------|
46-
| version | true | latest stable | fj-doc version to add to the project (i.e. '8.6.5') |
47-
| extensions | true | base,freemarker | List of fj-doc core modules to add (*) |
48-
| projectFolder | true | . | Maven project base folder |
49-
| addDocFacade | true | true | If true, a stub doc configuration helper will be created |
50-
| force | false | false | Will force project setup even if fj-doc already configured (warning: can overwrite configuration) |
51-
| excludeXmlApis | false | false | It will exclude dependency xml-apis:xml-apis |
52-
| addExclusions | false | | Add comma separated exclusion, for instance : xml-apis:xml-apis,${groupId}:${artificatId} |
44+
| parameter | required | default | description |
45+
|-----------------|----------|-----------------|---------------------------------------------------------------------------------------------------|
46+
| version | true | latest stable | fj-doc version to add to the project (i.e. '8.6.5') |
47+
| extensions | true | base,freemarker | List of fj-doc core modules to add (*) |
48+
| projectFolder | true | . | Maven project base folder |
49+
| addDocFacade | true | true | If true, a stub doc configuration helper will be created |
50+
| force | false | false | Will force project setup even if fj-doc already configured (warning: can overwrite configuration) |
51+
| excludeXmlApis | false | false | It will exclude dependency xml-apis:xml-apis |
52+
| addExclusions | false | | Add comma separated exclusion, for instance : xml-apis:xml-apis,${groupId}:${artificatId} |
53+
| addVerifyPlugin | true | true | If set to true, it will configure the 'verify' goal on the project |
5354

5455

5556

@@ -89,17 +90,21 @@ mvn org.fugerit.java:fj-doc-maven-plugin:verify -DtemplateBasePath=./src/test/re
8990
<version>${fj-doc-version}</version>
9091
<executions>
9192
<execution>
92-
<id>daogen</id>
93+
<id>freemarker-verify</id>
9394
<phase>compile</phase>
9495
<goals>
9596
<goal>verify</goal>
9697
</goals>
9798
</execution>
9899
</executions>
99100
<configuration>
101+
<!-- Where the FreeMarker templates are located -->
100102
<templateBasePath>${project.basedir}/src/main/resources/fugerit-blank/template</templateBasePath>
101-
<generateReport>true</generateReport>
103+
<!-- WARNING: if set to 'true', build will fail when at least one syntax error is found -->
102104
<failOnErrors>true</failOnErrors>
105+
<!-- If 'true' a report will be generated (when 'true', param reportOutputFolder is required) -->
106+
<generateReport>true</generateReport>
107+
<!-- Template syntax verify report output folder -->
103108
<reportOutputFolder>${project.build.directory}/freemarker-syntax-verify-report</reportOutputFolder>
104109
</configuration>
105110
</plugin>

fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/maven/MojoAdd.java

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public class MojoAdd extends AbstractMojo {
3535
@Parameter(property = "addExclusions", required = false)
3636
protected String addExclusions;
3737

38+
@Parameter(property = "addVerifyPlugin", defaultValue = "true", required = true)
39+
protected boolean addVerifyPlugin;
40+
3841
@Override
3942
public void execute() throws MojoExecutionException, MojoFailureException {
4043
String foundVersion = VersionCheck.findVersion( this.version );
@@ -44,6 +47,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
4447
context.setForce( this.force );
4548
context.setAddExclusions( addExclusions );
4649
context.setExcludeXmlApis( this.excludeXmlApis );
50+
context.setAddVerifyPlugin( this.addVerifyPlugin );
4751
this.getLog().info( String.format( "add execute() context : %s", context ) );
4852
AddVenusFacade.addVenusToMavenProject( context );
4953
}

fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/BasicVenusFacade.java

+43-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package org.fugerit.java.doc.project.facade;
22

33
import lombok.extern.slf4j.Slf4j;
4-
import org.apache.maven.model.Dependency;
5-
import org.apache.maven.model.DependencyManagement;
6-
import org.apache.maven.model.Exclusion;
7-
import org.apache.maven.model.Model;
4+
import org.apache.maven.model.*;
5+
import org.apache.maven.plugin.lifecycle.Execution;
6+
import org.codehaus.plexus.util.xml.Xpp3Dom;
7+
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
88
import org.fugerit.java.core.cfg.ConfigRuntimeException;
9+
import org.fugerit.java.core.io.helper.HelperIOException;
10+
import org.fugerit.java.core.lang.helpers.BooleanUtils;
911
import org.fugerit.java.core.lang.helpers.StringUtils;
12+
import org.fugerit.java.doc.freemarker.tool.FreeMarkerTemplateSyntaxVerifier;
1013
import org.maxxq.maven.dependency.ModelIO;
1114

1215
import java.io.*;
@@ -100,11 +103,47 @@ protected static void addExtensionList( File pomFile, VenusContext context ) thr
100103
}
101104
}
102105
log.info( "end dependencies size : {}", model.getDependencies().size() );
106+
// addVerifyPlugin?
107+
log.info( "addVerifyPlugin : {}", context.isAddVerifyPlugin() );
108+
addPlugin( context, model );
103109
try (OutputStream pomStream = new FileOutputStream( pomFile ) ) {
104110
modelIO.writeModelToStream( model, pomStream );
105111
}
106112
}
107113

114+
private static void addPlugin( VenusContext context, Model model ) throws IOException {
115+
if ( context.isAddVerifyPlugin() ) {
116+
Build build = model.getBuild();
117+
if ( build == null ) {
118+
build = new Build();
119+
model.setBuild( build );
120+
}
121+
List<Plugin> plugins = model.getBuild().getPlugins();
122+
Plugin plugin = new Plugin();
123+
plugin.setGroupId( GROUP_ID );
124+
plugin.setArtifactId( "fj-doc-maven-plugin" );
125+
plugin.setVersion( "${"+KEY_VERSION+"}" );
126+
PluginExecution execution = new PluginExecution();
127+
execution.setId( "freemarker-verify" );
128+
execution.setPhase( "compile" );
129+
execution.addGoal( "verify" );
130+
plugin.getExecutions().add( execution );
131+
String xml = "<configuration>\n" +
132+
" <templateBasePath>${project.basedir}/src/main/resources/"+context.getArtificatIdForFolder()+"/template</templateBasePath>\n" +
133+
" <generateReport>true</generateReport>\n" +
134+
" <failOnErrors>true</failOnErrors>\n" +
135+
" <reportOutputFolder>${project.build.directory}/freemarker-syntax-verify-report</reportOutputFolder>\n" +
136+
" </configuration>";
137+
try ( StringReader sr = new StringReader( xml ) ) {
138+
Xpp3Dom dom = Xpp3DomBuilder.build( sr );
139+
plugin.setConfiguration( dom );
140+
} catch (Exception e) {
141+
throw HelperIOException.convertEx( e );
142+
}
143+
plugins.add( plugin );
144+
}
145+
}
146+
108147
public static void checkDependencies( boolean force, Dependency d ) {
109148
if ( d.getGroupId().equals( GROUP_ID ) && d.getArtifactId().startsWith( "fj-doc") ) {
110149
log.warn( "fj-doc dependency found : {}", d );

fj-doc-maven-plugin/src/main/java/org/fugerit/java/doc/project/facade/VenusContext.java

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public class VenusContext {
4444
@Getter @Setter
4545
private String addExclusions;
4646

47+
@Getter @Setter
48+
private boolean addVerifyPlugin;
49+
4750
public void setExcludeXmlApis( boolean excludeXmlApis ) {
4851
if ( excludeXmlApis ) {
4952
this.setAddExclusions( "xml-apis:xml-apis" );

fj-doc-maven-plugin/src/test/java/test/org/fugerit/java/doc/project/facade/TestAddVenusFacade.java

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7272
this.addDocFacade = true;
7373
this.force = true;
7474
this.excludeXmlApis = true;
75+
this.addVerifyPlugin = true;
7576
super.execute();
7677
}
7778
};

fj-doc-maven-plugin/src/test/resources/ok1-pom/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@
2222
</organization>
2323

2424
<url>https://www.fugerit.org/</url>
25+
26+
<build>
27+
28+
</build>
2529

2630
</project>

0 commit comments

Comments
 (0)