如何在 Gradle 中创建路径 jar
在 Windows 环境中运行 groovyc 时,在我的情况下,由于类路径的长度,我遇到了问题。我想通过创建一个路径 jar 来解决这个问题,然后将该 jar 放在 cp 上。如何创建一个包含在 gradle 中自动指定的所有类路径条目的路径 jar,然后将该 jar 添加到 cp 中?
When running groovyc in a Windows env, I am running into issues due to the length of the classpath, in my situation. I would like to work around this by creating a pathing jar, and then put that jar on the cp. How can I create a pathing jar w/ all of the classpath entries specified automatically in gradle and then add that jar to the cp?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个经过测试的解决方案:
根据您的具体要求,您可能需要对此进行一些调整。例如,如果您有用 Groovy 编写的测试,则还需要一个用于测试编译类路径的路径 Jar。在这种情况下,您需要重复上述配置,如下所示:
Here is a tested solution:
Depending on your exact requirements, you might have to tweak this a bit. For example, if you have tests written in Groovy, you will also need a pathing Jar for the test compile class path. In this case you'll need to repeat above configuration as follows:
我终于实现了“pathing jar”的想法。我认为这是一个永久的解决方法。如果它是 gradle 本身的一部分,那么这可以被认为是一个解决方案。
原来的pathing jar代码是Peter提供的,但是没有用。问题:路径 jar 中引用的类路径元素必须相对于路径 jar 的位置。所以,这似乎对我有用。
I finally got the "pathing jar" idea to work. I consider this to be a permanent workaround. This could be considered a solution if it is made part of gradle itself.
The original pathing jar code was provided by Peter, but it didn't work. The problem: classpath elements referenced in the pathing jar must be relative to the location of the pathing jar. So, this appears to work for me.
这对我有帮助:
“文件名或扩展名太长错误”使用 gradle
换句话说:使用 com.github.ManifestClasspath 插件。
其他解决方案对我不起作用,因为实际的项目主类最终在执行时没有包含在类路径中。
This is what helped me:
"The filename or extension is too long error" using gradle
In other words: use the com.github.ManifestClasspath plugin.
The other solutions did not work for me because the actual project main class ended up no being included in the classpath at execution time.