How do I create maven-metata.xml with maven-publish and artifactory- gradle -plugin?

I wrote the Gradle plugin in Groovy and used Gradle to build it. I have an Artifactory LAN server that I publish results using the Gradle Artifactory plugin and the maven-publish plugin in Gradle. I have another Gradle build script that uses this plugin as a dependency. I was able to make it all work if I list my dependency with a specific version. I tried to use the maven version range (for example, '[1.0,2.0)'), but that did not help, saying that it could not find maven-metadata.xml. I checked Artifactory, and of course it is not there. What do I need to do to produce it, preferably during plugin build?

Here is the build.gradle file for my custom gradle plugin:

buildscript {
    repositories {
        maven {
            url "${artifactory_contextUrl}/plugins-release"
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
        }
    }
    dependencies {
        classpath group: 'org.apache.directory.studio', name: 'org.apache.commons.io', version: '2.4'
        classpath group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.9'
    }
}

plugins {
    id 'com.jfrog.artifactory' version '3.0.1'
}

apply plugin: 'groovy'
apply plugin: 'maven-publish'

artifactory {
    contextUrl = "${artifactory_contextUrl}"
    publish {
        repository {
            repoKey = 'plugins-snapshot-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true
        }
        defaults {
            publications ('mavenJava')
        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true
        }
    }
}

dependencies {
    compile gradleApi()
    compile localGroovy()
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
}

I searched the Gradle, Artifactory, and Maven documentation to understand maven-metadata.xml and learn how to create and deploy it. It makes sense what it is, and I could probably create it manually, but I cannot find anything that specifically explains how to automatically generate it in Gradle using the maven-publish plugin or artifactory-gradle-plugin. I don’t want to update the file manually, as this will nullify all the automation efforts, and I don’t want to switch to mvn, since I have already invested so much in Gradle.

+4
source share
2 answers

groupId publications. maven-metadata.xml .

publishing {
    publications {
        mavenJava(MavenPublication) {
            groupId = 'com.group'
        }
    }
}
+4

maven-metadata.xml Artifactory. Artifactory?

0

All Articles