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

Add s3 handling for maven-metadata #37

Merged
merged 2 commits into from
Dec 12, 2024
Merged

Conversation

vinnybod
Copy link
Member

@vinnybod vinnybod commented Dec 12, 2024

We need to be able to use s3 as a maven registry, but the original maven-metadata.xml code that we added didn't support s3. This adds that support.

I tested locally with an s3 bucket and using --define maven_repo=s3://{bucket}

The reason for a lot of the line changes was running the formatter bazel run scripts:format. I did revert the untouched files. We should probably update bazel-contrib#1260

@vinnybod vinnybod requested a review from a team as a code owner December 12, 2024 21:32
Copy link

@fzakaria fzakaria left a comment

Choose a reason for hiding this comment

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

LGTM + some nits for readability.

Comment on lines 374 to 375
* Attempts to download the file at the given targetUrl. Valid protocols are: http(s) & file at
* the moment.

Choose a reason for hiding this comment

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

Nit: comment should update.

try {
URI s3Uri = new URI(targetUrl);
String bucketName = s3Uri.getHost();
String path = s3Uri.getPath().substring(1);

Choose a reason for hiding this comment

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

nit: i would path -> key better naming for S3.
I would break out this parsing maybe into URI -> S3Object

}
return Optional.of(
com.google.common.io.Files.asCharSource(path.toFile(), StandardCharsets.UTF_8)
.read());

Choose a reason for hiding this comment

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

Nit: Java11+ has String content = Files.readString(path, encoding);

);
}
catch (HttpResponseException e) {
CharStreams.toString(

Choose a reason for hiding this comment

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

                    new InputStreamReader(response.getContent(), StandardCharsets.UTF_8)));```
Might be nice to make this a small utility function.

@fzakaria fzakaria self-requested a review December 12, 2024 22:43
@vinnybod vinnybod merged commit ac31db3 into master Dec 12, 2024
1 check passed
@vinnybod vinnybod deleted the vinnybod/s3-maven-metadata branch December 12, 2024 22:43
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