Skip to content

Add --exclude option to the maven profile#1225

Merged
Konboi merged 3 commits intov1from
mvn-plugin-support-exclude-option
Jan 29, 2026
Merged

Add --exclude option to the maven profile#1225
Konboi merged 3 commits intov1from
mvn-plugin-support-exclude-option

Conversation

@Konboi
Copy link
Contributor

@Konboi Konboi commented Jan 28, 2026

Why

When using launchable subset maven, there was no way to exclude specific packages (e.g., e2e tests) from the subset. Users needed a way to filter out certain test patterns using regular expressions.

What

  • Added --exclude option to the maven subset command
  • The option accepts regular expression patterns to exclude matching tests
  • Multiple --exclude options can be specified to exclude multiple patterns
  • Invalid regular expressions will result in a clear error message

Usage example

# Exclude e2e tests
launchable subset --no-build maven --exclude "\.e2e\." src/test/java/

# Exclude multiple patterns
launchable subset --no-build maven --exclude "\.e2e\." --exclude "\.integration\." src/test/java/

@Konboi Konboi requested review from gayanW and ono-max January 29, 2026 00:23
@ono-max
Copy link
Contributor

ono-max commented Jan 29, 2026

Just out of curiosity, why do you wanna configure the regular expression instead of glob patterns? I believe glob patterns are more common for filename pattern matching?

https://security.stackexchange.com/questions/279011/why-should-one-use-globs-over-regex-when-doing-filename-pattern-matching#:~:text=1%20Answer,19

Co-authored-by: Naoto Ono <nono@cloudbees.com>
@Konboi
Copy link
Contributor Author

Konboi commented Jan 29, 2026

@ono-max

why do you wanna configure the regular expression instead of glob patterns?

My motivation for this PR is to exclude specific packages.
The rules are applied to the class names with package information, as shown below:

            test_path = file2class_test_path(f)

            for pattern in compiled_exclude_rules:
                if pattern.search(test_path[0]["name"]):
                    return None

https://github.com/cloudbees-oss/smart-tests-cli/pull/1225/changes#diff-8c5a081ee7b6445f53fe6dd7bab128e214152586c882e490fe07ae707f30e1e1R95-R96

In this context, Java package names are not file paths e.g.) com.launchableinc.xxx

That's why I chose the regexp instead of glob patterns.
Additionally, because this is a Maven profile, using packages rather than directories is expected to be more intuitive for users.

Does this make sense?

@ono-max
Copy link
Contributor

ono-max commented Jan 29, 2026

It does make sense. Thank you for your explanation!

@Konboi Konboi merged commit d0d6ecc into v1 Jan 29, 2026
13 checks passed
@Konboi Konboi deleted the mvn-plugin-support-exclude-option branch January 29, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants