Maven Deploy Plugin
  1. Maven Deploy Plugin
  2. MDEPLOY-112

deployed snapshot name has different build numbers for multiple artifacts of the same build

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.6
    • Component/s: deploy:deploy
    • Labels:
      None
    • Environment:
      windows xp
    • Number of attachments :
      0

      Description

      I have a module that deploys 2 artifacts,1 jar and 1 of them is custom type. The build number from the snapshot name is different for the 2 (in the repository). It get incremented every time an artifact is deployed. When I try to make a local build it searches for the highest build number, and tries to bring both the artifacts with the latest build number but only one of them has that number.
      I found a workaround for this by <uniqueVersion>false</uniqueVersion> for the snapshotRepository.

        Activity

        Hide
        Benjamin Bentmann added a comment -

        An example POM or at least the relevant lines from the log output where Maven prints what it deploys would be helpful.

        Show
        Benjamin Bentmann added a comment - An example POM or at least the relevant lines from the log output where Maven prints what it deploys would be helpful.
        Hide
        Gabriel Dogaru added a comment - - edited

        [04:41:21]: [INFO] [deploy:deploy

        {execution: default-deploy}

        ]
        [04:41:21]: [INFO] No primary artifact to deploy, deploy attached artifacts instead.
        [04:41:21]: [INFO] Retrieving previous build number from snapshots_repo
        [04:41:21]: Uploading: file:////build/m2repository/snapshots/myapp/testutils/11.6-SNAPSHOT/testutils-11.6-20090902.084121-24.jar
        [04:41:21]: 78K uploaded (testutils-11.6-20090902.084121-24.jar)
        [04:41:21]: [INFO] Retrieving previous metadata from snapshots_repo
        [04:41:21]: [INFO] Uploading repository metadata for: 'artifact myapptestutils'
        [04:41:21]: [INFO] Retrieving previous metadata from snapshots_repo
        [04:41:21]: [INFO] Uploading repository metadata for: 'snapshot myapp:testutils:11.6-SNAPSHOT'
        [04:41:21]: [INFO] Retrieving previous build number from snapshots_repo
        [04:41:21]: Uploading: file:////build/m2repository/snapshots/myapp/testutils/11.6-SNAPSHOT/testutils-11.6-20090902.084121-25.resource
        [04:41:21]: 2K uploaded (testutils-11.6-20090902.084121-25.resource)
        [04:41:21]: [INFO] Retrieving previous metadata from snapshots_build
        [04:41:22]: [INFO] Uploading repository metadata for: 'artifact myapp:testutils'
        [04:41:22]: [INFO] Retrieving previous metadata from snapshots_repo
        [04:41:22]: [INFO] Uploading repository metadata for: 'snapshot myapp:testutils:11.6-SNAPSHOT'
        [04:41:22]: [INFO] ------------------------------------------------------------------------
        [04:41:22]: [INFO] BUILD SUCCESSFUL

        I am using project.addAttachedArtifact(artifact); in my mojo to attach the artifact

        Pom for distribution management:
        <distributionManagement>
        <repository>
        .........
        </repository>
        <snapshotRepository>
        <id>snapshots_repo</id>
        <name>snapshots_repo</name>
        <url>file:////build/m2repository/snapshots</url>
        </snapshotRepository>
        </distributionManagement>

        Show
        Gabriel Dogaru added a comment - - edited [04:41:21] : [INFO] [deploy:deploy {execution: default-deploy} ] [04:41:21] : [INFO] No primary artifact to deploy, deploy attached artifacts instead. [04:41:21] : [INFO] Retrieving previous build number from snapshots_repo [04:41:21] : Uploading: file:////build/m2repository/snapshots/myapp/testutils/11.6-SNAPSHOT/testutils-11.6-20090902.084121-24.jar [04:41:21] : 78K uploaded (testutils-11.6-20090902.084121-24.jar) [04:41:21] : [INFO] Retrieving previous metadata from snapshots_repo [04:41:21] : [INFO] Uploading repository metadata for: 'artifact myapptestutils' [04:41:21] : [INFO] Retrieving previous metadata from snapshots_repo [04:41:21] : [INFO] Uploading repository metadata for: 'snapshot myapp:testutils:11.6-SNAPSHOT' [04:41:21] : [INFO] Retrieving previous build number from snapshots_repo [04:41:21] : Uploading: file:////build/m2repository/snapshots/myapp/testutils/11.6-SNAPSHOT/testutils-11.6-20090902.084121-25.resource [04:41:21] : 2K uploaded (testutils-11.6-20090902.084121-25.resource) [04:41:21] : [INFO] Retrieving previous metadata from snapshots_build [04:41:22] : [INFO] Uploading repository metadata for: 'artifact myapp:testutils' [04:41:22] : [INFO] Retrieving previous metadata from snapshots_repo [04:41:22] : [INFO] Uploading repository metadata for: 'snapshot myapp:testutils:11.6-SNAPSHOT' [04:41:22] : [INFO] ------------------------------------------------------------------------ [04:41:22] : [INFO] BUILD SUCCESSFUL I am using project.addAttachedArtifact(artifact); in my mojo to attach the artifact Pom for distribution management: <distributionManagement> <repository> ......... </repository> <snapshotRepository> <id>snapshots_repo</id> <name>snapshots_repo</name> <url> file:////build/m2repository/snapshots </url> </snapshotRepository> </distributionManagement>
        Hide
        Benjamin Bentmann added a comment -

        I am using project.addAttachedArtifact(artifact); in my mojo to attach the artifact

        That's a valuable piece of info. Could you try calling MavenProjectHelper.attachArtifact() instead of directly mutating the project? Use something like

        /**
         * @component
         */
        private MavenProjectHelper projectHelper;
        

        to get the component injected into your mojo.

        Show
        Benjamin Bentmann added a comment - I am using project.addAttachedArtifact(artifact); in my mojo to attach the artifact That's a valuable piece of info. Could you try calling MavenProjectHelper.attachArtifact() instead of directly mutating the project? Use something like /** * @component */ private MavenProjectHelper projectHelper; to get the component injected into your mojo.
        Hide
        Gabriel Dogaru added a comment -

        I tried that .
        if i use MavenProjectHelper.attachArtifact() the artifacts do not have timestamp or build number. They get deployed the same way as using uniqueVersion=false.
        The reason why I didn't use MavenProjectHelper the first time is that for some projects I needed to create artifacts with a different name than project.name, and there is no MavenProjectHelper.attachArtifact() that would accept artifactId as parameter.
        Also I couldn't (still can't) use AttachedArtifact in project.addAttachedArtifact(artifact) as it is used in MavenProjectHelper because of some dependency conflict (I use gmaven 1.0-rc-4 and maven 2.2.1) and I used instead DefaultArtifact. I guess that is not a problem since they both implement Artifact.

        Show
        Gabriel Dogaru added a comment - I tried that . if i use MavenProjectHelper.attachArtifact() the artifacts do not have timestamp or build number. They get deployed the same way as using uniqueVersion=false. The reason why I didn't use MavenProjectHelper the first time is that for some projects I needed to create artifacts with a different name than project.name, and there is no MavenProjectHelper.attachArtifact() that would accept artifactId as parameter. Also I couldn't (still can't) use AttachedArtifact in project.addAttachedArtifact(artifact) as it is used in MavenProjectHelper because of some dependency conflict (I use gmaven 1.0-rc-4 and maven 2.2.1) and I used instead DefaultArtifact. I guess that is not a problem since they both implement Artifact.
        Hide
        Benjamin Bentmann added a comment -

        Fixed case of broken timestamped versions via attachArtifact() in r963122.

        Calling MavenProject.addAttachedArtifact() directly isn't the intended API usage so if you want to go down that route I suggest to implement your own versions of AttachedArtifact as well.

        Show
        Benjamin Bentmann added a comment - Fixed case of broken timestamped versions via attachArtifact() in r963122 . Calling MavenProject.addAttachedArtifact() directly isn't the intended API usage so if you want to go down that route I suggest to implement your own versions of AttachedArtifact as well.

          People

          • Assignee:
            Benjamin Bentmann
            Reporter:
            Gabriel Dogaru
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: