Skip to content

Commit e748c4f

Browse files
authored
Merge pull request #457 from fugerit-org/456-chore-fj-doc-maven-plugin-goal-add---add-base-package-parameter
[fj-doc-maven-plugin] goal add - add base package parameter #456
2 parents 558c5f5 + 4b5c07d commit e748c4f

File tree

8 files changed

+30
-3
lines changed

8 files changed

+30
-3
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
### Changed
1111

12+
- [fj-doc-maven-plugin] goal add, new parameter : basePackage (optional) <https://github.com/fugerit-org/fj-doc/issues/456>
1213
- fj-bom version 2.0.2
1314
- quarkus-version set to 3.24.0 across all the modules <https://github.com/fugerit-org/fj-doc/issues/454>
1415

fj-doc-guide/src/main/docs/asciidoc/chapters/02_1_maven_plugin_add.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ mvn org.fugerit.java:fj-doc-maven-plugin:add \
1313

1414
==== Goal 'add' available parameters
1515

16+
[#goal-add-parameters]
17+
1618
[cols="4*", options="header"]
1719
|====================================================================================================================================================================================
1820
| parameter | required | default | description
@@ -30,6 +32,7 @@ mvn org.fugerit.java:fj-doc-maven-plugin:add \
3032
| addDependencyOnTop | true | false | If set to true, added dependencies will be added before existing ones
3133
| freemarkerVersion | true | 2.3.32 | Freemarker compatibility version (max 2.3.33)
3234
| simpleMpdel | true | false | If set to true, modification to pom.xml will be light, dependencies for addLombok and addJunit will be ignored. addVerifyPlugin param will be ignored.
35+
| basePackage | false | | If set given base package is used, otherwise base java package will be derived from groupId and artifactiId.
3336
|====================================================================================================================================================================================
3437

3538
[#available-extensions]

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public class MojoAdd extends AbstractMojo {
5656
@Parameter(property = "simpleModel", defaultValue = "false", required = true)
5757
protected boolean simpleModel;
5858

59+
@Parameter(property = "basePackage", required = false)
60+
protected String basePackage;
61+
5962
protected String groupIdOverride;
6063

6164
protected String artifactIdOverride;
@@ -78,6 +81,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7881
context.setGroupIdOverride( this.groupIdOverride );
7982
context.setArtifactIdOverride( this.artifactIdOverride );
8083
context.setSimpleModel( this.simpleModel );
84+
context.setBasePackage( this.basePackage );
8185
this.getLog().info( String.format( "add execute() context : %s", context ) );
8286
AddVenusFacade.addToProject( context );
8387
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
6363
context.setFlavourVersion( this.flavourVersion );
6464
context.setVersion( VersionCheck.findVersion( this.version ) );
6565
context.setExtensions( this.extensions );
66+
context.setBasePackage( this.basePackage );
6667
this.getLog().info( String.format( "flavour context : %s", context ) );
6768
String actualVersion = FlavourFacade.initProject( context );
6869
if ( FlavourFacade.FLAVOUR_DIRECT.equals( actualVersion ) ) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import lombok.*;
44
import lombok.extern.slf4j.Slf4j;
5+
import org.fugerit.java.core.lang.helpers.StringUtils;
56

67
import java.io.File;
78
import java.util.List;
@@ -44,6 +45,9 @@ public class FlavourContext {
4445
@Getter @Setter
4546
private String extensions;
4647

48+
@Getter @Setter
49+
private String basePackage;
50+
4751
private String toClassName( String base, String splitString ) {
4852
StringBuilder buf = new StringBuilder();
4953
String[] split = base.split( splitString );
@@ -70,4 +74,8 @@ public boolean isFreeMarkerNativeAvailable() {
7074
return VersionCheck.isMajorThan( this.getVersion(), VenusContext.VERSION_NA_FREEMARKER_NATIVE );
7175
}
7276

77+
public String getEvaluateBasePackage() {
78+
return StringUtils.valueWithDefault( this.getBasePackage(), VenusContext.toPackage( this.getGroupId(), this.getArtifactId() ) );
79+
}
80+
7381
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ public static String toResourcePathFmConfigXml( String artifactId ) {
9797
@Getter @Setter
9898
private boolean simpleModel;
9999

100+
@Getter @Setter
101+
private String basePackage;
102+
103+
public static String toPackage( String groupId, String artifactId) {
104+
return toArtificatIdForFolder( groupId )+"."+toArtificatIdForName( artifactId );
105+
}
106+
100107
public void setExcludeXmlApis( boolean excludeXmlApis ) {
101108
if ( excludeXmlApis ) {
102109
this.setAddExclusions( "xml-apis:xml-apis" );
@@ -143,7 +150,7 @@ public String getResourcePathFmConfigXml() {
143150
}
144151

145152
public String getDocConfigPackage() {
146-
return this.getGroupIdForName()+"."+this.getArtificatIdForName();
153+
return StringUtils.valueWithDefault( this.getBasePackage(), toPackage( this.getGroupId(), this.getArtificatIdForName() ) );
147154
}
148155

149156
public String getTemplateSubPath() {

fj-doc-maven-plugin/src/main/resources/config/template/flavour/flavour-macro.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<#macro toProjectPackageFolder context>${context.groupId?replace(".","/")}/${context.artifactId?replace("-","")}</#macro>
1+
<#macro toProjectPackageFolder context>${context.evaluateBasePackage?replace(".","/")}</#macro>
22

3-
<#macro toProjectPackage context>${context.groupId}.${context.artifactId?replace("-","")}</#macro>
3+
<#macro toProjectPackage context>${context.evaluateBasePackage}</#macro>
44

55
<#macro createDocumentProcess context exceptionType>
66
// creates the doc helper

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
5656
this.addJunit5 = true;
5757
this.addLombok = true;
5858
this.flavour = currentFlavour;
59+
if ( FlavourFacade.FLAVOUR_QUARKUS_3.equals( currentFlavour ) ) {
60+
this.basePackage = "org.fugerit.java.basepack";
61+
}
5962
super.execute();
6063
}
6164
};

0 commit comments

Comments
 (0)