为什么Gradle不在本地Maven存储库中查找插件? [英] Why does Gradle not look in the local maven repository for plugins?

查看:1065
本文介绍了为什么Gradle不在本地Maven存储库中查找插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了Gradle插件并将其发布到本地Maven存储库.我可以在〜/.m2/存储库中看到它.但是,当我运行Gradle项目以使用此插件时,它甚至不会在本地存储库中查找……至少,不是基于输出.

I have built a Gradle plugin and published it to the local maven repository. I can see it in my ~/.m2/repository. However, when I run a Gradle project to use this plugin, it does not even look in the local repository...at least, not based on the output.

从命令行运行时会报告此情况:

It reports this when running from the command-line:

失败:构建失败,并出现异常.

FAILURE: Build failed with an exception.

其中:构建文件'D:\ Work \ MuseProject \ update4j-gradle-plugin \ example \ build.gradle' 行:15

Where: Build file 'D:\Work\MuseProject\update4j-gradle-plugin\example\build.gradle' line: 15

出了什么问题:插件[id:'net.christophermerrill.gradle.update4j',版本:'0.1']不是 在以下任何来源中找到:

What went wrong: Plugin [id: 'net.christophermerrill.gradle.update4j', version: '0.1'] was not found in any of the following sources:

-Gradle Core插件(插件不在"org.gradle"命名空间中)

-- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)

-插件存储库(无法解析插件工件'net.christophermerrill.gradle.update4j:net.christophermerrill.gradle.update4j.gradle.plugin:0.1')

-- Plugin Repositories (could not resolve plugin artifact 'net.christophermerrill.gradle.update4j:net.christophermerrill.gradle.update4j.gradle.plugin:0.1')

在以下存储库中搜索: Gradle中央插件存储库

Searched in the following repositories: Gradle Central Plugin Repository

我已经将mavenLocal()添加到buildscript配置中.我还尝试添加特定的依赖项(如在其他地方建议的那样),

I have added mavenLocal() to the buildscript configuration. I also tried adding the specific dependency (as was suggested elsewhere) with no effect

buildscript {
  repositories {
      mavenLocal()
  }
  dependencies {
      classpath 'net.christophermerrill:update4j-gradle-plugin:0.1'
  }
}

从输出中可以最好地看出,它甚至没有在本地存储库中查找,但我不确定100%.使用--scan和--info选项不会提供任何其他见解-它们似乎根本不起作用,我怀疑这是因为失败出现在插件完成加载之前(只是猜测).

Best I can tell from the output, it is not even looking in the local repository, but I am not 100% sure. Using the --scan and --info options does not provide any additional insights - they appear to do nothing at all, which I suspect is because the failure appears before the plugins finish loading (just guessing).

是否可以确定Gradle是否在本地Maven存储库中查找?我正在尝试消除这种可能性.当然,另一种选择是我的插件未正确发布.在解决了这个问题之后,这将是我的下一个问题:)

Is there a way to determine if Gradle is looking in the local Maven repo? I am trying to eliminate this as a possibility. The alternative, of course, is that my plugin is not published correctly. That will be my next question, after I settle this one :)

推荐答案

我认为指定自定义插件存储库看起来很有希望:此功能使您可以配置plugins{} DSL以从gradle插件门户网站之外的其他存储库中进行解析.我认为您想使用以下配置来更新settings.gradle:

I think that specifying a custom plugin repository looks promising: this feature lets you configure the plugins{} DSL to resolve from other repositories in addition to the gradle plugin portal. I think you'd want to update your settings.gradle with configuration something along the lines of:

pluginManagement {
  repositories {
      mavenLocal()
      gradlePluginPortal()
  }
}

(请注意,此代码块需要显示在settings.gradle的顶部).

(Note that this code block needs to appear at the top of settings.gradle).

这篇关于为什么Gradle不在本地Maven存储库中查找插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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