首页 > 解决方案 > Gradle没有将工件上传到工件

问题描述

我正在尝试上传一个用 gradle 创建的 jar,但我遇到了麻烦,因为我对 gradle 或 artifactory 都不熟悉。

由于这是一个旧项目,因此使用的是 Gradle 3.5。

这是我添加到 build.gradle 文件中的内容:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
    }
}

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

artifactory {
    contextUrl = "xxxxxxxxx"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'repokey1'
            username = "xxxxxxx"
            password = "xxxxxx" 
        }
    }
    resolve {
        repository {
            repoKey = 'repokey2'
            username = "xxxxxx"
            password = "xxxxxx"  
        }
    }
}
apply plugin: "com.jfrog.artifactory"

当我运行时:

gradle artifactoryPublish

我收到以下消息:

Deploying build descriptor to: http://xxxxxxxx/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under http://xxxxxxx/artifactory/webapp/builds/my-project/1626816605048/2021-07-20T17:30:05.039-0400/

如果我访问 http://xxxxxxxx/artifactory/api/build 我会得到一个带有一些元数据的 json,但是在任何地方都找不到 jar,我错过了什么吗?

标签: javagradleartifactory

解决方案


Gradle Artifactory 插件应该被告知要上传哪个发布配置。在您的情况下,您可以添加收集所有 JAR 的默认“存档”配置:

artifactory {
    publish {
        ...
        defaults {
            publishConfigs('archives')
        }
    }
}

注意 - 不推荐使用发布配置方法,具有较新 Gradle 版本的用户应使用 Gradle 发布。

阅读更多:

  1. 文档
  2. 例子

推荐阅读