Adding custom file to Artifactory with maven-publish+shadow


(Enrico) #1

Hello guys.

So, I’m kind of new to gradle but I’ve managed to set up a build.gradle that publishes my jar to an artifactory repository.

However, in order to work, this Jar requires an external configuration, config/name.properties, so that we have something like:

-- name.jar
-- config/othername.jar

The jar is used only by people that know about this configuration thing, so no readme it’s required at the moment. However, it would be good to have the properties file on artifactory so that it can be copy-pasted by the users. I’m not interested in having the .properties downloaded by any dependencies manager, just to have it on artifactory in this kind of manner: https://imgur.com/a/19D7wsQ.

So, my question is: how can i publish a directory+file, by keeping the file name and directory names?

This are the relevant parts of my build.gradle:

    publishing {
        publications {
            shadow(MavenPublication) { publication ->
                project.shadow.component(publication)
                artifactId = jar.baseName
                artifact(tasks.javadocJar)
               //add file + dir here as artifact
            }
        }
        repositories {
            maven {
                url ARTIFACTORY_URL
                credentials {
                    username = ARTIFACTORY_USER
                    password = ARTIFACTORY_PSW
                }
            }
        }
    }

I’m using shadow and maven-publish plugins.

Thank you.

PS: if you have any other best practice to deal with my problem, let me know.