-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
Co-authored-by: jainruchir <[email protected]>
There was a problem hiding this 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.
* Attempts to download the file at the given targetUrl. Valid protocols are: http(s) & file at | ||
* the moment. |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
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