【问题标题】:How to amend Gradle plugins {} management repository for custom plugins?如何为自定义插件修改 Gradle plugins {} 管理存储库?
【发布时间】:2018-08-08 08:45:44
【问题描述】:

我的公司代理/防火墙设置阻止 jcentermavencentral 等,因此,我无法从 GitHub 获取 Gradle 自定义 插件。

我正在使用 gradle 4.7 并且仍然使用通过 buildscript{} 获取插件的旧方法 - 即 Gradle 1.x。我想使用 plugins{} 并将 id 放在该块内,但我不能,因为默认存储库正在尝试从中获取它。

有没有办法修改插件 repo? 可能在 init.gradle 或 cmd arg 中?

或者也许只是添加另一个来查看。我找到了一些链接,但那些已经过期,我最后的手段就是检查源代码。我希望有一个简单的答案。

Gradle 2.1 及更高版本想用这个

plugins {
    id "de.undercouch.download" version "3.4.3"
}

Gradle 1.x 和 2.0 目前使用这个

buildscript {
    repositories {
        mynexusrepo()
    }
    dependencies {
        classpath 'de.undercouch:gradle-download-task:3.4.3'
    }
}

apply plugin: 'de.undercouch.download'

【问题讨论】:

    标签: java gradle


    【解决方案1】:

    我找到了一个可行的解决方案。它已经更改了几次,但对于 4.7 版本的 Gradle,这看起来是一个可行的解决方案。

    记住,有些插件需要在 GString "" 中!

    这需要在settings.gradle 作为第一个工作块。

    pluginManagement {
        repositories {
            maven { url "http://cdlnexus01:8081/nexus/content/groups/GradlePlugins/" }
            maven { url "http://cdlnexus01:8081/nexus/content/groups/public/" }
            maven { url "https://plugins.gradle.org/m2/" }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-09-14
      • 2013-12-25
      • 2015-08-27
      • 2023-03-31
      • 1970-01-01
      • 2021-04-18
      • 1970-01-01
      • 1970-01-01
      • 2012-07-15
      相关资源
      最近更新 更多