Skip to content

publishM2 doesnt write maven-metadata-local.xml which make SNAPSHOT work near impossible #2053

@gurgl

Description

@gurgl

Problem that arise, especially when working snapshots, of localy and remotly available artifacts of same version. It all comes down to sbt task "publishM2" doesnt write a

maven-metadata-local.xml

that could contain :

<metadata modelVersion="1.1.0">
    <groupId>com.mycompany.libraries</groupId>
    <artifactId>myartifact</artifactId>
    <version>2.0.0-SNAPSHOT</version>
    <versioning>
        <snapshot>
            <localCopy>true</localCopy>
        </snapshot>
        <lastUpdated>20150505040202</lastUpdated>
        <snapshotVersions>
            <snapshotVersion>
                <classifier>sources</classifier>
                <extension>jar</extension>
                <value>2.0.0-SNAPSHOT</value>
                <updated>20150505040202</updated>
            </snapshotVersion>
            <snapshotVersion>
                <extension>jar</extension>
                <value>2.0.0-SNAPSHOT</value>
                <updated>20150505040202</updated>
            </snapshotVersion>
            <snapshotVersion>
                <extension>pom</extension>
                <value>2.0.0-SNAPSHOT</value>
                <updated>20150505040202</updated>
            </snapshotVersion>
        </snapshotVersions>
    </versioning>
</metadata>

If the above file isnt present it makes it impossible for maven to distinguish between a local and a remote versions of an artifact of same verison number (2.0.0-SNAPSHOT in this example). When a maven project depends on a sbt-publishM2 artifact - it downloads any remote version (say one is in "myRemoteRepository". At this point a file is created by maven in the users .m2 folder for the given artifact :

maven-metadata-myRemoteRepository.xml

<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
    <groupId>com.mycompany.libraries</groupId>
    <artifactId>myartifact</artifactId>
    <version>2.0.0-SNAPSHOT</version>
    <versioning>
        <snapshot>
            <timestamp>20150504.135536</timestamp>
            <buildNumber>15</buildNumber>
        </snapshot>
        <lastUpdated>20150504135536</lastUpdated>
        <snapshotVersions>
            <snapshotVersion>
                <extension>jar</extension>
                <value>2.0.0-20150504.135536-15</value>
                <updated>20150504135536</updated>
            </snapshotVersion>
            <snapshotVersion>
                <extension>pom</extension>
                <value>2.0.0-20150504.135536-15</value>
                <updated>20150504135536</updated>
            </snapshotVersion>
            <snapshotVersion>
                <classifier>sources</classifier>
                <extension>jar</extension>
                <value>2.0.0-20150504.135536-15</value>
                <updated>20150504135536</updated>
            </snapshotVersion>
        </snapshotVersions>
    </versioning>
</metadata>

...containing lastUpdated that is later used to compare with other maven-metadata- versions - to determine if remote build is newer than local... comparing lastUpdated.

This make publishM2 sort of useless in when creating SBT built artifacts for use in a maven project

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions