Gradle中的自定义依赖管理插件 [英] Custom dependency management plugin in Gradle

查看:112
本文介绍了Gradle中的自定义依赖管理插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何编写一个自定义gradle插件来处理自定义模块描述符中的依赖关系? gradle文档说明了以下内容,但我一直无法找到任何告诉我 的内容。


即使您的项目使用自定义依赖关系管理系统或
类似Eclipse .classpath文件作为
依赖项管理的主数据,也很容易编写Gradle插件来使用
这个数据在Gradle中。


我一直在维护 ATG项目的自定义常春藤解析器(从这个项目),但Gradle最近弃用了1.8版本,我需要将实现移植到本地Gradle插件中。



实现 ATG 使用'模块'(与Gradle项目不同),有一个MANIFE ST.MF文件用于模块描述符。这些文件定义了模块依赖的其他模块,以及构成当前模块的(直接)类路径的路径列表(jar或目录)。

例如

  ATG-Class-Path:lib / classes。 jar lib / commons-beanutils-1.7.jar 
ATG-Required:MyProj.core MyProj.integration.webservices DAF.Endeca.Assembler

模块依赖关系是传递性的,可能涉及ATG产品安装中的自定义模块或模块。因此,我需要定义一个可以使用ATG产品安装作为工件源的自定义存储库。



没有Gradle,我需要以


  1. ATG的 MANIFEST.MF 文件

  2. Eclipse .classpath files

  3. Ant构建脚本的依赖关系

  4. SonarQube配置
  5. li>

因为我无法摆脱ATG MANIFEST.MF文件,所以我想编写一个自定义插件来允许它们用于Gradle构建。然后,我可以使用Gradle作为我的构建系统,它也可以生成Eclipse .classpath和.project文件,并针对该项目运行Sonar。



Gradle似乎有很多在过去的几天里翻找它并没有让我知道任何地方。



如果有人能指向我需要的接口列表(2)实现一个自定义的依赖解析器(使用自定义文件作为模块描述符),这应该足以让我开始。

解决方案上面提到的Eclipse .classpath 用例可以通过解析该文件并将其转换为Gradle文件相关性来解决。目前无法插入自定义存储库实现。


How do you write a custom gradle plugin to handle dependencies in a custom module descriptor, from a custom repository? The gradle documentation says the following, but I haven't been able to find anything that tells me how.

Even if your project is using a custom dependency management system or something like an Eclipse .classpath file as master data for dependency management, it is very easy to write a Gradle plugin to use this data in Gradle.

I've been maintaining a Custom Ivy resolver for ATG projects (forked from this project), but Gradle recently deprecated this with version 1.8, and I need to port the implementation to a native Gradle plugin.

Implementations of ATG use 'modules' (not unlike Gradle projects), that have a MANIFEST.MF file for a module descriptor. These files define other 'modules' that a module depends on, and also a list of paths (jars or directories) that form the (direct) classpath for the current module.

e.g.

ATG-Class-Path: lib/classes.jar lib/commons-beanutils-1.7.jar
ATG-Required: MyProj.core MyProj.integration.webservices DAF.Endeca.Assembler

Module dependencies are transitive, and may refer to custom modules or modules that sit within the ATG product installation. Hence, I need to define a custom repository that can use the ATG product installation as a source of artifacts.

Without Gradle, I need to maintain dependencies in the form of

  1. ATG's MANIFEST.MF files
  2. Eclipse .classpath files
  3. Dependencies for the Ant build-script
  4. SonarQube configurations

Since I can't get rid of the ATG MANIFEST.MF files, I would like to write a write a custom plugin to allows them to be used in Gradle builds. I can then use Gradle as my build system, which can also generate Eclipse .classpath and .project files, and run Sonar against the project.

Gradle seems to have a lot of source code, and rummaging through it for the last couple of days hasn't got me anywhere.

If someone can point me to a list of interfaces that need to be implemented to (1) implement a custom repository, and (2) implement a custom dependency resolver (to use custom files as module descriptors), that should be enough to get me started.

解决方案

The Eclipse .classpath use case mentioned above can be solved by parsing that file and translating it to Gradle file dependencies. It isn't currently possible to plug in a custom repository implementation.

这篇关于Gradle中的自定义依赖管理插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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