简体   繁体   English

在gradle自定义插件中添加Jar依赖项

[英]Adding Jar dependency in gradle custom plugin

Assuming all my Gradle plugin user going to have a MYAPP_HOME sys variable set in there system in MYAPP_HOME page i have a jar at $MYAPP_HOME/lib/mylib.jar 假设我所有的Gradle插件用户都将在MYAPP_HOME页面的系统中设置一个MYAPP_HOME sys变量,我在$ MYAPP_HOME / lib / mylib.jar中有一个jar

i am writing my own plugin.... 我正在编写自己的插件...。

I can find the MYAPP_HOME variable is set and fine the jar exists.. 我可以找到MYAPP_HOME变量已设置,并且罐子存在。

How can i add this jar dependency in my custom gradle plugin... ? 如何在我的自定义gradle插件中添加此jar依赖项...? when user runs my plugin say compileMyplugin my custom gradle plugin need to set the $MYAPP_HOME/lib/mylib.jar jar as compiler dependent 当用户运行我的插件时说compileMyplugin我的自定义gradle插件需要将$ MYAPP_HOME / lib / mylib.jar jar设置为依赖于编译器

How to do this any one help me ? 这对我有什么帮助?

The plugin just needs to do: 该插件只需要做:

project.dependencies {
    compile project.files("${System.getenv("MYAPP_HOME")}/lib/mylib.jar"))
}

PS: In general, I wouldn't recommend relying on an environment variable and the availability of a Jar on the local file system. PS:通常,我不建议依赖环境变量和本地文件系统上Jar的可用性。 Instead, I'd publish the Jar to an artifact repository or put it under source control. 相反,我会将Jar发布到工件存储库中,或将其置于源代码控制之下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM