Skip to content

Commit 0f3bfe0

Browse files
committed
new parameters excludeXmlApis and addExclusions
1 parent c90b089 commit 0f3bfe0

File tree

7 files changed

+86
-10
lines changed

7 files changed

+86
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ 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 parameter excludeXmlApis (could be needed with quarkus)
13+
- [fj-doc-maven-plugin] new parameter addExclusions
14+
1015
## [8.6.3] - 2024-08-21
1116

1217
### Changed

fj-doc-maven-plugin/README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ mvn org.fugerit.java:fj-doc-maven-plugin:add \
2929

3030
*Parameters*
3131

32-
| parameter | required | default | description |
33-
|---------------|----------|-----------------|---------------------------------------------------------------------------------------------------|
34-
| version | true | latest stable | fj-doc version to add to the project (i.e. '8.6.2') |
35-
| extensions | true | base,freemarker | List of fj-doc core modules to add (*) |
36-
| projectFolder | true | . | Maven project base folder |
37-
| addDocFacade | true | true | If true, a stub doc configuration helper will be created |
38-
| force | false | true | Will force project setup even if fj-doc already configured (warning: can overwrite configuration) |
32+
| parameter | required | default | description |
33+
|----------------|----------|-----------------|---------------------------------------------------------------------------------------------------|
34+
| version | true | latest stable | fj-doc version to add to the project (i.e. '8.6.2') |
35+
| extensions | true | base,freemarker | List of fj-doc core modules to add (*) |
36+
| projectFolder | true | . | Maven project base folder |
37+
| addDocFacade | true | true | If true, a stub doc configuration helper will be created |
38+
| force | false | false | Will force project setup even if fj-doc already configured (warning: can overwrite configuration) |
39+
| excludeXmlApis | false | false | It will exclude dependency xml-apis:xml-apis |
40+
| addExclusions | false | | Add comma separated exclusion, for instance : xml-apis:xml-apis,${groupId}:${artificatId} |
41+
42+
3943

