-
-
Notifications
You must be signed in to change notification settings - Fork 256
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 support for publishing maven-metadata.xml #1260
base: master
Are you sure you want to change the base?
Conversation
Maven repositories normally have a maven-metadata.xml file that indicate to the Maven system what versions are available and which is to be considered the latest version. ```xml <metadata modelVersion="1.1.0"> <groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId> <versioning> <latest>1.0</latest> <release>1.0</release> <versions> <version>1.0</version> </versions> <lastUpdated>20200731090423</lastUpdated> </versioning> </metadata> ``` At Confluent, we use AWS Code Artifactory which does not mark a Maven package as "published" unless a new maven-metadata.xml is uploaded indicating so. * Add support for reading existing maven-metadata.xml * Add support for adding the new version to the metadata object * Add support to upload the file for http & file protocols * Add small test cases to validate SerDe for Maven metadata object from XML Co-authored-by: Vince Rose <[email protected]> Co-authored-by: Na Lou <[email protected]>
@shs96c we added a flag to keep it backwards compatible, but we are of the opinion the default should be true. |
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.
We tested this locally using:
bazel run //tests/integration/pom_file:pom-example-with-runtime-dep.publish --define "maven_repo=file:///tmp/.m2"
(Note: we had to have set the publish_maven_metadata
attr for the target)
Internally at Confluent, we tested the publishing via HTTP to AWS Code Artifactory as well.
ByteArrayOutputStream os = new ByteArrayOutputStream(); | ||
new MetadataXpp3Writer().write(os, metadata); | ||
Files.write(newMavenMetadataXml, os.toByteArray()); | ||
return upload(mavenMetadataUrl, credentials, newMavenMetadataXml); |
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: upload could probably take InputStream but I didn't want to change too much of the code;
Open to doing another pass after on this file if you are open to it.
* Attempts to download the file at the given targetUrl. | ||
* Valid protocols are: http(s) & file at the moment. | ||
*/ | ||
private static CompletableFuture<Optional<String>> download( |
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: could move this to a separate file Downloaders
to keep this file a bit smaller.
Maven repositories normally have a maven-metadata.xml file that indicate to the Maven system what versions are available and which is to be considered the latest version.
At Confluent, we use AWS Code Artifactory which does not mark a Maven package as "published" unless a new maven-metadata.xml is uploaded indicating so.
Co-authored-by: Vince Rose [email protected]
Co-authored-by: Na Lou [email protected]