如何使用maven-publish和artifactory-gradle-plugin生成maven-metata.xml? [英] How do I generate maven-metata.xml with maven-publish and the artifactory-gradle-plugin?

查看:144
本文介绍了如何使用maven-publish和artifactory-gradle-plugin生成maven-metata.xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用groovy编写了Gradle插件,并使用Gradle来构建它.我有一个本地网络Artifactory服务器,我将结果发布到使用Gradle中的Gradle Artifactory插件和maven-publish插件.我还有另一个Gradle构建脚本,该脚本依赖于此插件作为依赖项.如果我列出了特定版本的依赖项,那么我已经能够使所有这些工作正常.我尝试使用Maven版本范围(例如'[1.0,2.0)'),但这未能说明无法找到maven-metadata.xml.我检查了Artifactory,果然不存在.我需要做些什么来产生它,最好是在构建插件的过程中?

I've written a Gradle plugin in groovy and used Gradle to build it. I've got a local network Artifactory server that I publish the results to using the Gradle Artifactory plugin and the maven-publish plugin in Gradle. I have another Gradle build script that relies on this plugin as a dependency. I've been able to get this all working if I list my dependency with a specific version. I've tried to use a maven version range (ex. '[1.0,2.0)'), but this fails saying it can't find maven-metadata.xml. I checked Artifactory, and sure enough, it isn't there. What do I need to do to produce it, preferably during the build of the plugin?

这是我的自定义gradle插件的build.gradle文件:

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
        }
    }
}

我已经搜索了Gradle,Artifactory和Maven文档,以了解maven-metadata.xml以及如何生成和部署.它的含义是合理的,我可能可以手动构建一个,但是我找不到任何能特别说明如何使用maven-publish插件或artifactory-gradle-plugin在Gradle中自动生成它的东西.我不想手动更新文件,因为那样做会使自动化工作失败,而且我已经在Gradle上投入了很多资金,所以我不想切换到mvn.

I've searched the Gradle, Artifactory, and Maven documentation to understand maven-metadata.xml and how to generate and deploy. It makes sense what it is, and I could probably build one manually, but I can't find anything that explains specifically how to automatically generate it in Gradle with either the maven-publish plugin or the artifactory-gradle-plugin. I don't want to have to manually update the file since that would defeat the automation effort, and I don't want to switch to mvn since I've already invested so much in Gradle.

推荐答案

必须将 groupId 添加到 publications 部分.实施后,将 maven-metadata.xml 文件发布到工件存储库中.

A groupId had to be added to the publications section. Once implemented, a maven-metadata.xml file was published to the artifact repository.

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

这篇关于如何使用maven-publish和artifactory-gradle-plugin生成maven-metata.xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