4044
*Available extensions*
4145

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,21 @@ public class MojoAdd extends AbstractMojo {
2929
@Parameter(property = "force", defaultValue = "false", required = true)
3030
protected boolean force;
3131

32+
@Parameter(property = "excludeXmlApis", defaultValue = "false", required = true)
33+
protected boolean excludeXmlApis;
34+
35+
@Parameter(property = "addExclusions", required = false)
36+
protected String addExclusions;
37+
3238
@Override
3339
public void execute() throws MojoExecutionException, MojoFailureException {
3440
String foundVersion = VersionCheck.findVersion( this.version );
3541
this.getLog().info( String.format( "version parameter : %s found : %s", this.version, foundVersion ) );
3642
VenusContext context = new VenusContext( new File( this.projectFolder ), foundVersion ,this.extensions );
3743
context.setAddDocFacace( this.addDocFacade );
3844
context.setForce( this.force );
45+
context.setAddExclusions( addExclusions );
46+
context.setExcludeXmlApis( this.excludeXmlApis );
3947
this.getLog().info( String.format( "add execute() context : %s", context ) );
4048
AddVenusFacade.addVenusToMavenProject( context );
4149
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import lombok.extern.slf4j.Slf4j;
44
import org.apache.maven.model.Dependency;
55
import org.apache.maven.model.DependencyManagement;
6+
import org.apache.maven.model.Exclusion;
67
import org.apache.maven.model.Model;
78
import org.fugerit.java.core.cfg.ConfigRuntimeException;
9+
import org.fugerit.java.core.lang.helpers.StringUtils;
810
import org.maxxq.maven.dependency.ModelIO;
911

1012
import java.io.*;
@@ -34,10 +36,19 @@ private static void addOrOverwrite( List<Dependency> deps, Dependency d ) {
3436
deps.add( d );
3537
}
3638

37-
private static void addCurrentModule(String currentModule, List<Dependency> dependencies) {
39+
private static void addCurrentModule( VenusContext context, String currentModule, List<Dependency> dependencies) {
3840
Dependency d = new Dependency();
3941
d.setArtifactId( currentModule );
4042
d.setGroupId( GROUP_ID );
43+
if (StringUtils.isNotEmpty( context.getAddExclusions() ) ) {
44+
for ( String current : context.getAddExclusions().split( "," ) ) {
45+
String[] parts = current.split( ":" );
46+
Exclusion e = new Exclusion();
47+
e.setGroupId( parts[0] );
48+
e.setArtifactId( parts[1] );
49+
d.getExclusions().add( e );
50+
}
51+
}
4152
addOrOverwrite( dependencies, d );
4253
}
4354

@@ -79,7 +90,7 @@ protected static void addExtensionList( File pomFile, VenusContext context ) thr
7990
String moduleName = ModuleFacade.toModuleName( currentModule );
8091
log.info( "Adding module : {}", moduleName );
8192
if ( ModuleFacade.isModuleSupported( moduleName ) ) {
82-
addCurrentModule( moduleName, model.getDependencies() );
93+
addCurrentModule( context, moduleName, model.getDependencies() );
8394
context.getModules().add( currentModule );
8495
} else {
8596
String message = String.format( "Module not supported : %s", moduleName );

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import lombok.ToString;
66
import org.apache.maven.model.Model;
77
import org.fugerit.java.core.cfg.VersionUtils;
8+
import org.fugerit.java.core.lang.helpers.StringUtils;
89
import org.fugerit.java.doc.freemarker.config.FreeMarkerConfigStep;
910

1011
import java.io.File;
@@ -40,6 +41,15 @@ public class VenusContext {
4041
@Getter @Setter
4142
private Model mavenModel;
4243

44+
@Getter @Setter
45+
private String addExclusions;
46+
47+
public void setExcludeXmlApis( boolean excludeXmlApis ) {
48+
if ( excludeXmlApis ) {
49+
this.setAddExclusions( "xml-apis:xml-apis" );
50+
}
51+
}
52+
4353
public VenusContext(File projectDir, String version, String extensions ) {
4454
this.projectDir = projectDir;
4555
this.version = version;

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@ private File initConfigWorker(String configId ) throws IOException {
3636
@Test
3737
public void testAddVenus() throws IOException {
3838
int count = 0;
39-
for ( String currentConfig : Arrays.asList( "ok1-pom", "ok2-pom", "ok3-pom" ) ) {
39+
for ( String currentConfig : Arrays.asList( "ok1-pom", "ok2-pom", "ok3-pom", "ok4-pom" ) ) {
4040
File projectDir = this.initConfigWorker( currentConfig );
4141
log.info( "projectDir: {}, exists:{}", projectDir, projectDir.exists() );
4242
Assert.assertTrue( projectDir.exists() );
4343
String moduleList = "fj-doc-base,base-json,mod-fop,mod-opencsv,mod-poi";
4444
boolean addFacade = false;
45+
boolean excludeXmlApis = false;
4546
if ( count == 0 ) {
4647
moduleList = "base,freemarker";
4748
addFacade = true;
49+
} else if ( count == 3 ) {
50+
excludeXmlApis = true;
4851
}
4952
VenusContext context = new VenusContext( projectDir, this.getVersion(), moduleList );
53+
context.setExcludeXmlApis( excludeXmlApis );
5054
context.setAddDocFacace( addFacade );
5155
boolean result = AddVenusFacade.addVenusToMavenProject( context );
5256
Assert.assertTrue( result );
@@ -67,6 +71,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
6771
this.projectFolder = projectDir.getAbsolutePath();
6872
this.addDocFacade = true;
6973
this.force = true;
74+
this.excludeXmlApis = true;
7075
super.execute();
7176
}
7277
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<artifactId>fjdocmavenpluginok4</artifactId>
6+
<groupId>org.fugerit.java.test</groupId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
9+
<name>Fugerit Doc Maven Plugin Ok POM Test 4</name>
10+
11+
<licenses>
12+
<license>
13+
<name>Apache License, Version 2.0</name>
14+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
15+
<distribution>repo</distribution>
16+
</license>
17+
</licenses>
18+
19+
<organization>
20+
<url>https://www.fugerit.org</url>
21+
<name>Fugerit</name>
22+
</organization>
23+
24+
<url>https://www.fugerit.org/</url>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.fugerit.java</groupId>
29+
<artifactId>fj-core</artifactId>
30+
</dependency>
31+
</dependencies>
32+
33+
</project>

0 commit comments

Comments
 (0)