首页 > 解决方案 > 将 gradle 项目部署到 Artifactory

问题描述

几天来,我试图将一个 gradle 项目部署到 Artifactory,但我的任何尝试都成功了!

我正在使用 Artifactory 6.1.0 和 gradle on ecipe 氧气释放

我在 Artifactory 中创建了一个管理员用户和一个 gradle 存储库

我将代码 [来自存储库的生成设置] 添加到 build.gradle 文件中,这是内容

//In fact I am not sure if I need all of them!?
apply plugin: 'java-library'
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'

buildscript {
    repositories {
        jcenter()

    }
    dependencies {
        //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
    }
}

allprojects {
    apply plugin: "com.jfrog.artifactory"
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'xyz_reposit'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
    resolve {
        repository {
            repoKey = 'gradle-dev'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
}

publishing {
    publications {
        maven(MavenPublication) {
            groupId = 'myGroup'
            artifactId = 'myProject'
            version = '1.0.0'

            from components.java
        }
    }
}

并且配置了 gradle.properties

artifactory_user=Admin
artifactory_password=password
artifactory_contextUrl=http://localhost:8081/artifactory

当我从此处发布执行 artifactoryDe​​ploy 时,cmd 中的结果

从eclipse执行部署后的cmd消息

当我回到 Artifactory 时,xyz 存储库中没有发布任何内容!?你能帮帮我吗!?我很确定 build.gradle 代码中缺少某些东西?!

标签: gradledeploymentartifactorypublishingartifact

解决方案


您使用的是什么版本的版本?我建议更新到最新的 5.4.1

其次,您还应该gradlew artifactoryPublish在做完artifactoryDeploy.

要查看命令的差异,请运行:

gradlew tasks

推荐阅读