artifactory-gradle-plugin icon indicating copy to clipboard operation
artifactory-gradle-plugin copied to clipboard

Provide a way to override the 'id' of the build-info file

Open enaess opened this issue 2 years ago • 1 comments

Describe the bug

Pretty much a vanilla java multi-project configuration

Apply a configuration at the root project's build.gradle file

artifactoryPublish.skip = true
artifactory {
    contextUrl = 'my-artifactory-server'
    publish {
        repository {
            repoKey = "proj-repo-local"
            username = "${ArtifactoryUsername}"
            password = "${ArtifactoryPassword}"
        }
        defaults {
            publications 'ALL_PUBLICATIONS'
            properties = [ 
                'build.changelist': "${System.env.P4_CHANGELIST ?: '10000'}",
                'build.branch': "${System.env.BRANCH_NAME ?: 'MyBranch'}"
                ]
        }
    }
    clientConfig.setIncludeEnvVars(true)
    clientConfig.info.setProject('proj')
}

Then apply the artifactory plugin in a sub-project; however, because of the structure of these projects; I will have to individually configure the maven publication with an artifactId and a groupId

publishing {
    publications {
        mavenJava(MavenPublication) {
            groupId "org.company.group"
            artifactId "my-artifact-id"
            from components.java
            pom {
                properties = [ 
                    "build.changelist": "${System.env.P4_CHANGELIST ?: '10000'}",
                    "build.branch": "${System.env.BRANCH_NAME ?: 'MyBranch'}"
                ]
            }    
        }
    }   
}

Current behavior

Now the resulting moduleInfo.json will take the project name descriptor (project-id) for module-id when publishing the build-info, and module type is GRADLE.

Because of how the projects are organized, there is no way of overriding the module-id (or even group-id) that forms the "id" when you look at moduleInfo.json that is being uploaded to Artifactory as a part of the module-id. It's directly tied to the resolved Gradle's project-id: {group}-{project-name}-{version}.

I would have to restructure how the Gradle projects works to alter this behavior. That isn't going to fly when you have lots of engineers working on a project.

Reproduction steps

No response

Expected behavior

It would be much simpler to be able to change the module/id in the .json file with a simple override; or use the basename of the publication for the module instead.

{
  "type" : "gradle",
  "id" : "PROJECT_NAME.path.to.application:1.00.10000",
  "repository" : "proj-gradle-dev",
  "artifacts" : [ {
    "type" : "jar",
    "sha1" : "....",
    "sha256" : "....",
    "md5" : "...",
    "name" : "application-1.00.10000.jar",
    "path" : "com/mycompany/group/application/1.00.10000/application-1.00.10000.jar"
  }],
  "dependencies" : [ {
    "type" : "",
    "id" : "PROJECT_NAME.path.to.dependency.lib:1.00.10000",
    "scopes" : [ "compileClasspath"],
    "requestedBy" : [ [ "PROJECT_NAME.path.to.application:1.00.10000" ] ]
  }, {

When I look in artifactory, it seems like it is unable to fully resolve the paths to the artifacts within the build itself.

No path found (externally resolved or deleted/overwritten)

Even though the "PROJECT_NAME.path.to.dependency.lib:1.00.10000" is present in the build info file.

While that may be an entirely separate / different problem to how Artifactory manages the links to the various artifacts uploaded. The ability to at least name modules according to your custom layout should still exist (e.g. I'd like to be able to override module-id= ${project.id}-${group}-${version}.

Artifactory Gradle plugin version

5.1.10

Operating system type and version

Ubuntu 22.04

JFrog Artifactory version

7.41.14

Gradle version

N/A

enaess avatar Oct 18 '23 22:10 enaess

This issue has been marked as stale due to 6 months of inactivity. As part of our effort to address every issue properly, please feel free to remove the stale label or keep this issue active by leaving a comment. Otherwise, it will be closed in 7 days

github-actions[bot] avatar May 01 '25 00:05 github-actions[bot]