Prefers normal snapshot remote artifact over feature remote artifact after finding multiple

Create issue
Issue #1 new
joshf created an issue

Hello, Thanks for your work on this extension.

I have implemented it, and it seems to be working ok for pushing deps to the correct new feature repository. I am having trouble getting it to resolve the feature dependencies 'first', instead it appears to resolve them all simultaneously, and compare all the timestamps and then it downloads whichever is newest. It does consult the feature repository (below you can see "Downloaded https://artifactory.company.com/artifactory/libs-snapshot-feature-local/HO-1957-mc-star-related/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/maven-metadata.xml (992 B at 2.3 KB/sec)"

But since it is slightly older, the one from the primary snapshot repo is retrieved.

I've attempted to flip around various orders of repositories, but afaik it won't make any difference because there isn't a proper 'fall through' happening.

Thanks again for easing the pain with maven-> new branching models.

Josh

[DEBUG] Could not find metadata com.armus:hybrid-jsclient:1.10.0-SNAPSHOT/maven-metadata.xml in local (/root/.m2/repository)
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://172.19.20.28:8080/artifactory/repo
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://artifactory.company.com/artifactory/libs-snapshot-feature-local/HO-1957-mc-star-related
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://172.19.20.28:8080/artifactory/libs-snapshot-local
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://maven.springframework.org/snapshot
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://172.19.20.28:8080/artifactory/repo
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://artifactory.company.com/artifactory/libs-snapshot-feature-local/HO-1957-mc-star-related with username=_maven_rw, password=***
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://172.19.20.28:8080/artifactory/libs-snapshot-local
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://maven.springframework.org/snapshot
[INFO] Downloading: http://maven.springframework.org/snapshot/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/maven-metadata.xml
[INFO] Downloading: https://artifactory.company.com/artifactory/libs-snapshot-feature-local/HO-1957-mc-star-related/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/maven-metadata.xml
[INFO] Downloading: http://172.19.20.28:8080/artifactory/repo/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/maven-metadata.xml
[INFO] Downloading: http://172.19.20.28:8080/artifactory/libs-snapshot-local/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/maven-metadata.xml
[INFO] Downloaded: http://172.19.20.28:8080/artifactory/libs-snapshot-local/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/maven-metadata.xml (979 B at 5.5 KB/sec)
[DEBUG] Writing tracking file /root/.m2/repository/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/resolver-status.properties
[INFO] Downloaded: http://172.19.20.28:8080/artifactory/repo/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/maven-metadata.xml (979 B at 5.3 KB/sec)
[DEBUG] Writing tracking file /root/.m2/repository/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/resolver-status.properties
[DEBUG] Writing tracking file /root/.m2/repository/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/resolver-status.properties
[INFO] Downloaded: https://artifactory.company.com/artifactory/libs-snapshot-feature-local/HO-1957-mc-star-related/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/maven-metadata.xml (992 B at 2.3 KB/sec)
[DEBUG] Writing tracking file /root/.m2/repository/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/resolver-status.properties
[DEBUG] Could not find metadata com.armus:hybrid-jsclient:1.10.0-SNAPSHOT/maven-metadata.xml in springsource (http://maven.springframework.org/snapshot)
[DEBUG] Using transporter WagonTransporter with priority -1.0 for http://172.19.20.28:8080/artifactory/libs-snapshot-local
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for http://172.19.20.28:8080/artifactory/libs-snapshot-local
[INFO] Downloading: http://172.19.20.28:8080/artifactory/libs-snapshot-local/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/hybrid-jsclient-1.10.0-20170411.221148-308.war
[INFO] Downloaded: http://172.19.20.28:8080/artifactory/libs-snapshot-local/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/hybrid-jsclient-1.10.0-20170411.221148-308.war (1226 KB at 2699.2 KB/sec)
[DEBUG] Writing tracking file /root/.m2/repository/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/com/company/hybrid-jsclient/1.10.0-SNAPSHOT/hybrid-jsclient-1.10.0-20170411.221148-308.war.lastUpdated
[INFO] Copying hybrid-jsclient-1.10.0-SNAPSHOT.war to /var/jenkins_home/jobs/local/workspace/parent/tmp_build_docker/hybrid-jsclient.war

settings.xml

<repository>
  <id>Maven-feature-snapshot</id>
  <name>libs-feature</name>
    <url>https://artifactory.company.com/artifactory/libs-snapshot-feature-local/${git.branch}</url>
    <releases>
        <enabled>false</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
        <checksumPolicy>warn</checksumPolicy>
    </snapshots>
</repository>
...
<properties>
  <features.repositoryName>libs-feature</features.repositoryName>
  <features.branchProperty>git.branch</features.branchProperty>
</properties>

pom.xml

<profile>
    <id>FEATURE</id>
    <distributionManagement>
        <snapshotRepository>
            <name>libs-snapshot</name>
            <id>${feature.repository.id}</id>
            <url>${feature.repository.url}</url>
        </snapshotRepository>
    </distributionManagement>
</profile>

Comments (5)

  1. Bogdan Calmac

    Here is my experience, which most likely points to the same issue.

    Consider 2 projects app and lib and let's say we make two incompatible changes on branches FOO-1 and FOO-2.

    1. [In lib on FOO-1] mvn deploy
    2. [In app on FOO-1] mvn -U compile -> OK
    3. [In lib on FOO-2] mvn deploy
    4. [In app on FOO-2] mvn -U compile -> OK. So far so good. But now:
    5. [In app on FOO-1] mvn -U compile -> FAIL. This is because the locally installed FOO-2 lib is newer than the one from FOO-1 and maven keeps using it.

    Now, if I clear the local repo and I only have downloaded artifacts, everything's fine:

    1. [In app on FOO-1] mvn -U compile -> OK
    2. [In app on FOO-2] mvn -U compile -> OK
    3. [In app on FOO-1] mvn -U compile -> OK
    4. [In app on FOO-2] mvn -U compile -> OK

    This time the maven extension correctly switches the artifact according the the current branch.

    To summarize, if a locally installed artifact from a wrong branch is newer, the maven-branch-extension can no longer force the use of the remote artifact from the correct branch.

  2. joshf reporter

    @bcalmac-cc I believe this is a distinct case, probably should be opened as a separate issue in the tracker. I base that opinion on the code I've reviewed in this plugin about dealing with local .m2, in which cache files are directly manipulated in order to attempt to deal with the issue you're describing. The issue I raised on the other hand assumes no .m2 state whatsoever, rather its 'which remote artifact is maven going to resolve when it finds more than one matching?' In my case I know mvn finds the feature branch artifact AND of course it can see the normal SNAPSHOT location as well which has a colliding artifact.

  3. Log in to comment