Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix io-gcp requiring hamcrest dependency #30619

Closed
wants to merge 2 commits into from

Conversation

Abacn
Copy link
Contributor

@Abacn Abacn commented Mar 12, 2024

Fix #30617

Please add a meaningful description for your change here


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@Abacn Abacn force-pushed the fixhamcrestprovided branch 2 times, most recently from d0b9684 to 2ec11a1 Compare March 13, 2024 01:46
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@Abacn
Copy link
Contributor Author

Abacn commented Mar 13, 2024

The failed PostCommit tests are either due to #30560 or quota error (failed to bring 1 worker)

R: @ahmedabu98 @kennknowles

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

@ahmedabu98
Copy link
Contributor

Can we trigger BQ early rollout tests here?

paths: ['release/trigger_all_tests.json', '.github/trigger_files/beam_PostCommit_Java_BigQueryEarlyRollout.json']

@ahmedabu98
Copy link
Contributor

Also would it make sense to combine TestBigQueryOptions and BigtableChangeStreamTestOptions in a new test/.../gcp/common/TestGcpIoPipelineOptionsRegistrar? instead of having them in separate registrars

@Override
public Iterable<Class<? extends PipelineOptions>> getPipelineOptions() {
return ImmutableList.<Class<? extends PipelineOptions>>builder()
.add(TestBigQueryOptions.class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are options for TestBigQuery which is intended for users. Anything intended for users should be under src/main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestBigQueryOptions is still in main. The problem here is there is an AutoService to register TestBigQueryOptions, then whenever a PipelineOptionFactory.fromArgs is called, the PipelineOptionFactory tries to do some reflection access to TestBigQueryOptions which causes NoClassDefFoundError: org/hamcrest/Matcher. This is because TestPipelineOptions has a method return a Matcher.

This makes org.hamcrest effectively a required dependency (instead of optional one) for Beam io-gcp.

If do not register TestBigQueryOptions, users can still use it. They just need to register the option before they call PipelineOptionFactory.withValidation().

Copy link
Contributor Author

@Abacn Abacn Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative fix will just be make it a implementation dependency here:

provided library.java.hamcrest

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, making it an implementation dependency seems correct. It is, after all, an implementation dependency :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hamcrest is a tiny tiny library that is super stable and has no transitive deps and not going to have security concerns - there is no reason to avoid it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, opened #30635 and close this PR

@kennknowles
Copy link
Member

I know it could seem like anything "for testing" goes under src/test and should not be in the classpath, but that is not quite true. The only things that go in src/test or test dependency scope are things that are part of the test suite. Nothing should ever depend on the test scope artifact, so we shouldn't put anything in it that we want to distribute.

@Abacn Abacn closed this Mar 14, 2024
@Abacn Abacn deleted the fixhamcrestprovided branch March 14, 2024 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: hamcrest required in class path in 2.55.0
3 participants