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 support for publishing maven-metadata.xml #1260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fzakaria
Copy link

@fzakaria fzakaria commented Oct 3, 2024

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.

<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]

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]>
@fzakaria
Copy link
Author

fzakaria commented Oct 3, 2024

@shs96c we added a flag to keep it backwards compatible, but we are of the opinion the default should be true.
Let us know what you think.

Copy link
Author

@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.

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);
Copy link
Author

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(
Copy link
Author

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.

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.

1 participant