Hi everyone :wave: I wonder if I can bounce some ...
# community-support
l
Hi everyone 👋 I wonder if I can bounce some ideas about publishing artefacts using IvyPublication and the artifactory plugin. I have a gradle sub-project responsible for creating a zip archive and making it available as an artefact. Another gradle project responsible for pulling different parts together should be responsible for publishing this (and other) artefacts to artifactory. I have two questions: 1. Am I correct in understanding that the standard approach for making an output of a task available as an artefact is the following:
Copy code
// sub-project-a
 
plugins {
    id 'base'
    id 'ivy-publish'
    id 'com.jfrog.artifactory' version "5.2.5"
}

repositories {
    ivy {
        patternLayout {
            artifact '[organization]/[module]/[revision]/[module]-[revision](.[classifier]).[ext]'
        }
    }
}

configurations {
    someDistribution
}

task generateZip(type: Zip) {
    from 'some-place'
    include '*.some-extension'

    archiveBaseName.set(module)
    archiveClassifier.set('my-classifier')
    archiveVersion.set(version)
    destinationDirectory.set(layout.buildDirectory)

    outputs.files(archiveFile)
}

artifacts {
    someDistribution generateZip.archiveFile
}
2. When it comes to publishing, how should I refer to the artefacts generated by this sub-project?
Copy code
// sub-project-b
plugins {
    id 'base'
    id 'ivy-publish'
    id 'com.jfrog.artifactory' version '5.2.5'
}

configurations {
    someDistribution 
}

dependencies {
    someDistribution project(path: ':common:sub-project-a', configuration: 'someDistribution')
}

publishing {
    publications {
        create('somePub', IvyPublication) {
           // How to refer to the artefacts from someDistribution?
        }
    }
}
I am still new to this area, so I fully appreciate this might not be the best way to do things. Thanks in advance 🙂
v
I heard not much good things about the artifactory plugin, just that often people have problems with it and ended up using just the normal Gradle built-in publishing.
Am I correct in understanding that the standard approach for making an output of a task available as an artefact is the following:
The ivy-publish, artifactory, and repositories configuration are irrelevant in
sub-project-a
to the example. And the configurations in both projects de not have a clear role which is legacy and bad practice. Like you declared them, they are declarable, resolvable, and consumable, and in
sub-project-b
you also use it for declaring and plan to use it for resolving. You should either use the incubating helpers to create properly roled configuration or set the properties manually accordingly and use them accordingly. For the consumer this would mean a second configuration which is resolvable and extends the first configuration. But generally that is one of the ways to safely share build output between projects, yes.
When it comes to publishing, how should I refer to the artefacts generated by this sub-project?
I have no idea about what you need to do for the Artifactory plugin. For the normal built-in publishing it depends on whether you just want the artifact uploaded and a half-baked POM along it, or a proper publishing with Gradle Module Metadata and so on. For the former it should be sufficient to use
artifact(...)
in the plublication, for the latter you would need to create a proper component as shown in the documentation and publish that. Btw. I strongly recommend switching to Kotlin DSL. By now it is the default DSL, you immeditaley get typesafe build scripts, actually helpful error messages if you mess up the syntax, and amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.