Skip to content

Commit 6a66b23

Browse files
authored
Merge pull request #1028 from Backbase/feature/Exclude-dirs-from-bundle
Add 'excludes' parameter for 'bundle' execution.
2 parents b2189a1 + 1182b1d commit 6a66b23

File tree

5 files changed

+59
-0
lines changed

5 files changed

+59
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ It currently consists of
1414

1515
# Release Notes
1616
BOAT is still under development and subject to change.
17+
## 0.17.61
18+
* Added new `excludes` parameter into `bundle` execution to exclude certain files (default: `**/lib/**`) to avoid generating externally downloaded spec files.
1719
## 0.17.60
1820
* Allow references to parent directory of the spec itself, to be able to refer to common examples in a common lib.
1921
* Fix tests... petshop example moved.

boat-maven-plugin/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ Available parameters:
212212
Required: false
213213
List of file patterns to include to bundle.
214214

215+
excludes (Default: **/lib/**)
216+
Required: false
217+
List of file patterns to exclude to bundle.
218+
215219
output (Default: ${project.build.directory}/openapi)
216220
Required: true
217221
Output directory for the bundled OpenAPI specs.

boat-maven-plugin/src/main/java/com/backbase/oss/boat/BundleMojo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public class BundleMojo extends AbstractMojo {
5151
@Parameter(name = "includes", defaultValue = "**/openapi.yaml, **/*api*.yaml")
5252
protected String[] includes;
5353

54+
@Parameter(name = "excludes", defaultValue = "**/lib/**")
55+
protected String[] excludes;
56+
5457
@Parameter(name = "output", required = true, defaultValue = "${project.build.directory}/openapi")
5558
private File output;
5659

@@ -91,6 +94,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9194
DirectoryScanner directoryScanner = new DirectoryScanner();
9295
directoryScanner.setBasedir(input);
9396
directoryScanner.setIncludes(includes);
97+
directoryScanner.setExcludes(excludes);
9498
directoryScanner.scan();
9599

96100
String[] includedFiles = directoryScanner.getIncludedFiles();

boat-maven-plugin/src/test/java/com/backbase/oss/boat/BundleMojoTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.junit.jupiter.params.provider.ValueSource;
1818

1919
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertFalse;
2021
import static org.junit.jupiter.api.Assertions.assertThrows;
2122
import static org.junit.jupiter.api.Assertions.assertTrue;
2223
import static org.junit.jupiter.api.Assertions.fail;
@@ -64,6 +65,28 @@ void testBundleFolder() {
6465
assertTrue(new File(outputFolder, "one-client-api-v1.3.5.yaml").exists());
6566
assertTrue(new File(outputFolder, "one-client-api-v2.0.0.yaml").exists());
6667
assertTrue(new File(outputFolder, "another-client-api-v1.7.9.yaml").exists());
68+
assertFalse(new File(outputFolder, "test-client-api-v1.1.1.yaml").exists());
69+
}
70+
71+
@Test
72+
@SneakyThrows
73+
void testBundleFolder_whenExcludesExists() {
74+
var outputFolder = "target/test-bundle-bundler";
75+
76+
BundleMojo mojo = new BundleMojo();
77+
78+
mojo.setInput(new File(getClass().getResource("/bundler").getFile()));
79+
mojo.setOutput(new File(outputFolder));
80+
mojo.setIncludes(new String[]{"**/*-api-v*.yaml"});
81+
mojo.setExcludes(new String[]{"**/folder/**"});
82+
mojo.setVersionFileName(true);
83+
mojo.setFlattenOutput(true);
84+
mojo.execute();
85+
86+
assertFalse(new File(outputFolder, "one-client-api-v1.3.5.yaml").exists());
87+
assertFalse(new File(outputFolder, "one-client-api-v2.0.0.yaml").exists());
88+
assertFalse(new File(outputFolder, "another-client-api-v1.7.9.yaml").exists());
89+
assertTrue(new File(outputFolder, "test-client-api-v1.1.1.yaml").exists());
6790
}
6891

6992
@Test
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.1.1
4+
title: Test
5+
license:
6+
name: MIT
7+
paths:
8+
'/client-api/v1/tests':
9+
get:
10+
summary: List all tests
11+
operationId: listTests
12+
responses:
13+
'200':
14+
description: A paged array of tests
15+
content:
16+
application/json:
17+
schema:
18+
$ref: "#/components/schemas/Tests"
19+
components:
20+
schemas:
21+
Tests:
22+
type: object
23+
properties:
24+
-id:
25+
type: string
26+
description: The id of this test.

0 commit comments

Comments
 (0)