gpt4 book ai didi

gradle - Artifactory虚拟存储库无法解析Gradle-Artifactory插件

转载 作者:行者123 更新时间:2023-12-03 03:39:23 26 4
gpt4 key购买 nike

所以,我尽力让build-info-extractor-gradle插件正常工作……抱歉发泄。 ;-)

我正在使用gradle包装器,指定gradle 1.6,artworkory 3.0.0,并尝试指定对build-info-extractor-gradle插件2.1.x-SNAPSHOT的依赖,因为这是gradle 1.5及更高版本的specified version

我正在尝试遵循此tutorial video,但是它必须已过时,因为它仍在引用gradle 1.0并指定jfrog repo路径,该路径不包含插件的2.x版本。

人工设置

  • 本地存储库-“gradle-release-local”-布局设置为gradle-default
  • 远程仓库-“gradle-plugins”-从jfrog导入中稍作修改-例如http://repo.jfrog.org/artifactory/gradle-plugins-snapshots
  • 虚拟存储库-“gradle”-“gradle-release-local”和“gradle-plugins”


  • Gradle 设置

    settings.gradle(从 Artifact 生成)
    buildscript {
    repositories {
    maven {
    url 'http://artifactory.build.somewhere.com:8081/artifactory/gradle'
    credentials {
    username = "${artifactory_user}"
    password = "${artifactory_password}"
    }
    }

    }
    dependencies {
    classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.1.x-SNAPSHOT'
    }
    }

    allprojects {
    apply plugin: 'artifactory'
    }

    artifactory {
    contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
    repository {
    repoKey = 'gradle-release-local'
    username = "${artifactory_user}"
    password = "${artifactory_password}"
    maven = true
    ivy {
    ivyLayout = '[organization]/[module]/ivy-[revision].xml'
    artifactLayout = '[organization]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]'
    mavenCompatible = false
    }
    }
    }
    resolve {
    repository {
    repoKey = 'gradle'
    username = "${artifactory_user}"
    password = "${artifactory_password}"
    maven = true

    }
    }
    }

    如果我在本地上传jar,则我的存储库配置可以正常工作,例如这就是我下载build-info-extractor-gradle jar的方式。但是,所有依赖项都会失败,如您所见:
        $ gradlew tasks

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not resolve all dependencies for configuration 'classpath'.
    > Could not find commons-io:commons-io:2.0.1.
    Required by:
    unspecified:unspecified:unspecified > org.jfrog.buildinfo:build-info-extractor-gradle:2.1.x-SNAPSHOT
    > Could not find org.apache.ivy:ivy:2.2.0.
    Required by:
    unspecified:unspecified:unspecified > org.jfrog.buildinfo:build-info-extractor-
    ...
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    关于gradle配置或人工仓库配置有什么问题的任何想法吗?为什么它不能解析远程存储库中的外部依赖关系?我应该只添加mavenCentral吗?

    更新资料

    我将mavenCentral()添加到存储库中,只是为了看看会发生什么并得到:
    $ gradlew tasks
    Download http://repo1.maven.org/maven2/commons-io/commons-io/2.0.1/commons-io-2.0.1.pom
    Download http://repo1.maven.org/maven2/org/apache/commons/commons-parent/15/commons-parent-15.pom
    Download http://repo1.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.pom
    Download http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
    Download http://repo1.maven.org/maven2/org/apache/commons/commons-parent/5/commons-parent-5.pom
    Download http://repo1.maven.org/maven2/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.pom

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not resolve all dependencies for configuration 'classpath'.
    > Could not find org.jfrog.buildinfo:build-info-extractor:2.1.x-SNAPSHOT.
    Required by:
    unspecified:unspecified:unspecified > org.jfrog.buildinfo:build-info-extractor-gradle:2.1.x-SNAPSHOT

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    更新#2

    开始新鲜。删除了mavenCentral()和本地上载的jar和pom,然后使用--info和--refresh-dependencies运行:
    $ gradlew --refresh-dependencies -i tasks
    Starting Build
    Settings evaluated using empty settings script.
    Projects loaded. Root project using build file 'D:\repos\some_build\build.gradle'.
    Included projects: [root project 'some_build']
    Evaluating root project 'some_build' using build file 'D:\repos\some_build\build.gradle'.
    Compiling build file 'D:\repos\some_build\build.gradle' using BuildScriptClasspathScriptTransformer.
    Resource missing. [HTTP GET: http://artifactory.build.somewhere.com:8081/artifactory/gradle/org/jfrog/buildinfo/build-info-extractor-gradle/2.1.0/build-info-extractor-gradle-2.1.0.pom]
    Resource missing. [HTTP HEAD: http://artifactory.build.somewhere.com:8081/artifactory/gradle/org/jfrog/buildinfo/build-info-extractor-gradle/2.1.0/build-info-extractor-gradle-2.1.0.jar]

    FAILURE: Build failed with an exception.

    因此,很明显,我的虚拟“gradle”存储库没有找到 Artifact 。如何确定它是否在搜索远程“gradle-plugins”存储库?

    最佳答案

    h!事实证明,有两个非常重要的配置选项,禁用远程存储库解析,它们是默认选择的(我不记得要检查/取消选中这些吗?)。

    无论如何,这是我所做的,为了最终通过我的虚拟存储库的解析使gradle-artifactory plugin工作:

  • 禁用全局离线模式
  • 转到:Admin -> Configuration -> General
  • 确保取消选择全局脱机模式。您会在General Settings
  • 中看到此选项
  • 保存
  • 为您的虚拟仓库启用远程 Artifact 解析
  • 转到:Admin -> Configuration -> Repositories -> {Edit the virtual repo} -> Advanced Settings
  • 确保虚拟存储库具有人工请求,可以检索远程 Artifact 选择的
  • 保存
  • gradle-plugins远程存储库添加到您的虚拟存储库中
  • 在远程存储库中选择New
  • 给您的远程仓库一个名称,例如jfrog-gradle-plugins
  • URL设置为http://repo.jfrog.org/artifactory/gradle-plugins
  • 保存
  • 使用jfrog-gradle-plugins选项
  • Selected Repositories远程仓库添加到虚拟仓库的 Edit中。
  • 保存

  • build.gradle中添加以下内容:
    buildscript {
    repositories {
    maven {
    url "${repositoryUrl}/libs-release"
    }
    }
    dependencies {
    classpath( group: 'org.jfrog.buildinfo',
    name: 'build-info-extractor-gradle',
    version: '2.2.2')
    }
    }

    gradle.properties中添加以下内容:
    repositoryUrl = http://my.artifactory.server:8081/artifactory
    repositoryUser = me
    repositoryPassword = thisIsAPasswordStoredInMyUserDirectory

    希望这能帮助任何开始集成 ArtifactoryGradle的人。

    在Artifactory中调试 Artifact 解析的有用提示

    使用 trace REST API选项。例如:

    http://repo.jfrog.org/artifactory/gradle-plugins/org/jfrog/buildinfo/build-info-extractor-gradle/2.2.2/build-info-extractor-gradle-2.2.2?trace

    关于gradle - Artifactory虚拟存储库无法解析Gradle-Artifactory插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17518284/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com